0

When the following request is made, it is not giving me the complete data set rather limiting to 10 pages and 500 records:

https://www.googleapis.com/youtube/v3/search?maxResults=50&part=id&type=video&channelId=UCgdHSFcXvkN6O3NXvif0-pA&pageToken=CPQDEAA

It is only returning about 500 records out of 2126.

2021-04-05T11:18:13.330-04:00    3    [1|Q-Id]    [HTTP|Res: 20]
[HTTP Headers]
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Vary: Origin
Vary: X-Origin
Vary: Referer
Content-Encoding: gzip
Date: Mon, 05 Apr 2021 15:18:13 GMT
Server: scaffolding on HTTPServer2
Cache-Control: private
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Alt-Svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Transfer-Encoding: chunked
2021-04-05T11:18:13.330-04:00    3    [1|Q-Id]    [HTTP|Res: 20] {
  "kind": "youtube#searchListResponse",
  "etag": "5snf-LkAO-ildQnoSYiawBtMrQI",
  "nextPageToken": "CKYEEAA",
  "prevPageToken": "CPQDEAE",
  "regionCode": "US",
  "pageInfo": {
    "totalResults": 2126,
    "resultsPerPage": 4
  },

Getting the same behavior when I try the API here:

https://developers.google.com/youtube/v3/docs/search/list.

stvar
  • 6,551
  • 2
  • 13
  • 28
vsani
  • 1
  • 2
  • 2
    What is the question ? – kebs Apr 23 '21 at 13:22
  • there is the `nextPageToken`, use it to fetch additional pages, if you need more items – holex Apr 23 '21 at 13:29
  • The pagination is set to 50, so a page will give me 50 videos and the nextPageToken after 10 iterations is being set to Blank. So I get only like 500 videos when I know we have a lot more. – vsani Apr 23 '21 at 14:09

2 Answers2

0

The behavior you experienced is valid as per the following official specification of the request parameter channelId of the Search.list API endpoint:

channelId (string)

The channelId parameter indicates that the API response should only contain resources created by the channel.

Note: Search results are constrained to a maximum of 500 videos if your request specifies a value for the channelId parameter and sets the type parameter value to video, but it does not also set one of the forContentOwner, forDeveloper, or forMine filters.

Consequently, by paginating the result set of your API call

https://www.googleapis.com/youtube/v3/search?maxResults=50&part=id&type=video&channelId=UCgdHSFcXvkN6O3NXvif0-pA

you'll be getting no more than 500 video items.

stvar
  • 6,551
  • 2
  • 13
  • 28
0

As said by @stvar search isn't the YouTube Data API v3 endpoint which meets your needs. Indeed you are trying to list videos from a given YouTube channel and by trying to do I would recommend you to follow this approach. The approach consists in getting the uploads auto-created playlist id of the YouTube channel by using Channels: list with contentDetails in part and then use PlaylistItems: list to retrieve all public videos uploaded on this YouTube channel.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33