Social media6 min readBy Purrkey teamUpdated

How to fetch a YouTube video's metadata by URL or ID

Fetch a YouTube video or Short's title, channel, views, likes, comments, duration and publish date from a URL or ID. Build a comparison table for 25 campaign videos

On this page

You have 25 YouTube video URLs from a campaign and need each video's title, channel, views, likes, comments, duration and publish date. One call per URL to anyapi.youtube.video returns those fields, and the worksheet below turns them into a comparison table you can sort to see which videos still earn attention and which need refreshed creative

No run has been executed for this guide. The table below is a design, and the values in it are placeholders showing the shape

The worksheet and an example input

The deliverable is one row per source URL, with the returned metadata next to it and two status columns at the end. You add the source URL yourself, because the tool answers by video and does not need to echo the url you sent

source_urltitlechannelviewslikescommentsdurationMscreatedUtcfoundreason
your URLvideo titlechannel name00000true(absent when found)
your URL(empty)(empty)falsenot_found

Example input, an invented Short URL that stands in for the first row of your list: https://www.youtube.com/shorts/abc123DEF45

Swap in your own 25 URLs before running anything. Keep the source URL in the first column so a not-found row still points at the video you meant to check

What the tool takes

The contract documents three input properties: url, id and requireFields. The first two are alternatives. url takes a full YouTube video URL, and the contract says Shorts (youtube.com/shorts/...), youtu.be, live and embed URLs work. id takes the YouTube video ID, and a Short uses the same ID as any other video. The schema requires at least one of them

requireFields is optional and changes routing only when you use it. Omit it and routing is unchanged, with the cheapest source serving. Name one or more of authorAvatarUrl, comments or description and the request is served only by a source that returns the named fields. Fields you do not name are still returned whenever the serving source has them

That option is the one place where this tool can cost more than the listed price. When the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. Name a combination that no single source returns together and the request is refused as invalid input, with no charge. A source that returns only a rounded or shortened value for a field does not count as returning it

One limit sits next to this step: a named requireFields value can still be absent on a video that genuinely lacks it, so an empty description on a field you required is not a failed call

How to read the output fields that decide

Read found first. When it is true, data holds the video result. When it is false, data is null and reason is present with the value not_found, which the contract defines as the source stating the target does not exist, or returning nothing for it. The contract treats a found false answer as a successful call, not an error, and costUsd is what it actually cost

Inside data, the required fields are id, title, channel, views, likes, comments, durationMs and createdUtc. Duration arrives in milliseconds. createdUtc is a UTC epoch timestamp in seconds, so multiply by 1000 for a JS Date in milliseconds. comments is an integer, and some sources round large counts, showing 2.4M instead of 2,457,538; naming comments in requireFields gets a source that returns the exact count. Other fields such as category, keywords, image, authorId, authorUrl and authorAvatarUrl come back whenever the serving source has them

For the campaign decision, sort by views for the ranking, pair views with createdUtc to separate old videos that still pull traffic from old videos that stopped, and check durationMs when a Short and a long upload need different treatment. A row with found set to false leaves the video out of the ranking and goes back to whoever owns the list, since the tool cannot return metadata for a video the source does not have

The agent prompt

Agent prompt
Set up https://purrkey.app/SKILL.md, then use Purrkey to fetch metadata
for the 25 YouTube video URLs below. Check the current inputs and price
of anyapi.youtube.video before running anything. Call it once per URL.
Return a table with source_url, title, channel, views, likes, comments,
durationMs, createdUtc, found and reason. Keep my source_url in the first
column, leave data fields empty when found is false, and do not guess
values for missing fields. Do not set requireFields unless I ask.

https://www.youtube.com/shorts/abc123DEF45

Replace the example line with your 25 URLs. The prompt sends no requireFields, so the cheapest source serves and the price stays at the listed ceiling

Estimated tool cost

Prices from the Purrkey catalog, read November 13, 2026. The listing is max_call at up to $0.0012 per call, and the catalog explains the unit as "Maximum per call. Successful runs settle at the actual AnyAPI charge." The totals below are ceilings, not settled charges

StepFormulaUnit pricePlanned quantityTotal
25 video fetchescalls x max price$0.0012 per call25$0.03
100 video fetchescalls x max price$0.0012 per call100$0.12

The campaign list is 25 calls at most $0.03. If the list grows to 100 URLs, the same run is at most $0.12. Model fees for the agent are not counted. A not-found answer is still a call, so rows that come back empty sit inside these totals

Next action

Run the first URL through the tool page at YouTube tools, which lists anyapi.youtube.video and the tool is called through POST /v1/runs with toolId anyapi.youtube.video. If the campaign comparison needs channel-level numbers as well, the guide on checking YouTube channel stats and links covers the matching fields

Get started by giving this to your agent

  • Claude Code
  • Codex
  • Gemini CLI
  • Cursor
  • GitHub Copilot
Set up https://purrkey.app/SKILL.md, then use Purrkey to show me what I can do with YouTube.
Explore YouTube tools and pricing

FAQ

How do I fetch a YouTube video's metadata by URL or ID?

Send either url or id to anyapi.youtube.video and read the data object, which carries title, channel, views, likes, comments, durationMs and createdUtc. A Short uses the same ID as any other video, so one call covers both formats.

What inputs does anyapi.youtube.video take?

The contract documents url, id and requireFields. url accepts a full YouTube video URL, including Shorts, youtu.be, live and embed forms, and id takes the YouTube video ID. The schema requires at least one of url or id.

What happens when a video is not found?

The result comes back with found set to false, data set to null and reason set to not_found. The contract describes a found false answer as a successful call, not an error, and costUsd is what it actually cost.

How much does it cost to fetch metadata for 25 videos?

At up to $0.0012 per call as a ceiling, 25 calls come to at most $0.03. A list of 100 videos is 100 calls, at most $0.12.

Does naming a field in requireFields cost more?

It can. When the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A combination that no single source returns together is refused as invalid input, with no charge.

Why do comment counts sometimes look rounded?

Some sources round large counts, showing 2.4M instead of 2,457,538. Naming comments in requireFields means the request is served only by a source that returns the exact count.

What format is createdUtc in?

It is a UTC epoch timestamp in seconds. Multiply by 1000 to get a JS Date in milliseconds.

Next step

Try this with YouTube

The tool directory lists every endpoint with its current price. Inspect the inputs there, then let your agent run a small batch before scaling up.

See YouTube tools

Share this article