> ## Documentation Index
> Fetch the complete documentation index at: https://getanyapi.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# YouTube Video

> Sell youtube.video on AnyAPI: the request your endpoint receives, the response it must return, and what the live trial grades.

Fetch a YouTube video or Short's metadata (title, channel, views, likes, duration, publish date) by URL or ID.

This page is the seller-facing summary of one catalog API, `youtube.video`. The transport rules that apply to every API a seller serves - signed requests, the response envelope, timeouts, and body limits - are on [the operator endpoint contract](https://getanyapi.com/docs/sell/operator-endpoint-contract.md).

## The price you compete with

AnyAPI publishes this API from **\$0.80 per 1,000 requests**. That is the price a buyer sees today, so it is the price your endpoint has to come in under to win traffic.

## The request your endpoint receives

This API takes no input fields.

> **Full input JSON Schema**
>
> ```json theme={"dark"}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "$id": "https://getanyapi.com/schemas/youtube.video.input.json",
>   "example": {
>     "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
>   },
>   "title": "YouTube video input",
>   "type": "object",
>   "additionalProperties": false,
>   "properties": {
>     "url": {
>       "type": "string",
>       "description": "Full YouTube video URL. Shorts (youtube.com/shorts/...), youtu.be, live, and embed URLs all work."
>     },
>     "id": {
>       "type": "string",
>       "description": "YouTube video ID. A Short uses the same ID as any other video."
>     },
>     "requireFields": {
>       "type": "array",
>       "uniqueItems": true,
>       "items": {
>         "type": "string",
>         "enum": [
>           "authorAvatarUrl",
>           "comments",
>           "description"
>         ]
>       },
>       "description": "Optional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `authorAvatarUrl`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A named field can still be absent on a video that genuinely lacks it. Naming a combination that no single source returns together 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."
>     }
>   },
>   "anyOf": [
>     {
>       "required": [
>         "url"
>       ]
>     },
>     {
>       "required": [
>         "id"
>       ]
>     }
>   ]
> }
> ```

## The response your endpoint must return

| Field | Type | Always present | What it means |
| - | - | - | - |
| `data` | null or object | yes | The video result, or null when not found. |
| `data.authorAvatarUrl` | string | no | URL of the publishing channel's avatar image. |
| `data.authorId` | string | no | YouTube channel ID of the publishing channel. |
| `data.authorUrl` | string | no | Canonical URL of the publishing channel, tracking query parameters stripped. |
| `data.category` | string | no | YouTube category the video is filed under, for example "Music". |
| `data.channel` | string | yes | Name of the channel that published the video. |
| `data.comments` | integer | yes | Number of comments. Some sources round large counts (2.4M instead of 2,457,538); name `comments` in requireFields to be served only by a source that returns the exact count. |
| `data.createdUtc` | number | yes | UTC epoch timestamp in seconds (Unix time). Multiply by 1000 for a JS Date in milliseconds. |
| `data.description` | string | no | Video description text. Some sources return it as YouTube displays it, with long links shortened ([https://colab.research.google.com/dri](https://colab.research.google.com/dri)...) and YouTube or social links replaced by their titles; name `description` in requireFields to be served only by a source that returns every link intact. |
| `data.durationMs` | integer | yes | Duration of the video in milliseconds. |
| `data.id` | string | yes | Unique identifier of the video. |
| `data.image` | string | no | URL of the video thumbnail image. |
| `data.keywords` | array | no | Keywords the uploader tagged the video with. |
| `data.likes` | integer | yes | Number of likes. |
| `data.title` | string | yes | Title of the video. |
| `data.views` | integer | yes | Number of views. |
| `found` | boolean | yes | Whether the video was found. |

Extra fields are kept, missing declared fields fail.

> **Full output JSON Schema**
>
> ```json theme={"dark"}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "$id": "https://getanyapi.com/schemas/youtube.video.output.json",
>   "title": "YouTube video output",
>   "x-anyapi-result-list": false,
>   "type": "object",
>   "additionalProperties": false,
>   "required": [
>     "found",
>     "data"
>   ],
>   "properties": {
>     "found": {
>       "type": "boolean",
>       "description": "Whether the video was found."
>     },
>     "data": {
>       "description": "The video result, or null when not found.",
>       "oneOf": [
>         {
>           "type": "null"
>         },
>         {
>           "type": "object",
>           "required": [
>             "id",
>             "title",
>             "channel",
>             "views",
>             "likes",
>             "comments",
>             "durationMs",
>             "createdUtc"
>           ],
>           "properties": {
>             "id": {
>               "x-anyapi-must-populate": true,
>               "type": "string",
>               "description": "Unique identifier of the video."
>             },
>             "title": {
>               "x-anyapi-must-populate": true,
>               "type": "string",
>               "description": "Title of the video."
>             },
>             "channel": {
>               "x-anyapi-must-populate": true,
>               "type": "string",
>               "description": "Name of the channel that published the video."
>             },
>             "views": {
>               "type": "integer",
>               "description": "Number of views."
>             },
>             "likes": {
>               "type": "integer",
>               "description": "Number of likes."
>             },
>             "comments": {
>               "type": "integer",
>               "description": "Number of comments. Some sources round large counts (2.4M instead of 2,457,538); name `comments` in requireFields to be served only by a source that returns the exact count."
>             },
>             "durationMs": {
>               "type": "integer",
>               "description": "Duration of the video in milliseconds."
>             },
>             "createdUtc": {
>               "x-anyapi-must-populate": true,
>               "type": "number",
>               "description": "UTC epoch timestamp in seconds (Unix time). Multiply by 1000 for a JS Date in milliseconds."
>             },
>             "description": {
>               "type": "string",
>               "description": "Video description text. Some sources return it as YouTube displays it, with long links shortened (https://colab.research.google.com/dri...) and YouTube or social links replaced by their titles; name `description` in requireFields to be served only by a source that returns every link intact."
>             },
>             "authorId": {
>               "type": "string",
>               "description": "YouTube channel ID of the publishing channel."
>             },
>             "authorUrl": {
>               "type": "string",
>               "description": "Canonical URL of the publishing channel, tracking query parameters stripped."
>             },
>             "authorAvatarUrl": {
>               "type": "string",
>               "description": "URL of the publishing channel's avatar image."
>             },
>             "image": {
>               "type": "string",
>               "description": "URL of the video thumbnail image."
>             },
>             "keywords": {
>               "type": "array",
>               "items": {
>                 "type": "string"
>               },
>               "description": "Keywords the uploader tagged the video with."
>             },
>             "category": {
>               "type": "string",
>               "description": "YouTube category the video is filed under, for example \"Music\"."
>             }
>           }
>         }
>       ]
>     }
>   }
> }
> ```

## Fields that must never come back empty

* `channel`
* `createdUtc`
* `id`
* `title`

The repository marks these fields as ones every source must be able to fill. An empty value is only correct when the entity itself genuinely has nothing there.

## Not found, and how it differs from empty

When the entity does not exist, answer 2xx with the not-found shape:

```json theme={"dark"}
{
  "found": false,
  "data": null
}
```

An empty list is not a not-found: when the entity exists and has nothing to return, answer 2xx with `found: true` and an empty `keywords` array.

This output schema declares no `reason` field, so `found: false` is the whole not-found answer.

## Example request

```json theme={"dark"}
{
  "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}
```

The compatibility checks fire the schema's example at your endpoint. After that, your answers are graded against what the currently serving source returned for the same real customer inputs.

## Next

* [The operator endpoint contract](https://getanyapi.com/docs/sell/operator-endpoint-contract.md) for signing, budgets, and the live trial.
* [Every API open to sellers](https://getanyapi.com/docs/sell/apis/index.md).
* Want to sell an API that is not on that list? Email [support@getanyapi.com](mailto:support@getanyapi.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.