Racc
September 10, 2023, 3:03pm
1
So I made a bot which checks to see if a channel is live for discord and when live sends a message however out of nowhere im getting this issue with my bot:
Checking if the response contains data
{“data”: ,“pagination”:{}}
No data received from the Twitch API.
am i being rate limited? or is something else going on?
code which might help?:
/* Construct the stream URL */
std::string streamURL = “https://api.twitch.tv/helix/streams?user_login= ” + channel;
#ifdef _DEBUG
std::cout << streamURL << std::endl;
#endif
/* Prepare HTTP headers */
dpp::http_headers headers;
headers.insert( std::make_pair( "Client-ID", twitchClientId ) );
headers.insert( std::make_pair( "Authorization", "Bearer " + twitchAccessToken ) );
and im doing a get request
if the data array is empty it indicates the channel is not live
an example from the CLI
CohhCarnage is live, cohh is not
barrycarlyon@Robyn ~ % twitch api get 'streams?user_login=cohh'
{
"data": [],
"pagination": {}
}
barrycarlyon@Robyn ~ % twitch api get 'streams?user_login=cohhcarnage'
{
"data": [
{
"game_id": "506438",
"game_name": "Starfield",
"id": "41834847337",
"is_mature": false,
"language": "en",
"started_at": "2023-09-10T14:57:31Z",
"tag_ids": [],
"tags": [
"adhd",
"moderated",
"devswelcome",
"parent",
"goodvibes",
"chill",
"BackseatingWelcome",
"NoPolitics",
"NoSpoilers",
"Variety"
],
"thumbnail_url": "https://static-cdn.jtvnw.net/previews-ttv/live_user_cohhcarnage-{width}x{height}.jpg",
"title": "[!DoNotNG+ (Updated) / !ShipGuide / !OutpostGuide] STARFIELD! - !Coffee / !MobileApp",
"type": "live",
"user_id": "26610234",
"user_login": "cohhcarnage",
"user_name": "CohhCarnage",
"viewer_count": 4838
}
],
"pagination": {
"cursor": "eyJiIjp7IkN1cnNvciI6ImV5SnpJam8wT0RNNExqTTJNemswT0RRM01USXpMQ0prSWpwbVlXeHpaU3dpZENJNmRISjFaWDA9In0sImEiOnsiQ3Vyc29yIjoiIn19"
}
}
Dist
September 10, 2023, 3:04pm
3
No data or pagination because there’s no streams that are live, and no further pages to go through (and when specifying specific streamers, there wouldn’t be pagination anyway).
Racc
September 10, 2023, 3:06pm
4
weird though i had the channel live at the time? and the post that barry sent is what i’d usually get as a response i have a picture of it somewhere
Racc
September 10, 2023, 3:07pm
5
i do loop through a vector for my channels just for extra information i presume it doesnt matter if the channel name in the link isnt all lowercase?
it shouldn’t
barrycarlyon@Robyn ~ % twitch api get 'streams?user_login=cOhHcArNaGe'
{
"data": [
{
"game_id": "506438",
"game_name": "Starfield",
"id": "41834847337",
"is_mature": false,
"language": "en",
"started_at": "2023-09-10T14:57:31Z",
"tag_ids": [],
"tags": [
"adhd",
"moderated",
"devswelcome",
"parent",
"goodvibes",
"chill",
"BackseatingWelcome",
"NoPolitics",
"NoSpoilers",
"Variety"
],
"thumbnail_url": "https://static-cdn.jtvnw.net/previews-ttv/live_user_cohhcarnage-{width}x{height}.jpg",
"title": "[!DoNotNG+ (Updated) / !ShipGuide / !OutpostGuide] STARFIELD! - !Coffee / !MobileApp",
"type": "live",
"user_id": "26610234",
"user_login": "cohhcarnage",
"user_name": "CohhCarnage",
"viewer_count": 5056
}
],
"pagination": {
"cursor": "eyJiIjp7IkN1cnNvciI6ImV5SnpJam8xTURVMkxqTTJNemswT0RRM01USXpMQ0prSWpwbVlXeHpaU3dpZENJNmRISjFaWDA9In0sImEiOnsiQ3Vyc29yIjoiIn19"
}
}
But a user_login
is technically all lowercase
Racc
September 10, 2023, 3:12pm
7
could there be a chance im rate limited then?
if you are rate limited you get a HTTP 429 not a blank/not live response.
Racc
September 10, 2023, 3:14pm
9
ah alr thanks
checked over my code i cant see anything obvious changed all the channels in my vector to mine just incase but same problem im so lost
Racc
September 10, 2023, 3:15pm
10
weird it started working just now again? changed literally nothing so lost
barrycarlyon@Robyn ~ % twitch api get 'streams?user_login=raccisvibin'
{
"data": [
{
"game_id": "516575",
"game_name": "VALORANT",
"id": "41088844296",
"is_mature": true,
"language": "en",
"started_at": "2023-09-10T15:13:29Z",
"tag_ids": [],
"tags": [
"SafeSpace",
"LGBT",
"English"
],
"thumbnail_url": "https://static-cdn.jtvnw.net/previews-ttv/live_user_raccisvibin-{width}x{height}.jpg",
"title": "Valorant vibin",
"type": "live",
"user_id": "124630891",
"user_login": "raccisvibin",
"user_name": "RaccIsVibin",
"viewer_count": 0
}
],
"pagination": {}
}
if you literally just went live it can take a moment or two for the API to catch up due to caching.
You show 2 minutes of up time.
If you rapid offline/online/offline/online it can confuse things
Racc
September 10, 2023, 3:16pm
13
yeah before i tested though and had the same issue i was live for about 45 mins
Racc
September 10, 2023, 3:19pm
14
one final thing seems that for whatever reason setting my channel as the first channel in the vector it then and only then detects me as live so its something i messed up ig?
I don’t know what you mean by “vector”
So whats the full request you are making?
Racc
September 10, 2023, 3:22pm
16
this is what i mean by a vector:
inline static std::vector< std::string > channels{ “raccisvibin”, “faiavt”, “raccisvibin” };
i loop through checking each channel names status in my code hope that clarifies
Which should equate to a call of
twitch api get ‘streams?user_login=raccisvibin&user_login=faiavt&user_login=raccisvibin’
But it soulds like your library is not constructing the URL like that.
So check what you code actaully calls
Racc
September 10, 2023, 3:28pm
18
no it does the code each time per channel making the stream link only streams?user_login=raccisvibin
Then there no reason I can think of for the problem you are having.
Racc
September 10, 2023, 3:31pm
20
alr thanks i appreciate your help<3