How do I use Speedrun.com API

I saw this game called ☃️Survive and Kill the Killers in Area 51 !!! - Roblox and I’m curious how they use “Speedrun API”, https://www.speedrun.com/ has there own API. I was able to find out how to tell if the user Exists using the PFP Size, but how would I use the auth token to log a player in to get access to certain features. Why I’m asking is because I’m recreating an older version of the game I linked, and I thought why not add this feature, even though this is new, it will still add more potential.

Heres the code I used to reference with PFP Size:

local Data = game:GetService("HttpService"):GetAsync("https://www.speedrun.com/api/v1/users?lookup=Autoimi")

local LuaData = game:GetService("HttpService"):JSONDecode(Data)

if LuaData.pagination.size == 0 then
	print("Failed")
else
	print("Success")
end

Forgot to list the Documentation, api/version1 at master · speedruncomorg/api · GitHub

Simply set the “X-API-Key” header to the api key, and you should be able to do it. For example, to pass it in the current code you have:

local Data = game:GetService("HttpService"):GetAsync("https://www.speedrun.com/api/v1/users?lookup=Autoimi", {
	["X-API-Key"] = "key"
})

I get this error:

  17:29:04.584  Unable to cast Dictionary to bool  -  Server - SpeedrunAPI:1
  17:29:04.584  Script 'ServerScriptService.SpeedrunAPI', Line 1  -  Studio - SpeedrunAPI:1

I’m using my API key from my profile which you can get at: https://www.speedrun.com/user/Autoimi/settings/apikey (Change Autoimi with your username)

Wait just realized in the middle all I have to do is do false, lol

Maybe use RequestAsync or PostAsync instead of GetAsync.

I need to use GetAsync to get the players token, because I need to verify its a real AuthToken

Are you sure it will work with GetAsync? I thought RequestAsync was required to send the API key to the server:


or am I missing something?

I think you might be right, I don’t know how to write this in :RequestAsync() format.

Found a way nvm. Thank you!!!

I have now made some _G functions to handle using the API. All examples can be found here: Speedrun API - Roblox, of course its in version 1, so it doesn’t have Saving API Data, but that will come soon, and that’s when I’ll make my DevForum post about it, give me some tips, and feedback! :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.