# YouTube Video (`youtube.video`)

Metadata for one YouTube video or Short by URL or ID: title, description, channel, views, likes, comment count, duration, publish date, tags and category.

Docs: https://primaryapi.com/docs/api-reference/youtube/video

- Endpoint: `POST https://api.primaryapi.com/v1/run/youtube.video`
- Category: Social · Platform: `youtube` · Kind: lookup · Status: live
- Price: 2 credits per call; up to 8 credits if a call is retried elsewhere. A quote’s `maxCredits` is the most a given call can cost.
- Billing unit: per successful call
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=youtube.video`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `url` | string | no |  | max 2048 chars | YouTube video URL: watch, youtu.be, Shorts, live, embed and mobile links all work. Give url or id. |
| `id` | string | no |  | pattern: ^[A-Za-z0-9_-]{11}$ | 11-character YouTube video ID (a Short uses the same ID format). Give url or id. |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `id` | string | 11-character video ID |
| `url` | string | Canonical watch URL |
| `title` | string \| null |  |
| `description` | string \| null |  |
| `image` | string \| null | Thumbnail URL |
| `createdUtc` | string \| null | Publish time, ISO 8601 |
| `durationMs` | integer \| null |  |
| `views` | integer \| null |  |
| `likes` | integer \| null | null when the creator hides likes |
| `comments` | integer \| null | Comment count; null when comments are off or the source does not expose it |
| `category` | string \| null | YouTube category (genre) |
| `keywords` | string[] \| null | Creator tags; null when the source does not expose them |
| `channel` | string \| null | Channel title |
| `authorId` | string \| null | Channel ID (UC…) |
| `authorUrl` | string \| null |  |
| `authorAvatarUrl` | string \| null |  |
| `isPaidPromotion` | boolean \| null | YouTube "includes paid promotion" flag (null when the source does not expose it) |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/youtube.video" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://www.youtube.com/watch?v=Y2Ah_DFr8cw"}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "id": "Y2Ah_DFr8cw",
      "url": "https://www.youtube.com/watch?v=Y2Ah_DFr8cw",
      "title": "Inside the NBA: Chuck Trolls Jussie Smollett \"Do not commit crimes with checks, use cash!\"",
      "description": null,
      "image": "https://img.youtube.com/vi/Y2Ah_DFr8cw/maxresdefault.jpg",
      "createdUtc": "2019-02-22T11:19:54.000Z",
      "durationMs": 348000,
      "views": 372864,
      "likes": 4043,
      "comments": 358,
      "category": "People & Blogs",
      "keywords": [],
      "channel": "Afroballer",
      "authorId": "UCWH3hing1Qb4LnkRfQdxsxQ",
      "authorUrl": "https://www.youtube.com/@afroballer8906",
      "authorAvatarUrl": null,
      "isPaidPromotion": false
    }
  },
  "provider": "PrimaryAPI",
  "credits": 2,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z"
}
```

## Pricing and reliability

- Usual price: 2 credits per call
- Price ceiling: up to 8 credits if a call is retried elsewhere. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=youtube.video`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Notes

Callers pass url or id; vendors always receive the canonical watch URL.

