2

I would like to be able to query for a YouTube video ID using the YouTube Data API. My application only requires the ID (and no other metadata) from the video. According to the documentation:

A simple read operation that only retrieves the ID of each returned resource has a cost of approximately 1 unit.

So I should only be charged 1 unit for a query if the ID is exclusively returned. Using the following query, I am charged 100 units towards my quota (which I understand is the Search API quota cost)..why is there a discrepancy in the docs, what am I missing?

const response = await youtube.search.list({
    "part": "id",
    "maxResults": 1,
    "q": "san holo honest",
    "fields": "items/id/videoId"
});

The API returns:

"data": {
      "items": [
        {
          "id": {
            "videoId": "CHH48NKPAkk"
          }
        }
      ]
    },

I guess I am a little confused in the difference between what the Overview page claims is a cost of 1 Unit compared to what the Search page claims is a cost of 100 Units.

I found a StackOverflow post claiming that they were able to reduce the quota count for a simple operation using a similar method to return videos IDs: Reaching quota too soon on Youtube Data API V3 - optimizing search.list

However, I can't seem to replicate. Is there a better way to query for just the video ID so that I don't incur such a large quota fee?

Jordan Lewallen
  • 1,681
  • 19
  • 54
  • what you say is ... a read costs 1 unit, a search costs 100 units ... you perform a search and are surprised it costs you 100 units? – Jaromanda X Feb 04 '20 at 03:22
  • @JaromandaX my understanding was that reading from a database and searching a database were synonymous, which still doesn't answer why the linked SO question was able to reduce their quota cost for a search – Jordan Lewallen Feb 04 '20 at 03:23
  • Sorry, I read what you wrote, not the documentation – Jaromanda X Feb 04 '20 at 03:27
  • @JaromandaX correct, what I wrote is a reflection of what I read in the documentation – Jordan Lewallen Feb 04 '20 at 03:28
  • Is the code in [this post](https://stackoverflow.com/questions/64709715/youtube-data-api-v3-maximum-search-result-for-channel-id) not working OR is the code working but does not reduce the quota? I am reading the [documentation](https://developers.google.com/youtube/v3/getting-started#quota) in the same way as you do. Reading request (=Getting a list) = 1 unit cost per request. I am also faced with exceeding my quota with a reading request that should cost a couple of 100 units when I have 10'000 units available per day. This is the only request I placed in a day. – Simone Apr 26 '22 at 08:14
  • In reference to your fee worry, there seems to be no monetary costs attached to [quota](https://support.google.com/youtube/thread/1382733?hl=en). The [Google documentation](https://developers.google.com/youtube/v3/getting-started#quota) is not clear about this. – Simone Apr 26 '22 at 08:17

0 Answers0