DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
API tutorial

How to Scrape YouTube Data: A Step-by-Step Guide to the Official API (2026)

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Short answer: do not scrape YouTube pages or call undocumented endpoints. YouTube’s Developer Policies prohibit directly or indirectly scraping its applications or obtaining scraped YouTube data. For legitimate collection, create a Google developer project, enable YouTube Data API v3, authenticate each operation correctly, request only the fields you need, and budget the method-specific quota before running a job.

This guide uses “scrape” because that is the wording many developers search for, but the compliant workflow is API retrieval. It covers video, channel and playlist metadata, quota planning, caption-track permissions, pagination, runnable examples and documented failure modes.

1. Decide what data and permission your project actually needs

Write down the resource, fields and owner relationship before writing code. The answer determines the endpoint, credential type and whether YouTube permits the operation.

Public-resource metadata

The Data API exposes documented resources such as videos, channels and playlists. Public metadata can include titles, descriptions, publication dates, channel identifiers, thumbnails, statistics and playlist relationships, subject to the fields and access rules of the selected method. An API key may be sufficient for operations that allow unauthenticated public reads; it does not grant permission to private data or to actions reserved for an account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Data authorized by a channel owner

Use OAuth 2.0 when an operation acts on a user’s account or requires that user’s consent. Store refresh tokens securely, request the narrowest scope that meets the job, and explain to the account owner what your application will do. Never treat an API key as a substitute for authorization.

Caption text

Caption tracks are a separate case. Listing tracks returns track resources and metadata, not the words in the captions. Downloading a track requires edit permission for that video, so the documented download method is not a general caption downloader for arbitrary public videos.

2. Create a Google project and enable YouTube Data API v3

  1. Open the Google Cloud Console and create or select a project dedicated to your application.
  2. In APIs & Services → Library, search for YouTube Data API v3 and click Enable.
  3. Under APIs & Services → Credentials, create an API key for methods that document key-based access. Restrict the key by API and, where practical, by server IP or application.
  4. For user-authorized operations, create an OAuth client appropriate to your application (web, desktop or another supported type), configure the consent screen and request the required YouTube scope.
  5. Record the project’s quota in APIs & Services → YouTube Data API v3 → Quotas. Defaults and policy requirements can change, so verify them immediately before deployment.

The official API overview is the authoritative starting point for authentication and resource methods: developers.google.com/youtube/v3.

3. Choose a documented method and minimize the response

Search, then retrieve resources

search.list finds videos, channels or playlists matching a query, but it is not a substitute for a database of every YouTube page. Once you have stable video or channel IDs, use the corresponding resource method (for example, videos.list or channels.list) to retrieve details. A search result can identify a resource; it does not automatically include every field exposed by that resource.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Request only the parts you use

Methods use a part parameter to select groups of fields. Requesting only the required parts reduces transfer, parsing and storage. For example, a reporting job might need snippet,statistics, while a thumbnail-only job should not request player or content details. Check the current reference for valid parts and parameters for your chosen method.

Page through results

List methods commonly return a nextPageToken. Save the token, request the next page and stop when the response has no next token. Persist the last successful token or resource ID so a retry does not restart an expensive collection. Respect any maxResults limit documented for that method.

Example: retrieve videos by ID with cURL

curl -G "https://www.googleapis.com/youtube/v3/videos" 
  --data-urlencode "part=snippet,statistics" 
  --data-urlencode "id=VIDEO_ID_1,VIDEO_ID_2" 
  --data-urlencode "key=YOUR_API_KEY"

Replace the IDs and key with your values. Treat the response as versioned API data: validate missing fields, preserve the resource ID, and record the retrieval time.

Example: search and paginate in Python

import os
import requests

API_KEY = os.environ["YOUTUBE_API_KEY"]
url = "https://www.googleapis.com/youtube/v3/search"
params = {
    "part": "snippet",
    "q": "renewable energy",
    "type": "video",
    "maxResults": 50,
    "key": API_KEY,
}

while True:
    response = requests.get(url, params=params, timeout=30)
    response.raise_for_status()
    payload = response.json()
    for item in payload.get("items", []):
        print(item["id"].get("videoId"), item["snippet"].get("title"))
    token = payload.get("nextPageToken")
    if not token:
        break
    params["pageToken"] = token

This example deliberately collects metadata only. Add backoff for transient HTTP failures, cap the number of pages, and persist IDs as you process them.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Example: the same request in Node.js

const params = new URLSearchParams({
  part: 'snippet',
  q: 'renewable energy',
  type: 'video',
  maxResults: '50',
  key: process.env.YOUTUBE_API_KEY
});

const res = await fetch(`https://www.googleapis.com/youtube/v3/search?${params}`);
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
const data = await res.json();
for (const item of data.items ?? []) {
  console.log(item.id.videoId, item.snippet.title);
}

4. Estimate quota before collecting

YouTube charges quota per method, not per byte returned. The current API overview lists these default allocations (YouTube says defaults can change):

Operation Documented default or cost What to verify
search.list 100 calls per day in the overview; each search query costs 1 unit Current project quota and method limits
videos.insert 100 calls per day in the overview Whether your write workflow and account are eligible
Other endpoints 10,000 units per day default allocation in the overview Current allocation; defaults are subject to change
Typical list read Usually 1 unit Exact method’s current quota table
Typical write Usually 50 units Exact write method’s current quota table
captions.list 50 units per call Current captions reference
captions.download 200 units per call Permission and current captions reference

