Skip to Content
agentic-yt

Metadata

Video details, chapters and counters; the formats a video can be downloaded in; and its thumbnails.

Video details

ayt video dQw4w9WgXcQ --json
curl "https://api.agentic-yt.crafter.run/v1/videos/dQw4w9WgXcQ" \
  -H "Authorization: Bearer $AGENTIC_YT_TOKEN"

The response has:

FieldNotes
id, url, title, description
duration_secondsnull for a live stream.
channel{ id, name, handle, url }.
thumbnailsEvery size, each { url, width, height }.
view_count, like_count, comment_countAny can be null.
chapters[{ title, start, end }] in seconds; empty when the video has none.
tags, categories
published_atISO 8601 UTC.
visibilitypublic, unlisted, private, members_only or unknown.
is_live, language
cache{ hit, stable_fetched_at, counters_fetched_at } — how fresh this answer is.

Freshness

Metadata is cached in two halves. The stable half — title, description, chapters, tags — is kept for 7 days. The counters — views, likes, comment count — are kept for 1 hour. cache.hit is true when the answer came entirely from cache, and the two timestamps say when each half was last fetched.

When the live number matters, bypass both:

ayt video dQw4w9WgXcQ --fresh --json      # GET /v1/videos/{id}?fresh=true

fresh=true always contacts YouTube, so it is slower and can fail with youtube_blocked where the cached answer would not. Do not make it the default.

Chapters make good clips

chapters[].start and end are already in seconds — exactly what ayt clip takes. "Give me the chapter about X" is one metadata call and one clip.

Formats

ayt formats dQw4w9WgXcQ --json

GET /v1/videos/{id}/formats answers two questions.

What does YouTube have? formats lists the source streams, each with format_id, kind (video, audio or muxed for both), ext, width, height, fps, quality_label (like 1080p60), codecs, bitrate_kbps, filesize_bytes and language.

What can I ask for? downloadable is the part an agent should read:

{
  "downloadable": {
    "video_qualities": ["144p", "240p", "360p", "480p", "720p", "1080p"],
    "video_formats": ["mp4", "webm"],
    "audio_formats": ["mp3", "wav", "m4a", "opus"]
  }
}

video_qualities are the values this particular video accepts as quality on download. You do not have to check first — asking for a quality the video does not have gives you the next lower one — but it is how you find out that a 2009 upload tops out at 480p before promising the user 1080p.

Thumbnails

ayt thumbnail dQw4w9WgXcQ --json
ayt thumbnail dQw4w9WgXcQ -o cover.jpg

GET /v1/videos/{id}/thumbnail?quality=maxres returns thumbnail — the size closest to what you asked for — and thumbnails, every size available. quality is one of default, medium, high, standard, maxres (the default). The URLs point at YouTube's image servers and need no token.

A thumbnail is the uploader's chosen cover image. For a picture of a specific moment in the video, use frames.

Errors to expect

  • video_unavailable — private, deleted, region-locked or age-restricted.
  • youtube_blocked — YouTube refused; a cached answer may still be available without fresh.

On this page