# Twitch API after and pagination

**URL:** <https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975>\
**Category:** API\
**Created:** [November 25, 2021, 8:37pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975 "2021-11-25T20:37:32Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:37pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/1 "2021-11-25T20:37:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 25, 2021, 8:38pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/2 "2021-11-25T20:38:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:39pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/3 "2021-11-25T20:39:05Z")

</div>

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

Will that return one?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 25, 2021, 8:39pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/4 "2021-11-25T20:39:43Z")

</div>

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

miss read the code snippet

---

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:40pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/5 "2021-11-25T20:40:10Z")

</div>

So than is that after=RETURN?

---

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:40pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/6 "2021-11-25T20:40:59Z")

</div>

```auto
 $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?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 25, 2021, 8:42pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/7 "2021-11-25T20:42:23Z")

</div>

Then you might have got the first and only page

What game ID are you trying?

---

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:42pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/8 "2021-11-25T20:42:38Z")

</div>

Fortnite

---

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:42pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/9 "2021-11-25T20:42:57Z")

</div>

In German language!

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 25, 2021, 8:44pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/10 "2021-11-25T20:44:33Z")

</div>

An example from the TwitchCLI

```auto
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;
```

---

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:45pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/11 "2021-11-25T20:45:37Z")

</div>

So in your descs is no cursor, written!

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 25, 2021, 8:46pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/12 "2021-11-25T20:46:29Z")

</div>

> [@tracepaladinxxl](#):
>
> So in your descs is no cursor, written!

Not sure what you mean

---

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:47pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/13 "2021-11-25T20:47:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [November 25, 2021, 8:48pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/14 "2021-11-25T20:48:04Z")

</div>

Still not sure what you mean.

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

---

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:48pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/15 "2021-11-25T20:48:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tracepaladinxxl](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tracepaladinxxl](https://discuss.dev.twitch.com/u/tracepaladinxxl)\
**Post date:** [November 25, 2021, 8:49pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/16 "2021-11-25T20:49:03Z")

</div>

Thanks solved it now!

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [December 25, 2021, 8:49pm UTC](https://discuss.dev.twitch.com/t/twitch-api-after-and-pagination/34975/17 "2021-12-25T20:49:27Z")

</div>

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