How to get multiple pages from Google YouTube API superchatevents

69 Views Asked by At

I'm trying to use the Google superchatevents API to get a list of superchats. However something seems to be wrong with the next page token. For example I can run:

curl \
  'https://youtube.googleapis.com/youtube/v3/superChatEvents?part=snippet&key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --compressed

This returns:

{
  "kind": "youtube#superChatEventListResponse",
  "etag": "...",
  "nextPageToken": "CLXB5qO25P4C",
  "pageInfo": {
    "totalResults": 8,
    "resultsPerPage": 5
  },
  "items": [

with 5 items in the array. So I then thought I needed to use the nextPageToken to get the next set (in this case the remaining 3) so I try:

curl \
  'https://youtube.googleapis.com/youtube/v3/superChatEvents?part=snippet&pageToken=CLXB5qO25P4C&key=[YOUR_API_KEY]' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --compressed

(Note the pageToken is set to the nextPageToken in the previous response)

But that returns:

{
  "kind": "youtube#superChatEventListResponse",
  "etag": "...",
  "nextPageToken": "CKbK0au35P4C",
  "pageInfo": {
    "totalResults": 0,
    "resultsPerPage": 0
  },
  "items": []
}

So it returns no results but has a different nextPageToken (if I use that token I then get the exact same response).

Obviously in this case I could set the maxResults to 8 and get all 8 but what happens when there are more than 50 which is the maximum you can set maxResults to? I've tried setting the max to 2 so that there would be multiple full pages but again I get the same behaviour.

0

There are 0 best solutions below