-
Related to #682 and many others, is it possible to poll the YT data API for the remaining quota? If not could the app keep a rough track of API calls and warn when getting close to the limit? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I've looked into this extensively, and the answer is "kind of", but it is incredibly convoluted. For some reason there is no "how much quota left" query, nor is there a "how much quota have I used" query. The only way it can be done is using another API, the google "cloud monitoring" API:
Though even with that, it basically requires you to set up a whole custom query using "MQL" which is an entire language just for report queries. I was sort of able to get it to create a chart that shows when you kinda go over the limit, but it's not even exact. I'm pretty sure it works by summing up every minute's worth of API usage over a 24 hour period. I haven't even really figured out how to do a text based query. I essentially gave up on it, but I might look more into it again at some point. Also as a reminder to myself and anyone else who stumbles upon this, "Service Usage" is not what you're looking for. It only gives you the quota limit, not the amount you've actually used, as described by the blue 'starred' note here: https://cloud.google.com/service-usage/docs/manage-quota
The note then points to this which is part of the cloud monitoring API, but requires all the convoluted stuff I described above: https://cloud.google.com/monitoring/api/resources#tag_consumer_quota Also I'm going to rename the title of this thread so it might turn on up google for some people, so they can save the hours it took me simply to find that blue starred note buried in the documentation. This was the best I was able to do, which was make this chart showing usage and the limit: Notice though how it seems to be more of a rolling average, which is not how the API actually resets quota. The quota resets all at once (at midnight PST I believe), so it should really only have instant dropoffs, and no "partial" dropoffs at any time. I think there might be ways to set a "static" time window instead of a rolling window, but I couldn't figure it out. |
Beta Was this translation helpful? Give feedback.
-
I think it's possible to approximately compute used quota. after script starts anew - check saved time (and compare with current time shifted to PST time), if more than 1 day passed, think that quota is reset and save used quota to zero. based on feedback (marking feature as experimental) - assumptions might be corrected and estimation will be closer to that which youtube thinks is user quota. |
Beta Was this translation helpful? Give feedback.
I've looked into this extensively, and the answer is "kind of", but it is incredibly convoluted. For some reason there is no "how much quota left" query, nor is there a "how much quota have I used" query.
The only way it can be done is using another API, the google "cloud monitoring" API:
Though even with that, it basically requires you to set up a whole custom query using "MQL" which is an entire language just for report queries. I was sort of able to get it to create a chart that shows when you kinda go over the limit…