> **For coding agents and LLMs:** This is one page from the Social Fetch docs (markdown export). The sections below mirror the orientation block in [`/llms.txt`](https://www.socialfetch.dev/llms.txt); use [`/llms.json`](https://www.socialfetch.dev/llms.json) when you need a structured operation inventory. The catalog covers documented operations with on-site reference pages.

## This page

- **On-site (HTML):** [https://www.socialfetch.dev/docs/api/v1/youtube/videos/get](https://www.socialfetch.dev/docs/api/v1/youtube/videos/get)
- **Markdown (.mdx) URL:** [https://www.socialfetch.dev/docs/api/v1/youtube/videos/get.mdx](https://www.socialfetch.dev/docs/api/v1/youtube/videos/get.mdx)

## API base URL and authentication

- **API origin (from OpenAPI `servers`):** `https://api.socialfetch.dev`
- **Authentication:** send `x-api-key: sfk_...` on `/v1/**` routes unless the operation is explicitly anonymous (check OpenAPI `security`, the [API reference hub](https://www.socialfetch.dev/docs/api.mdx), [`/llms.txt`](https://www.socialfetch.dev/llms.txt), or [`/llms.json`](https://www.socialfetch.dev/llms.json) for each route).
- **OpenAPI JSON:** [https://www.socialfetch.dev/openapi.json](https://www.socialfetch.dev/openapi.json)

## Recommended docs entrypoints (this site)

- [Documentation overview](https://www.socialfetch.dev/docs.mdx) — top-level orientation (markdown).
- [Quickstart](https://www.socialfetch.dev/docs/quickstart.mdx) — authenticate with `x-api-key`, validate auth with `whoami`, and understand the JSON envelope.
- [SDK](https://www.socialfetch.dev/docs/sdk.mdx) — official TypeScript SDK guide, including `SocialFetchClient`, `Result`, and `unwrap()`.
- [SDK reference](https://www.socialfetch.dev/docs/sdk-reference.mdx) — exhaustive SDK method inventory and route mapping for agents, tooling, and power users.
- [Choose the right endpoint](https://www.socialfetch.dev/docs/choose-endpoint.mdx) — task-oriented route selection for smoke tests, profiles, list endpoints, and single-item lookups.
- [Capability matrix](https://www.socialfetch.dev/docs/capability-matrix.mdx) — fast comparison of identifiers, pagination, outcomes, media download, and SDK coverage.
- [`/llms.json`](https://www.socialfetch.dev/llms.json) — structured machine-readable operation inventory with parameter names, pagination, outcomes, credits, and SDK mapping.
- [API reference hub](https://www.socialfetch.dev/docs/api.mdx) — human-friendly index of operations with links into generated pages.
- [Errors](https://www.socialfetch.dev/docs/errors.mdx) — shared error envelope and HTTP status guidance.
- [Credits](https://www.socialfetch.dev/docs/credits.mdx) — metering, `402`, and planning batch jobs.
- Outcome semantics such as `found`, `not_found`, and `private` are documented in [Errors](https://www.socialfetch.dev/docs/errors.mdx) and on operation pages when present in the OpenAPI contract.

## Markdown docs convention

- Every docs page has a markdown twin: append **`.mdx`** to the docs pathname (for example `/docs/quickstart` → `/docs/quickstart.mdx`).
- Agents that send `Accept: text/markdown` on `/docs/**` HTML URLs may receive markdown directly (same URL, `Vary: Accept`).

---
# Get YouTube video (https://www.socialfetch.dev/docs/api/v1/youtube/videos/get)

## Summary

Returns public metadata for a single YouTube video. This endpoint also supports YouTube Shorts URLs.

**Tags:** `YouTube`

## HTTP

- **Method:** GET
- **Path:** `/v1/youtube/videos`
- **Base URL:** `https://api.socialfetch.dev`

## Capability summary

- **SDK mapping:** `client.youtube.getVideo({ url, language? })`
- **Accepted identifiers:** `url` (query)
- **Pagination:** none
- **Business outcome field:** `data.lookupStatus` with values `found`, `not_found`

## Credits

- **Base:** 1 credit per successful lookup.
- **Maximum on success (200):** 1 credit.
- **Authoritative field:** `meta.creditsCharged`.

## Authentication

- **`x-api-key`**: API key (`sfk_...`)

## Parameters

### `url` (query)

- **Required:** yes
- **Constraints:** type `string`; minLength: 1; maxLength: 4096
- **Description:** Link to the YouTube video. Shorts URLs are also supported.

### `language` (query)

- **Required:** no
- **Constraints:** type `string`; minLength: 2; maxLength: 16
- **Description:** Optional preferred language for returned text when the source supports localization.

## Responses (status codes)

- **200**: YouTube video metadata. Check `data.lookupStatus` for `found` vs `not_found`.
- **400**: Invalid query or bad request
- **401**: Missing or invalid API key
- **402**: Insufficient credits
- **500**: Unexpected or billing error
- **502**: Lookup could not be completed from the response (unexpected or invalid data).
- **503**: Service temporarily unavailable; safe to retry with backoff.

## Response body (200)

YouTube video metadata. Check `data.lookupStatus` for `found` vs `not_found`.

### Field outline

- **data** (required) — type `object`. Endpoint-specific response payload.
  - **lookupStatus** (required) — type `string`; enum: found, not_found. Whether the video was resolved for this request.
  - **video** (required) — type `object`; nullable. Video details when found.
    - **id** (required) — type `string`; minLength: 1. YouTube video identifier.
    - **url** (required) — type `string`; minLength: 1. Canonical public YouTube URL.
    - **title** (required) — type `string`. Video title.
    - **description** (required) — type `string`; nullable. Video description text when available.
    - **descriptionLinks** (required) — type `array`. URLs extracted from the description when available.
      - _items:_
        - type `string`; minLength: 1
    - **thumbnailUrl** (required) — type `string`; minLength: 1. Best available thumbnail image URL.
    - **publishedAt** (required) — type `string`; nullable. Publish timestamp when available.
    - **publishDateText** (required) — type `string`; nullable. Human-readable publish date label when available.
    - **durationMs** (required) — type `integer`; minimum: 0; nullable. Video duration in milliseconds when available.
    - **durationFormatted** (required) — type `string`; nullable. Human-readable duration label when available.
    - **genre** (required) — type `string`; nullable. Category or genre label when available.
    - **keywords** (required) — type `array`. Keyword tags associated with the video when available.
      - _items:_
        - type `string`; minLength: 1
    - **isPaidPromotion** (required) — type `boolean`. Whether the video is marked as paid promotion.
  - **channel** (required) — type `object`; nullable. Uploader channel when found.
    - **platform** (required) — type `string`; enum: youtube. Social platform for this channel.
    - **handle** (required) — type `string`; minLength: 1. YouTube channel handle without a leading @.
    - **displayName** (required) — type `string`; nullable. Public display name for the YouTube channel.
    - **profileUrl** (required) — type `string`; minLength: 1. Canonical public YouTube channel URL.
    - **platformUserId** (optional) — type `string`. YouTube channel id when available.
  - **metrics** (required) — type `object`; nullable. Engagement metrics when found.
    - **views** (required) — type `integer`; minimum: 0; nullable. View count when available.
    - **likes** (required) — type `integer`; minimum: 0; nullable. Like count when available.
    - **comments** (required) — type `integer`; minimum: 0; nullable. Comment count when available.
  - **chapters** (required) — type `array`. Chapter markers when available.
    - _items:_
      - **title** (required) — type `string`. Chapter title.
      - **startTimeText** (required) — type `string`; nullable. Human-readable chapter start time when available.
      - **startTimeSeconds** (required) — type `number`; minimum: 0. Chapter start offset in seconds.
  - **captions** (required) — type `array`. Caption and subtitle tracks when available.
    - _items:_
      - **label** (required) — type `string`. Caption track label.
      - **languageCode** (required) — type `string`. BCP-47 style language code when available.
      - **kind** (required) — type `string`; nullable. Caption kind when available.
      - **isTranslatable** (required) — type `boolean`. Whether the track can be translated in the player.
  - **relatedVideos** (required) — type `array`. Related videos suggested after playback when available.
    - _items:_
      - **id** (required) — type `string`; minLength: 1. Related video id.
      - **url** (required) — type `string`; nullable. Canonical watch URL when available.
      - **title** (required) — type `string`. Related video title.
      - **thumbnailUrl** (required) — type `string`; nullable. Thumbnail image URL when available.
      - **publishedAt** (required) — type `string`; nullable. Resolved publish timestamp when available.
      - **publishedTimeText** (required) — type `string`; nullable. Human-readable relative publish time when available.
      - **viewCount** (required) — type `integer`; minimum: 0; nullable. View count when available.
      - **viewCountText** (required) — type `string`; nullable. Human-readable view count when available.
      - **durationSeconds** (required) — type `integer`; minimum: 0; nullable. Duration in seconds when available.
      - **durationText** (required) — type `string`; nullable. Human-readable duration label when available.
      - **channel** (required) — type `object`; nullable. Uploader channel summary when available.
        - **displayName** (required) — type `string`; nullable. Related video channel title when available.
        - **handle** (required) — type `string`; nullable. Related video channel handle when available.
        - **profileUrl** (required) — type `string`; nullable. Related video channel URL when available.
        - **platformUserId** (optional) — type `string`. Related video channel id when available.
- **meta** (required) — type `object`. Metadata describing the request and billing outcome.
  - **requestId** (required) — type `string`; minLength: 1. Unique request identifier for tracing this API call.
  - **creditsCharged** (required) — type `integer`; minimum: 0. Credits charged for this request.
  - **version** (required) — type `string`; enum: v1. Public API version that served the response.

### Example JSON (found)

```json
{
  "data": {
    "lookupStatus": "found",
    "video": {
      "id": "Y2Ah_DFr8cw",
      "url": "https://www.youtube.com/watch?v=Y2Ah_DFr8cw",
      "title": "Example video",
      "description": "Description text.",
      "descriptionLinks": [],
      "thumbnailUrl": "https://img.youtube.com/vi/Y2Ah_DFr8cw/maxresdefault.jpg",
      "publishedAt": "2019-02-22T03:19:54-08:00",
      "publishDateText": "Feb 22, 2019",
      "durationMs": 348000,
      "durationFormatted": "00:05:48",
      "genre": "People & Blogs",
      "keywords": [
        "example"
      ],
      "isPaidPromotion": false
    },
    "channel": {
      "platform": "youtube",
      "handle": "afroballer8906",
      "displayName": "Afroballer",
      "profileUrl": "https://www.youtube.com/@afroballer8906",
      "platformUserId": "UCWH3hing1Qb4LnkRfQdxsxQ"
    },
    "metrics": {
      "views": 372864,
      "likes": 4043,
      "comments": 358
    },
    "chapters": [],
    "captions": [
      {
        "label": "English (auto-generated)",
        "languageCode": "en",
        "kind": "asr",
        "isTranslatable": true
      }
    ],
    "relatedVideos": [
      {
        "id": "lzDTK5kEdkM",
        "url": "https://www.youtube.com/watch?v=lzDTK5kEdkM",
        "title": "Charles Barkley and Shaq FUNNIEST MOMENTS",
        "thumbnailUrl": "https://i.ytimg.com/vi/lzDTK5kEdkM/hqdefault.jpg",
        "publishedAt": "2025-02-16T19:25:39.493Z",
        "publishedTimeText": "11 months ago",
        "viewCount": 1800000,
        "viewCountText": "1.8M views",
        "durationSeconds": 1081,
        "durationText": "18:01",
        "channel": {
          "displayName": "SkyHooked",
          "handle": "SkyHooked",
          "profileUrl": "https://www.youtube.com/@SkyHooked",
          "platformUserId": "UCrX8GD5f_O-Cu5Y2vQuSSvw"
        }
      }
    ]
  },
  "meta": {
    "requestId": "req_01example",
    "creditsCharged": 1,
    "version": "v1"
  }
}
```

### Example JSON (short)

```json
{
  "data": {
    "lookupStatus": "found",
    "video": {
      "id": "QLu_ZsRc_G0",
      "url": "https://www.youtube.com/watch?v=QLu_ZsRc_G0",
      "title": "Covering 10 points, a surprisingly tricky puzzle.",
      "description": "Made as part of a monthly series of puzzles for the 2026 Year of Math.",
      "descriptionLinks": [],
      "thumbnailUrl": "https://img.youtube.com/vi/QLu_ZsRc_G0/maxresdefault.jpg",
      "publishedAt": "2026-04-16T09:08:21-07:00",
      "publishDateText": "Apr 16, 2026",
      "durationMs": 39000,
      "durationFormatted": "00:00:39",
      "genre": "Education",
      "keywords": [
        "Mathematics"
      ],
      "isPaidPromotion": false
    },
    "channel": {
      "platform": "youtube",
      "handle": "3blue1brown",
      "displayName": "3Blue1Brown",
      "profileUrl": "https://www.youtube.com/@3blue1brown",
      "platformUserId": "UCYO_jab_esuFRV4b17AJtAw"
    },
    "metrics": {
      "views": 575269,
      "likes": 14359,
      "comments": 1300
    },
    "chapters": [],
    "captions": [
      {
        "label": "English (auto-generated)",
        "languageCode": "en",
        "kind": "asr",
        "isTranslatable": true
      }
    ],
    "relatedVideos": []
  },
  "meta": {
    "requestId": "req_01example_short",
    "creditsCharged": 1,
    "version": "v1"
  }
}
```

### Example JSON (not_found)

```json
{
  "data": {
    "lookupStatus": "not_found",
    "video": null,
    "channel": null,
    "metrics": null,
    "chapters": [],
    "captions": [],
    "relatedVideos": []
  },
  "meta": {
    "requestId": "req_01example_nf",
    "creditsCharged": 1,
    "version": "v1"
  }
}
```

### Machine-readable error codes

When an error JSON body is returned, it may include one of these `error.code` values (derived from the OpenAPI schemas for this operation; additional codes may exist at runtime):

- `bad_request`

## Error handling & retries

Interpret HTTP status codes using the descriptions below. Do not assume a JSON body unless the OpenAPI schema defines one for that status.

- **400**: Invalid query or bad request **Retry:** Fix the request; retrying the same invalid payload will not help.
- **401**: Missing or invalid API key **Retry:** Fix the API key first; retrying without changes will not help.
- **402**: Insufficient credits **Retry:** Do not retry without resolving billing/credits (retrying the same request will not help).
- **500**: Unexpected or billing error
- **502**: Lookup could not be completed from the response (unexpected or invalid data). **Retry:** May be transient; a few retries with backoff are reasonable.
- **503**: Service temporarily unavailable; safe to retry with backoff. **Retry:** Usually safe to retry with exponential backoff and jitter.

### Suggested client defaults

- Send the API key using the `x-api-key` header on every request.
- On `503` (and sometimes `502`), retry with backoff; cap retries and surface a clear error to the user.
- On `402`, surface an actionable billing message rather than blind retries.

## Examples

### TypeScript SDK

```typescript
import { SocialFetchClient } from "@socialfetch/sdk";

const client = new SocialFetchClient({
  apiKey: process.env.SOCIALFETCH_API_KEY!,
});

const result = await client.youtube.getVideo({
  url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
});

if (!result.ok) {
  console.error(result.error);
} else {
  console.log(result.value.data);
}
```

### Node.js

```javascript
const response = await fetch(
  "https://api.socialfetch.dev/v1/youtube/videos?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ",
  {
    headers: {
      "x-api-key": "YOUR_API_KEY",
    }
  }
);

const data = await response.json();
console.log(data);
```

### cURL

```bash
curl "https://api.socialfetch.dev/v1/youtube/videos?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ" \
  -H "x-api-key: YOUR_API_KEY"
```

### Python

```python
import requests

response = requests.get(
    "https://api.socialfetch.dev/v1/youtube/videos?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    headers={"x-api-key": "YOUR_API_KEY"},
)
data = response.json()
print(data)
```