youtubesearch

Documentation

One API, CLI, and MCP server over the same four operations — search, metadata, transcripts, summaries. Everything below is copy-paste runnable against production.

// Quickstart

First call in under a minute

No signup needed for the first call — keyless requests serve search and already-cached content. This one returns the executive summary of a cached video:

1 — keyless call
curl -s "https://api-production-4a11e.up.railway.app/v1/videos/zjkBMFhNj_g/summary?sections=executive_summary"

To fetch fresh, uncached content, get a free API key — 1,000 credits a month, no card — and pass it as a bearer token:

2 — keyed call
curl -s "https://api-production-4a11e.up.railway.app/v1/videos/zjkBMFhNj_g/transcript?format=markdown&max_tokens=300" \
-H "Authorization: Bearer ys_live_YOUR_KEY"

replace ys_live_YOUR_KEY with your key

// Authentication

One header, three tiers

Keyed requests send Authorization: Bearer ys_live_… — nothing else. Requests without the header run on the keyless tier.

TierAccessRateCredits/month
keylesscached content only + search10 searches/hr, 60 reads/hr per IP
freeeverything2 req/s1,000
proeverything10 req/s20,000

Every keyed response carries X-Credits-Charged and X-Credits-Remaining headers. Charges apply on success only — errors are never billed. Per-call costs are listed with each endpoint below.

// Endpoints

Four operations. No fifth flaky one.

GET /v1/videos/{id}

Full metadata for one video — the cheap look before an expensive extract.

Path

ParameterDescription
idthe 11-character YouTube video id.
request
curl -s "https://api-production-4a11e.up.railway.app/v1/videos/zjkBMFhNj_g" \
-H "Authorization: Bearer ys_live_YOUR_KEY"

Returns the video's native metadata — title, channel, duration, views, publish date, description — with chapters when the video has them.

1 credit

GET /v1/videos/{id}/transcript

Every video returns a transcript — captions when they exist, speech-to-text when they don't.

Query parameters

ParameterDescription
formatmarkdown | json | plain — the shape of the returned text.
start, endreturn only the segment between these bounds.
max_tokenscap the response size to fit your context budget.
request
curl -s "https://api-production-4a11e.up.railway.app/v1/videos/zjkBMFhNj_g/transcript?format=markdown&max_tokens=300" \
-H "Authorization: Bearer ys_live_YOUR_KEY"

Returns the timestamped transcript in the requested format. Sourced from captions when available; otherwise ASR transcribes the audio — no captions ≠ no answer.

1 cached · 2 cold · 10 when ASR transcribes

GET /v1/videos/{id}/summary

Structured summary sections you select per call — take only the tokens you need.

Query parameters

ParameterDescription
sectionscomma-separated list of: executive_summary, key_points, detailed_summary, insights, timestamps, action_items, resources.
request
curl -s "https://api-production-4a11e.up.railway.app/v1/videos/zjkBMFhNj_g/summary?sections=executive_summary" \
-H "Authorization: Bearer ys_live_YOUR_KEY"

Returns only the sections you asked for, as structured text.

1 cached · 5 cold

GET /v1/credits

The balance for your key. Takes no parameters.

request
curl -s "https://api-production-4a11e.up.railway.app/v1/credits" \
-H "Authorization: Bearer ys_live_YOUR_KEY"

0 credits — checking your balance is always free

// Errors

Typed, never silent

Every error is the same envelope — a machine-readable code your agent can branch on, plus a human-readable message:

the envelope
{
"error": "KEY_REQUIRED",
"message": "This video's transcript isn't cached yet. Keyless access serves cached content only — get a free API key (1,000 credits/month, no card) to fetch fresh content."
}
StatusCodesAgent action
400INVALID_REQUEST, INVALID_VIDEO_IDFix the request.
401INVALID_KEY, KEY_REQUIREDFix credentials — a keyless request hit uncached content.
402OUT_OF_CREDITSMonthly allowance exhausted; resets at month start.
403 / 404AGE_RESTRICTED, TRANSCRIPTS_DISABLED, VIDEO_UNAVAILABLE, …Video-state facts; don't retry.
429RATE_LIMITEDHonor Retry-After.
502 / 503*_FAILED, *_UNAVAILABLETransient; retry. 429 and 5xx are the retryable class.

Failed calls are never billed.

// MCP setup

Wire it into Claude Code

A remote Streamable HTTP server exposes the four operations as read-only tools: search_videos, get_video, get_transcript, get_summary.

claude mcp add
claude mcp add --transport http youtubesearch \
https://mcp-production-f86c.up.railway.app/mcp \
--header "Authorization: Bearer ys_live_YOUR_KEY"

omit --header to run keyless (cached content + search only)

// CLI

The same four operations, from a shell

No install — npx youtubesearch runs the latest version. Log in once; keyless works without it.

shell
npx youtubesearch auth login # paste your key once
npx youtubesearch search "intro to large language models" --limit 5
npx youtubesearch video zjkBMFhNj_g
npx youtubesearch transcript zjkBMFhNj_g --max-tokens 2000
npx youtubesearch summary zjkBMFhNj_g --sections executive_summary,key_points
// OpenAPI spec

The machine-readable contract

Every endpoint, parameter, and response shape above is specified in the OpenAPI document — feed it to a generator or an agent:

https://api-production-4a11e.up.railway.app/v1/openapi.json

Agents can also read /llms-full.txt — this entire reference as one plain-markdown file.