How do I generate the cursor pagination in axios

I am performing the query to get data from the helix api but I need to use the cursor with the migration and I can only perform the first query.

Is it necessary to make a loop to make use of the cursor? Could you provide me with a code using the cursor to see multiple pagination.

I’m still on kraken until I understand how to make cursor queries work on multiple pages, how long will I be available to use the kraken API?

You do not generate the cursor

The cursor is returned on the request you just made.

So, for example, you make a call to Get Streams

Which in the example returns

GET https://api.twitch.tv/helix/streams
  "pagination": {
    "cursor": "eyJiIjp7IkN1cnNvciI6ImV5SnpJam8zT0RNMk5TNDBORFF4TlRjMU1UY3hOU3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqb3hOVGs0TkM0MU56RXhNekExTVRZNU1ESXNJbVFpT21aaGJITmxMQ0owSWpwMGNuVmxmUT09In19"
  }

So to get the next page you then call

https://api.twitch.tv/helix/streams?after=eyJiIjp7IkN1cnNvciI6ImV5SnpJam8zT0RNMk5TNDBORFF4TlRjMU1UY3hOU3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In0sImEiOnsiQ3Vyc29yIjoiZXlKeklqb3hOVGs0TkM0MU56RXhNekExTVRZNU1ESXNJbVFpT21aaGJITmxMQ0owSWpwMGNuVmxmUT09In19

February 28th 7PM UTC

Yes you get a page of data. If it has a cursor you know you have another page to load

After making an axios call, extract the cursor and call the API again.

I manage to do the query and get the data from the stream in the case of your example and I get the cursor, the problem is that from there I don’t know how I can work with the cursor to get new paginations

    {

      id: '44820029260',

      user_id: '34711476',

      user_login: 'jesusavgn',

      user_name: 'JesusAVGN',

      game_id: '515214',

      game_name: 'Politics',

      type: 'live',

      title: '!", ' !", https://t.me/jesusavgntwitch',

      viewer_count: 23246,

      started_at: '2022-02-26T19:32:50Z',

      language: 'ru',

      thumbnail_url: 'https://static-cdn.jtvnw.net/previews-ttv/live_user_jesusavgn-{width}x{height}.jpg',

      tag_ids: [Array],

      is_mature: false

    }

  ],

  pagination: {

    cursor: 'eyJiIjp7IkN1cnNvciI6ImV5SnpJam95TkRJM05qRXVORFExTnpRMk5EWTJPRGNzSW1RaU9tWmhiSE5sTENKMElqcDBjblZsZlE9PSJ9LCJhIjp7IkN1cnNvciI6ImV5SnpJam95TXpJME5pNDRNRFUxTkRBeU16QTJNU3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In19'

  }

}
axios.get(`https://api.twitch.tv/helix/streams/?first=20&after=${cursor}`,options);
cursor = get.data.pagination.cursor;
eyJiIjp7IkN1cnNvciI6ImV5SnpJam95TXpVeE1qQXVORFExTnpRMk5EWTJPRGNzSW1RaU9tWmhiSE5sTENKMElqcDBjblZsZlE9PSJ9LCJhIjp7IkN1cnNvciI6ImV5SnpJam95TXpjMk9TNHlOekV6TWpBeU16SXdPQ3dpWkNJNlptRnNjMlVzSW5RaU9uUnlkV1Y5In19

I’m trying to save the cursor value and use it in the following query but I’m not doing it right. If you can provide me with a code that is making use of the cursor and making the query so I can see how it is done, I would appreciate it.

I only manage to make it functional by manually making the call

Here is an example that users vanilla JS Fetch

So more or less I have the code what is complicated for me is to make the loop and I do not understand much that code calls the function again to get the cursor but I do not fully understand

This sounds like a “I don’t know javascript” problem than an API problem.

I don’t know what you code does in order to debug your code.

So all I can do is point you to the example of how I do it.

I have already seen the problem, it was not interpreting the cursor variable correctly. I was only seeing the preview of your code and I didn’t know how it was working.

Query constraints increased in helix?

I’m not sure what you are asking here.

To paginate an endpoint you load page 1
Which returns the cursor for page 2

You cannot jump straight to page 4.