Search
Find videos, channels or playlists, page through results, and turn any YouTube URL into an id.
Search YouTube
ayt search "how transformers work" --limit 5 --jsoncurl "https://api.agentic-yt.crafter.run/v1/search?q=how+transformers+work&limit=5" \
-H "Authorization: Bearer $AGENTIC_YT_TOKEN"| Parameter | Default | Notes |
|---|---|---|
q | — | Required. 1–500 characters. |
type | video | video, channel or playlist. One kind per request. |
limit | 20 | 1–100. |
cursor | — | next_cursor from the previous response. |
The response echoes query and type, and returns results plus next_cursor. Each result
carries a type field, so the same code can handle all three kinds:
{
"query": "how transformers work",
"type": "video",
"results": [
{
"type": "video",
"id": "…",
"url": "https://www.youtube.com/watch?v=…",
"title": "…",
"duration_seconds": 1620,
"channel": { "id": "UC…", "name": "…", "handle": "@…", "url": "…" },
"thumbnail_url": "…",
"view_count": 1234567,
"published_at": "2024-04-01T00:00:00.000Z",
"is_live": false
}
],
"next_cursor": "…"
}Channel results have name, handle, description, subscriber_count. Playlist results have
title, channel, video_count. Any counter can be null — YouTube does not always expose it.
Paging
next_cursor is opaque. Pass it back unchanged as cursor with the same q and type; when
it is null there are no more results.
ayt search "how transformers work" --cursor "<next_cursor>" --jsonPicking a result
Search results are summaries. Once the agent has chosen one, ayt video <id> gets the description,
chapters and tags — see Metadata. Check duration_seconds before asking
for a download: videos over the maximum duration are refused with
too_long.
Resolve a URL
You rarely need this: every {id} path parameter already accepts a full, percent-encoded YouTube
URL, and the CLI encodes it for you.
ayt video "https://youtu.be/dQw4w9WgXcQ?t=42"GET /v1/resolve exists for clients that cannot put a URL in a path segment, and for when you want
to know what a link is without contacting YouTube:
ayt resolve "https://www.youtube.com/watch?v=dQw4w9WgXcQ&list=PL123&t=42" --json{
"kind": "video",
"id": "dQw4w9WgXcQ",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"playlist_id": "PL123",
"start_seconds": 42
}kind is video, channel or playlist. playlist_id is set when a video URL also carried
list=, and start_seconds when it carried t= or start= — useful as the start of a
clip. It makes no network call to YouTube, so it does not tell you whether the
video exists.
Errors to expect
validation_failed— emptyq,limitout of range, or a string that is not a YouTube URL or id.youtube_blocked— YouTube refused the search. Retry after a pause.