Twitch API after and pagination

Hello I wnated to ask how this works:

$channelsApi21 = 'https://api.twitch.tv/helix/streams?first=100&after=20&language=de&game_id=XYZ;

Is that correct?

after should be the value of pagination.cursor returned in a request that doesn’t include an after

$pageXX = $resp1X->data[0]->pagination;

Will that return one?

That will then contain a key of cursor which will be the after value to pass yes

miss read the code snippet

So than is that after=RETURN?

 $channelsApi21 = 'https://api.twitch.tv/helix/streams?first=100&language=de&game_id=';
 $ch21 = curl_init();

 curl_setopt_array($ch21, array(
    CURLOPT_HTTPHEADER => array(
       'Client-ID: ' . $clientId,
'Authorization: Bearer ' . $keys->access_token
    ),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_URL => $channelsApi21 . $gameID1
 ));

 $response21 = curl_exec($ch21);

$resp1X = json_decode($response21);
$pageXX = $resp1X->data[0]->pagination;

echo "PAGE: $pageXX";

so far this returns nothing?

Then you might have got the first and only page

What game ID are you trying?

Fortnite

In German language!

An example from the TwitchCLI

twitch api get 'streams?first=1&language=de&game_id=33214'
{
  "data": [
    {
      "game_id": "33214",
      "game_name": "Fortnite",
      "id": "44565798381",
      "is_mature": false,
      "language": "de",
      "started_at": "2021-11-25T17:22:52Z",
      "tag_ids": [
        "9166ad14-41f1-4b04-a3b8-c8eb838c6be6"
      ],
      "thumbnail_url": "https://static-cdn.jtvnw.net/previews-ttv/live_user_tantechantii-{width}x{height}.jpg",
      "title": "Late Game Arenaa mit Anakin \u0026 Annalena! // !twitter !ova !subrekord",
      "type": "live",
      "user_id": "592513880",
      "user_login": "tantechantii",
      "user_name": "tantechantii",
      "viewer_count": 270
    }
  ],
  "pagination": {
    "cursor": "eyJiIjp7IkN1cnNvciI6ImV5SnpJam95TnpBdU56WTBNalUxTkRJMU5ETTFNalFzSW1RaU9tWmhiSE5sTENKMElqcDBjblZsZlE9PSJ9LCJhIjp7IkN1cnNvciI6ImV5SnpJam95TnpBdU56WTBNalUxTkRJMU5ETTFNalFzSW1RaU9tWmhiSE5sTENKMElqcDBjblZsZlE9PSJ9fQ"
  }
}

You should see that

So the cursor in your code should be

$resp1X->pagination->cursor;

not

$resp1X->data[0]->pagination;

So in your descs is no cursor, written!

Not sure what you mean

So I did no where see that there has to be that with cursor. Do you code only in own clubs for it?

Still not sure what you mean.

I get the feeling you are google translating and it’s murdering the transation

Sorry I was joking, I ment nowhere I`ve found that with cursor!

Thanks solved it now!

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