Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Issues with YouTube Data API for Daily Video List Retrieval in Specified Date Ranges

$
0
0

We are using Google's YouTube Data API to pull videos from our YouTube channel.

Our expected outcome is to pull the list of videos from our channel once a day, but we encountered the following issues when calling the API:

If we only set forMine=true without setting publishedBefore/publishedAfter, a full pull will be performed, which consumes a large number of QPS quotas and leads to quotaExceeded:

  • Request Details:
curl --location --request GET 'https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&forMine=true&maxResults=50' \--header 'Authorization: Bearer ya29.a0AS3H6NwLRHWiD5_G0Ptko675cXWt1TIb0Wh7o7GW17Kz0hsWkOST-Wf-J6Phbej1hAdOxywKOjP42Tz0tAPdG-c_V8LlI9VEsCt-ge2uBh7fcrDYMvttHgBfyHsc1hFk6JrEmjq7VLoHVAv8cl0yZ2SSMCDbWNh4TlWx8qGOGwaCgYKAVkSARASFQHGX2MiPrStO7sEXB1T1KJLhm80Uw0177' \--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \--header 'Accept: */*' \--header 'Host: www.googleapis.com' \--header 'Connection: keep-alive'
  • Response Details:
{"kind": "youtube#searchListResponse","etag": "2FYLvuJ6yP5pDtViJJ9k9oAUEcY","nextPageToken": "KDIyUQFsZOH7yQeLV3XVYbtLegi6tYiw-iC9kQjeaT3Bhs5JasljMbBvVSIOfiBD53DDVN9oZOvE5LoXSNhkLrOTsE9a9VmgqmZzFk9cddGT4lSm-g","pageInfo": {"totalResults": 57,"resultsPerPage": 50  },"items": [    {…… #Skip detailed video specifics          }        },"channelTitle": "Qingquan Hou","liveBroadcastContent": "none","publishTime": "2025-07-15T03:39:33Z"      }    }  ]}

If we set the request condition as forMine=true along with publishedBefore, it results in an invalidSearchFilter error :

  • Request Details:
curl --location --request GET 'https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&forMine=true&maxResults=50&publishedAfter=2025-07-01T19:59:59Z' \--header 'Authorization: Bearer ya29.a0AS3H6NwLRHWiD5_G0Ptko675cXWt1TIb0Wh7o7GW17Kz0hsWkOST-Wf-J6Phbej1hAdOxywKOjP42Tz0tAPdG-c_V8LlI9VEsCt-ge2uBh7fcrDYMvttHgBfyHsc1hFk6JrEmjq7VLoHVAv8cl0yZ2SSMCDbWNh4TlWx8qGOGwaCgYKAVkSARASFQHGX2MiPrStO7sEXB1T1KJLhm80Uw0177' \--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \--header 'Accept: */*' \--header 'Host: www.googleapis.com' \--header 'Connection: keep-alive'
  • Response Details:
{"error": {"code": 400,"message": "Request contains an invalid argument.","errors": [      {"message": "Request contains an invalid argument.","domain": "global","reason": "badRequest"      }    ],"status": "INVALID_ARGUMENT"  }}

If we do not set forMine=true in the request condition, although adding publishedBefore does not cause an error, the returned value is 0:

  • Request Details:
curl --location --request GET 'https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=50&publishedAfter=2025-07-01T19:59:59Z' \--header 'Authorization: Bearer ya29.a0AS3H6NwLRHWiD5_G0Ptko675cXWt1TIb0Wh7o7GW17Kz0hsWkOST-Wf-J6Phbej1hAdOxywKOjP42Tz0tAPdG-c_V8LlI9VEsCt-ge2uBh7fcrDYMvttHgBfyHsc1hFk6JrEmjq7VLoHVAv8cl0yZ2SSMCDbWNh4TlWx8qGOGwaCgYKAVkSARASFQHGX2MiPrStO7sEXB1T1KJLhm80Uw0177' \--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \--header 'Accept: */*' \--header 'Host: www.googleapis.com' \--header 'Connection: keep-alive'
  • Response Details:
{"kind": "youtube#searchListResponse","etag": "jY03jGgN1g_xKk8RSHyjN_PoL8I","regionCode": "KR","pageInfo": {"totalResults": 0,"resultsPerPage": 0  },"items": []}

The API documentation we are using is: https://developers.google.com/youtube/v3/docs/search/list?apix_params=%7B%22part%22%3A%5B%22snippet%22%5D%2C%22channelId%22%3A%22UCBaxnqrfeeoxOxoMpPhqefA%22%2C%22maxResults%22%3A25%2C%22type%22%3A%5B%22video%22%5D%7D&hl=zh-cn

What can we do to achieve our goal of pulling videos within a specified date range?


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>