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 redacted' \
--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": "redacted",
  "nextPageToken": "redacted",
  "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 redacted' \
--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 redacted' \
--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": "redacted",
  "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?

0

1 Answer 1

0
  • Utilise the search.list endpoint. Make sure to specify parameters like publishedAfter, publishedBefore, and maxResults for your date range and other preferences.

  • GET https://www.googleapis.com/youtube/v3/search?part=snippet&publishedAfter=YYYY-MM-DDT00:00:00Z&publishedBefore=YYYY-MM-DDT23:59:59Z&type=video&key=YOUR_API_KEY
    
  • The YouTube Data API has quota limitations. Regularly check your API usage in the Google Cloud Console to manage your quota effectively and avoid errors due to overuse.
    
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.