I replaced the username with the userid, and it successfully got my follower count. Thanks for the help! I’ll keep the code here in case anyone finds it useful.
local http = game:GetService("HttpService")
local client_id = "<your_client_id>" -- Replace <your_client_id> with your Twitch API client ID
local client_secret = "<your_client_secret>" -- Replace <your_client_secret> with your Twitch API client ID
local ClientAccountName = "<your_client_name>"
local function GetToken()
-- Make an HTTP request to the Twitch API to get an access token
local url = "https://id.twitch.tv/oauth2/token"
local data = "client_id="..client_id.."&client_secret="..client_secret.."&grant_type=client_credentials"
local request = http:PostAsync(url,data,Enum.HttpContentType.ApplicationUrlEncoded,false)
local data = http:JSONDecode(request)
print(data.access_token)
return data.access_token
end
-- Make an HTTP request to the Twitch API to get the user's follower count
local url = "https://api.twitch.tv/helix/users/follows?to_id=<your_client_id>" -- Replace <your_client_id> with your Twitch ID
local headers = {
["Client-ID"] = client_id,
["Authorization"] = "Bearer "..GetToken(),
}
local response = http:GetAsync(url,false,headers)
local data = http:JSONDecode(response)
local follower_count = data.total
print("Follower count for "..ClientAccountName..": "..follower_count)