Site guides
Getting YouTube data: the Data API, quotas, and what not to scrape
Use the YouTube Data API v3 for public metadata, understand quota costs and OAuth scopes, and avoid downloading or scraping content the terms do not permit.
YouTube data is available through the YouTube Data API v3 for public metadata such as channels, videos, playlists, and comments. The API has quotas, OAuth scopes, and terms that govern storage and display. Scraping the website is not a substitute for the API, and downloading videos is a separate copyright question.
This page is research material, not legal advice. YouTube’s terms and your jurisdiction govern your use.
What the Data API covers
The API exposes resources such as:
channels: title, description, statistics, uploads playlist;videos: title, description, statistics, duration, thumbnails;playlistsandplaylistItems;search: a search result list (quota-expensive);commentThreadsandcomments;captions(where available and permitted).
Each resource has a part parameter. Request only the parts you need; the quota cost depends on the endpoint and parts.
Quotas
The API uses a daily quota in units. A read costs a small number of units; a search can cost 100. The default quota is limited, and quota increases require a request to Google. Check the current quota costs in the documentation; they are not static.
Practical consequences:
- Cache responses; do not call
searchfor every page. - Use
videos.listwith a batch of IDs instead of one call per video. - Store the
nextPageTokenand resume pagination. - Monitor quota usage; a runaway loop can exhaust the day’s quota in minutes.
Authentication
- API key: for public data. Send it as
key=...over HTTPS. - OAuth 2.0: for private data or actions on a user’s behalf. Use the narrowest scopes.
An API key is not a secret in the same sense as a password, but it is still a credential. Restrict it by API, HTTP referrer, or IP where the console allows it. Do not embed a key in a public client if the terms or the console restrictions prohibit it.
A request shape
GET https://www.googleapis.com/youtube/v3/videos
?part=snippet,statistics,contentDetails
&id=VIDEO_ID_1,VIDEO_ID_2
&key=YOUR_API_KEY
The response is JSON. Validate that items is present and that each item has the fields you expect. A quota error (403 with quotaExceeded) is not a transient failure; do not retry it in a loop.
This example is a documented request shape, not a run against a live key. The API reference lists the exact parameters and quota costs.
What not to do
- Do not download videos unless you have the rights and the terms permit it. YouTube’s terms prohibit downloading except where the service provides a download feature.
- Do not scrape the watch page to bypass API quotas or access restrictions.
- Do not collect personal data from comments or profiles at scale without a lawful basis.
- Do not bypass age gates, region blocks, or login walls.
- Do not rehost thumbnails or video content outside the terms.
Storage and display rules
The YouTube API Services Terms govern how you store and display API data. They include attribution, deletion, and refresh obligations. Read the current terms before building a public product on the data. A local research dataset has different obligations from a public dashboard.
A safe pipeline
- Resolve channel/video IDs through the API.
- Batch
videos.listcalls by ID. - Cache metadata with a timestamp.
- Paginate comments with
pageToken; stop at the documented limit. - Store only the fields you need.
- Delete or refresh per the terms.
- Monitor quota and error rates.
Legal notes
- Contract: the API Services Terms and YouTube Terms govern the use.
- Copyright: videos, thumbnails, and music are protected. The API does not grant a download or reuse licence.
- Personal data: commenters and channel owners may be identifiable. Minimise and set retention.
- Database rights: a large metadata database may attract database rights in the EU/UK.
The sessions and APIs lesson covers the auth boundary, and the terms guide covers the contract layer.