# \[Helix\] Clips endpoint not working with 'before' argument (400 invalid cursor)

**URL:** <https://discuss.dev.twitch.com/t/helix-clips-endpoint-not-working-with-before-argument-400-invalid-cursor/38531>\
**Category:** Migration\
**Created:** [May 23, 2022, 4:46pm UTC](https://discuss.dev.twitch.com/t/helix-clips-endpoint-not-working-with-before-argument-400-invalid-cursor/38531 "2022-05-23T16:46:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawel.jelonek.krakow](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@pawel.jelonek.krakow](https://discuss.dev.twitch.com/u/pawel.jelonek.krakow)\
**Post date:** [May 23, 2022, 4:46pm UTC](https://discuss.dev.twitch.com/t/helix-clips-endpoint-not-working-with-before-argument-400-invalid-cursor/38531/1 "2022-05-23T16:46:33Z")

</div>

Hi,

I can see that using before argument with clips endpoint constantly ends with:

```auto
{
    "error": "Bad Request",
    "status": 400,
    "message": "invalid cursor"
}

```

Here is the sample chain for requests I can make to reproduce this issue:

> [https://api.twitch.tv/helix/clips?first=24&game\_id=509658](https://api.twitch.tv/helix/clips?first=24&game_id=509658)

> [https://api.twitch.tv/helix/clips?first=24&game\_id=509658&after=eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1qUT0ifX0](https://api.twitch.tv/helix/clips?first=24&game_id=509658&after=eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1qUT0ifX0)

> [https://api.twitch.tv/helix/clips?first=24&game\_id=509658&before=eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik5EZz0ifX0](https://api.twitch.tv/helix/clips?first=24&game_id=509658&before=eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik5EZz0ifX0)

the last cursor was given in the prior request.

This seems like a basic use case.

Can someone explain me what I am doing wrong here?

Regards

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [May 23, 2022, 7:12pm UTC](https://discuss.dev.twitch.com/t/helix-clips-endpoint-not-working-with-before-argument-400-invalid-cursor/38531/2 "2022-05-23T19:12:33Z")

</div>

Why are you changing from `after` on your 2nd request, to `before` on your 3rd? Using `before` is only for paginating backwards through previous pages of results you’ve already gone past.

You should keep using `after` and keep replacing the value with the cursor in your last request.

---

<div class="post-metadata">

**Author:** ![pawel.jelonek.krakow](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@pawel.jelonek.krakow](https://discuss.dev.twitch.com/u/pawel.jelonek.krakow)\
**Post date:** [May 23, 2022, 7:41pm UTC](https://discuss.dev.twitch.com/t/helix-clips-endpoint-not-working-with-before-argument-400-invalid-cursor/38531/3 "2022-05-23T19:41:06Z")

</div>

This is exactly what I wanted to do.

Maybe I should clarify this, this is my basic scenario:

- I call get clips endpoint to get first page of result for specific game\_id
- I use pagination cursor with after argument to get second page of results
- I use pagination cursor with before argument to get again first page of results

Request made:  
RQ1:

> [https://api.twitch.tv/helix/clips?game\_id=509658](https://api.twitch.tv/helix/clips?game_id=509658)

RS1:

```auto
{
        data: [....],
        pagination: {
              cursor: eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1qQT0ifX0
        }
}

```

RQ2:

> [https://api.twitch.tv/helix/clips?game\_id=509658&after=eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1qQT0ifX0](https://api.twitch.tv/helix/clips?game_id=509658&after=eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1qQT0ifX0)

RS2:

```auto
{
        data: [....],
        pagination: {
              cursor: eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1qQT0ifX0
        }
}

```

RQ3:

> [https://api.twitch.tv/helix/clips?game\_id=509658&before=eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1qQT0ifX0](https://api.twitch.tv/helix/clips?game_id=509658&before=eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6Ik1qQT0ifX0)

RS3:

```auto
{
    "error": "Bad Request",
    "status": 400,
    "message": "invalid cursor"
}

```

---

<div class="post-metadata">

**Author:** ![pawel.jelonek.krakow](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@pawel.jelonek.krakow](https://discuss.dev.twitch.com/u/pawel.jelonek.krakow)\
**Post date:** [May 23, 2022, 7:42pm UTC](https://discuss.dev.twitch.com/t/helix-clips-endpoint-not-working-with-before-argument-400-invalid-cursor/38531/4 "2022-05-23T19:42:13Z")

</div>

In my undestanding if we have cursor we can navigate backwards and forwards around this cursor. If no, what is the usage of before argument?

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [May 23, 2022, 7:43pm UTC](https://discuss.dev.twitch.com/t/helix-clips-endpoint-not-working-with-before-argument-400-invalid-cursor/38531/5 "2022-05-23T19:43:17Z")

</div>

Not all endpoints properly support `before` cursors. I haven’t tested with Get Clips, but it could simply be one of the endpoints that doesn’t allow using `before` and the documentation could incorrectly list it as a param.

Also, if you want to get pages 1, 2, and 1 again, rather than using before you should just make the request without any cursor and it will give you page 1. Generally for most use cases, such as polling an endpoint, it’s common to just get page 1, keep using `after` to get as many pages as you need, then the next time you need the data you start from scratch and page through again.

---

<div class="post-metadata">

**Author:** ![pawel.jelonek.krakow](https://avatars.discourse-cdn.com/v4/letter/p/ebca7d/32.png) [@pawel.jelonek.krakow](https://discuss.dev.twitch.com/u/pawel.jelonek.krakow)\
**Post date:** [May 23, 2022, 7:48pm UTC](https://discuss.dev.twitch.com/t/helix-clips-endpoint-not-working-with-before-argument-400-invalid-cursor/38531/6 "2022-05-23T19:48:53Z")

</div>

It would be good to add a note in documentation as it is right now a bit confusing. This issue forces to save specific cursors for each page as it is inconvienient if we are on the page number 8 and can’t actually easily go back to page 7.

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [May 23, 2022, 7:56pm UTC](https://discuss.dev.twitch.com/t/helix-clips-endpoint-not-working-with-before-argument-400-invalid-cursor/38531/7 "2022-05-23T19:56:03Z")

</div>

You shouldn’t be saving cursors and reusing them, otherwise you would get inconsistent results as they’re not designed to permanently represent a place in the results but rather something that’s relevant at the point in time you got the cursor.