Use a worksheet rather than a vague “videos per day” estimate:

  1. Count calls for each method, including pagination and retries.
  2. Multiply each count by that method’s current unit cost.
  3. Add the methods together and compare the total with the project’s quota console.
  4. Separately check the documented call allowance for search.list and any write method.
  5. Run a small pilot, record actual responses and tokens, then schedule within the measured budget.

For example, 40 search calls at 1 unit and 300 video-detail reads at 1 unit would be 340 units under those documented prices, before retries. That arithmetic is not a performance guarantee; the current quota table controls your project.

5. Captions: listing is not downloading

List available tracks

captions.list returns caption-track resources associated with a video. It costs 50 quota units and does not return caption text. The response can identify a track, its language and other metadata that the reference documents.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Download a track you are allowed to edit

captions.download returns the caption file and costs 200 units. The authenticated user must have permission to edit that video. Supported output can include SRT and VTT; the optional tlang parameter requests machine translation. Because of the edit-permission requirement, this endpoint is unsuitable for downloading captions from arbitrary public videos that your account does not control.

curl -L -G "https://www.googleapis.com/youtube/v3/captions/CAPTION_TRACK_ID" 
  --data-urlencode "tfmt=vtt" 
  --data-urlencode "key=YOUR_API_KEY" 
  -H "Authorization: Bearer OAUTH_ACCESS_TOKEN" 
  -o captions.vtt

Use the authentication flow and parameters documented for the current captions reference. Do not assume that possessing a track ID bypasses authorization.

6. What YouTube prohibits when people say “scraping”

YouTube’s API Services Developer Policies state: “You must not use undocumented APIs without express permission.” The policies also prohibit directly or indirectly scraping YouTube applications or obtaining scraped YouTube data. Do not copy HTML pages, reverse-engineer private endpoints, rotate identities to evade controls, defeat CAPTCHAs, or build a collector around an unofficial client.

YouTube further prohibits downloading or storing copies of audiovisual content through API use without prior written approval. Metadata access does not grant a license to archive videos, audio or streams. Design storage around the documented resource fields you need, honor deletion and privacy requirements, and review the API terms for your use case.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When you need more quota

YouTube says projects seeking additional quota must complete an API Compliance Audit. Any approved extension is limited to the approved use case; a changed use case requires notifying YouTube and receiving approval. Do not plan a quota increase as a way to justify an otherwise prohibited collection method. See the current quota and compliance guidance.

7. Troubleshoot documented failures

400 invalid request

Check required parameters, resource IDs, the selected part, and whether the method accepts an API key or requires OAuth. Log the response body, not only the HTTP status.

401 unauthenticated

For OAuth calls, refresh or replace the access token and verify that the token was issued for the intended project and scope. Keep API keys out of client-side source and public logs.

403 forbidden or quota exceeded

A 403 can mean insufficient authorization, a quota limit, or a policy-restricted operation. Inspect the error reason, confirm the authenticated account owns or can edit the resource when required, and check the project’s quota console. Do not respond by trying an undocumented endpoint.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

404 caption track not found

For captions, a 404 can indicate an unknown or mismatched track ID. Obtain the track from captions.list for the same video, verify the ID and retry only after correcting the request.

429 or transient 5xx responses

Use bounded exponential backoff with jitter, honor retry headers when present, and make writes idempotent where possible. Persist completed IDs so a retry cannot silently duplicate work.

Empty or incomplete results

Check filters, language and privacy state, pagination tokens and the selected resource parts. A successful response can legitimately omit fields that are unavailable or not requested.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

8. Reliability, privacy and operating practices

  • Keep a request log containing method, parameters without secrets, response status, quota estimate and timestamp.
  • Cache stable metadata according to your retention policy, but do not retain data longer than your legal, contractual or product requirements allow.
  • Validate IDs and normalize timestamps before loading a warehouse.
  • Separate discovery (search.list) from enrichment (videos.list, channels.list) so you can rerun one stage without repeating all calls.
  • Use a queue with rate limits and a dead-letter path for records that repeatedly fail.
  • Review YouTube’s terms and the privacy basis for your collection, especially when storing user-related information.

Or skip the browser setup

If your actual requirement is a visual record of a YouTube page—not API metadata—use a documented screenshot service rather than building a browser scraper. ScreenshotNeo accepts one GET request and returns PNG, JPEG, WebP or PDF. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks, blank pages, timeouts, failed loads and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://www.youtube.com/watch?v=VIDEO_ID -o shot.webp

See the ScreenshotNeo API documentation for all 63 options, including full-page lazy-image loading, CSS-selector capture, device presets, retina scale, PDF controls, custom JavaScript and CSS, click and wait actions, request blocking, headers, cookies, geolocation, transparent backgrounds, resizing, TTL caching, signed image links, async webhooks and bulk capture for up to 100 URLs per call. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.

Frequently Asked Questions

Can an API key retrieve private YouTube videos?

No. An API key identifies a project for methods that permit key-based access; it does not authorize private resources or account actions.

Does captions.list return the subtitle text?

No. It returns caption-track resources and metadata. Caption text comes from captions.download, which requires edit permission for the video.

Can I increase quota for a new scraping project?

YouTube’s documented process requires an API Compliance Audit, and any approved increase is restricted to the approved use case.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is a screenshot of a YouTube page the same as collecting YouTube API data?

No. A screenshot is a visual rendering, while the Data API returns structured resources. Your use must still comply with YouTube’s terms and applicable law.

The Bottom Line

For compliant YouTube data collection, use YouTube Data API v3, OAuth where the operation requires user authority, method-specific quota accounting and the documented caption permissions. “Scraping” pages or undocumented endpoints is prohibited by YouTube’s Developer Policies.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.