Videos missing from a channel's video list
Clash Royale CLAN TAG#URR8PPP
Videos missing from a channel's video list
I'm trying to retrieve information about all the videos of a given YouTube channel.
Here is my first request:
GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=CHANNEL_ID&maxResults=50&type=video&key=YOUR_API_KEY
"kind": "youtube#searchListResponse",
"etag": ""XI7nbFXulYBIpL0ayR_gDh3eu1k/15j9AlxbMtzBhzffpA04ahJgv9g"",
"nextPageToken": "CDIQAA",
"regionCode": "FR",
"pageInfo":
"totalResults": 375,
"resultsPerPage": 50
,
"items": [
"... 50 items here ..."
]
As you can see, there is a total of 375 results. So, using the nextPageToken
, I search for the 50 next videos.
nextPageToken
GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=CHANNEL_ID&maxResults=50&pageToken=CDIQAA&type=video&key=YOUR_API_KEY
"kind": "youtube#searchListResponse",
"etag": ""XI7nbFXulYBIpL0ayR_gDh3eu1k/7mmGfmqsGmfP8OggZWZVefQ7z6Q"",
"nextPageToken": "CGQQAA",
"prevPageToken": "CDIQAQ",
"regionCode": "FR",
"pageInfo":
"totalResults": 375,
"resultsPerPage": 50
,
"items": [
"... 28 more items here ..."
]
There are only 28 items in this response. Furthermore, if I query for the next page:
GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=CHANNEL_ID&maxResults=50&pageToken=CGQQAA&type=video&key=YOUR_API_KEY
This time, there are no items at all.
"kind": "youtube#searchListResponse",
"etag": ""XI7nbFXulYBIpL0ayR_gDh3eu1k/XKJQFk8Z_J6XraQ0mVCRtVWnSYc"",
"nextPageToken": "CJYBEAA",
"prevPageToken": "CGQQAQ",
"regionCode": "FR",
"pageInfo":
"totalResults": 375,
"resultsPerPage": 50
,
"items": [
]
What causes this behavior? Is there something wrong with my request?
channelId: "UCsGakFIbOsj-fgPFLf1QlQA"
Here is the channel ID I'm trying to query:
UCRVDPcrF_LTJo8u0bkzUL9A
, and I've been authorizing requests with an API key, although I suppose it shouldn't make a difference.– Richard-Degenne
Aug 14 at 16:43
UCRVDPcrF_LTJo8u0bkzUL9A
just to provide more information I confirm that in the reported channel:
UCRVDPcrF_LTJo8u0bkzUL9A
let me reproduce the problem while this problem does not seem to exist for same other channels such as UCsGakFIbOsj-fgPFLf1QlQA
– Franco Rondini
Aug 17 at 11:25
UCRVDPcrF_LTJo8u0bkzUL9A
UCsGakFIbOsj-fgPFLf1QlQA
1 Answer
1
In YouTube Data API v3
you should:
YouTube Data API v3
GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UCRVDPcrF_LTJo8u0bkzUL9A&key=YOUR_API_KEY
GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UCRVDPcrF_LTJo8u0bkzUL9A&key=YOUR_API_KEY
json
"kind": "youtube#channel",
"etag": ""XI7nbFXulYBIpL0ayR_gDh3eu1k/8HOHPc1ZO5cOiePp8nFHwKA99HM"",
"id": "UCRVDPcrF_LTJo8u0bkzUL9A",
"contentDetails": {
"relatedPlaylists": {
"uploads": "UURVDPcrF_LTJo8u0bkzUL9A",
"watchHistory": "HL",
"watchLater": "WL"
The uploads playlist for your channell is UURVDPcrF_LTJo8u0bkzUL9A
json
"kind": "youtube#channel",
"etag": ""XI7nbFXulYBIpL0ayR_gDh3eu1k/8HOHPc1ZO5cOiePp8nFHwKA99HM"",
"id": "UCRVDPcrF_LTJo8u0bkzUL9A",
"contentDetails": {
"relatedPlaylists": {
"uploads": "UURVDPcrF_LTJo8u0bkzUL9A",
"watchHistory": "HL",
"watchLater": "WL"
UURVDPcrF_LTJo8u0bkzUL9A
playlistId
uploads
GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&pageToken=WHEN_YOU_HAVE_A_PAGETOKEN_PUT_IT_HERE&playlistId=UURVDPcrF_LTJo8u0bkzUL9A&key=YOUR_API_KEY
GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&pageToken=WHEN_YOU_HAVE_A_PAGETOKEN_PUT_IT_HERE&playlistId=UURVDPcrF_LTJo8u0bkzUL9A&key=YOUR_API_KEY
Search: list
as documented here: https://developers.google.com/youtube/v3/docs/search/list about search result property pageInfo.totalResults
I quote literally:
pageInfo.totalResults
The total number of results in the result set.Please note that the
value is an approximation and may not represent an exact value. In
addition, the maximum value is 1,000,000.
You should not use this value to create pagination links. Instead, use
the nextPageToken and prevPageToken property values to determine
whether to show pagination links.
also, by some investigations I did testing it seems that the videos that are "missing" in the result, as you indicated, however, appear in the results when the optional parameter q
is explicitly specified in the request, obviously only if the filter value specified can be satisfied by the data of the video in question.
q
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
In order to reproduce the problem it could be useful to know CHANNEL_ID value that has caused this issue in your tests. I just tried through the apis-explorer page and with the
channelId: "UCsGakFIbOsj-fgPFLf1QlQA"
without any problem. Also in my case I've authorized requests using OAuth 2.0.– Franco Rondini
Aug 14 at 16:01