---
agent:
  instructions: "Search crawlapi docs via GET /.well-known/search?q={query} (add &format=json or Accept: application/json for JSON)."
  endpoint: "https://docs.crawlapi.dev/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.crawlapi.dev/llms.txt"
---

> Documentation index: https://docs.crawlapi.dev/llms.txt
> Search docs: https://docs.crawlapi.dev/.well-known/search?q={query}
> OpenAPI 3.1 specification: https://docs.crawlapi.dev/openapi.json

# X and YouTube

> Dedicated markdown layouts and structured fields for X posts and YouTube videos.

X posts and YouTube videos use dedicated extractors that return cleaner markdown layouts and normalized structured JSON. Both support `format: "markdown"` and `format: "json"`.

**X post**

```bash
curl -sS https://api.crawlapi.dev/v1/scrape \
  -H "Authorization: Bearer $CRAWLAPI_API_KEY" \
  -H 'content-type: application/json' \
  --data '{"url": "https://x.com/example/status/2120816188058112207"}'
```

**YouTube video**

```bash
curl -sS https://api.crawlapi.dev/v1/scrape \
  -H "Authorization: Bearer $CRAWLAPI_API_KEY" \
  -H 'content-type: application/json' \
  --data '{"url": "https://www.youtube.com/watch?v=rfscVS0vtbw"}'
```

## X posts

Supported hosts: `x.com`, `www.x.com`, `mobile.x.com`, `twitter.com`, `www.twitter.com`, and `mobile.twitter.com`.

- **`metadata.title`:** The attached X article title when present; otherwise the author and post excerpt.
- **`metadata.final_url`:** Canonical post URL (`https://x.com/<handle>/status/<id>`), with `twitter.com` normalized and share parameters stripped.
- **Threads:** Includes consecutive replies by the same author in order.
- **Replies:** Includes public replies shown to signed-out visitors under `## Replies` and in `structured.post.comments`, noting who nested replies answer.
- **Quoted posts and X articles:** Quoted posts render as blockquotes; attached X articles append their heading and markdown body.
- **Links and media:** `t.co` links expand to their destination URLs; `data.links` includes page links plus media URLs from the post and quoted post (`structured.post.media`).
- **Restricted posts:** Age-restricted posts return X's notice with `metadata.login_required: true`; direct `/i/article/<id>` URLs return `422 LOGIN_REQUIRED`.

### Markdown shape

```markdown
# Ana Ruiz (@ana)

2026-11-12 09:49:16 UTC · 77 likes · 2 reposts · 34 replies · 1 quote · 44 bookmarks · 5,335 views

Post text with line breaks kept and links expanded: https://example.com/launch

> Bo Lee (@bo): https://x.com/bo/status/2119867114450268322
>
> Quoted post text.

Reply · 2026-11-12 09:51:20 UTC · https://x.com/ana/status/2120816188058112207

Author's next post in the thread.

## Replies

2 of 34 replies, the ones X shows to a visitor who is not signed in.

Bo Lee (@bo) · 2026-11-12 10:02:11 UTC · 12 likes · https://x.com/bo/status/2120820000000000000

A reply by someone else.

Ana Ruiz (@ana) · replying to @bo · 2026-11-12 10:05:40 UTC · 3 likes · https://x.com/ana/status/2120820900000000000

The author answering it.
```

### Structured JSON shape

With `format: "json"`, `data.json.structured` has `type: "post"` and `source: "x"`; `tables`, `jsonld`, and `embedded` are empty arrays. See [Structured JSON](https://docs.crawlapi.dev/json.md) for the response envelope.

## YouTube videos

Supported URLs: `youtube.com/watch?v=...`, `/shorts/<id>`, `/live/<id>`, `/embed/<id>`, `/v/<id>`, channel `/live` pages, `m.youtube.com`, and `youtu.be/<id>`.

- **`metadata.title`:** Video title.
- **`metadata.final_url`:** Canonical video URL.
- **Chapters:** Extracted whenever chapters are declared in the video metadata.
- **Transcript:** Included under `## Transcript` (and `structured.video.transcript` in JSON) whenever captions are available, preferring manual captions over auto-generated ones.
- **Live streams and premieres:** Live streams show `Live now` with the broadcast start date; upcoming premieres show `Upcoming` with the scheduled date.
- **Links:** `data.links` includes the channel profile URL and links from the video description.
- **Unavailable or restricted videos:** Missing videos return `404 NOT_FOUND`, private videos return `422 LOGIN_REQUIRED`, and age-checked videos return public metadata with `metadata.login_required: true`.

### Markdown shape

```markdown
# Learn Python - Full Course for Beginners [Tutorial]

[freeCodeCamp.org](https://www.youtube.com/@freecodecamp)

2018-07-11 · 4:26:52 · 49,585,831 views

Full video description with line breaks preserved.

## Chapters

- 0:00 Introduction
- 1:45 Installing Python & PyCharm

## Transcript

[0:00] In this course, I'm going to teach you everything you need to know to get started programming in Python.
```

### Structured JSON shape

With `format: "json"`, `data.json.structured` has `type: "video"` and `source: "youtube"`; `tables`, `jsonld`, and `embedded` are empty arrays. See [Structured JSON](https://docs.crawlapi.dev/json.md) for the response envelope.

## Next steps

- [Markdown](https://docs.crawlapi.dev/markdown.md) Cleaning rules, link normalization, and response metadata.
- [Structured JSON](https://docs.crawlapi.dev/json.md) Full schema table for `post`, `video`, and 10 other entity types.
- [Errors & retries](https://docs.crawlapi.dev/errors.md) Handle `LOGIN_REQUIRED`, `NOT_FOUND`, and sign-in walls.
- [CLI](https://docs.crawlapi.dev/cli.md) Scrape X posts and YouTube URLs straight from your terminal.
