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

# Extract Markdown

> Read a page as Markdown with optional metadata and output limits.

With a [running session](https://docs.tilion.dev/guides/create-browser.md), call `POST /v1/extract` and select the output formats. These examples use `TILION_API_KEY` and `TILION_SESSION_ID` from your environment.

```python Python theme={"dark"}
import os
import requests

response = requests.post(
    "https://back.tilion.dev/v1/extract",
    headers={"Authorization": f"Bearer {os.environ['TILION_API_KEY']}"},
    json={
        "session_id": os.environ["TILION_SESSION_ID"],
        "url": "https://example.com/",
        "formats": ["markdown", "metadata"], "max_chars": 1200,
    }, timeout=70,
)
response.raise_for_status()
page = response.json()
if page.get("status") != "ok":
    raise RuntimeError(page)
print(page["markdown"])
print("Truncated:", page.get("truncated"))
```

```javascript Node.js theme={"dark"}
const response = await fetch("https://back.tilion.dev/v1/extract", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TILION_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    session_id: process.env.TILION_SESSION_ID,
    url: "https://example.com/",
    formats: ["markdown", "metadata"], max_chars: 1200,
  }), signal: AbortSignal.timeout(70_000),
});
if (!response.ok) throw new Error(await response.text());
const page = await response.json();
if (page.status !== "ok") throw new Error(JSON.stringify(page));
console.log(page.markdown);
console.log("Truncated:", page.truncated);
```

```bash curl theme={"dark"}
# Requires jq.
curl --fail-with-body https://back.tilion.dev/v1/extract \
  -H "Authorization: Bearer $TILION_API_KEY" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg sid "$TILION_SESSION_ID" \
    '{session_id: $sid, url: "https://example.com/", \
      formats: ["markdown", "metadata"], max_chars: 1200}')"
```

The response contains `markdown`, `metadata`, and `truncated`. `max_chars` limits output at a block boundary. Set `links` to `"none"` to remove link URLs or `include_images` to `false` to omit images.

> [!NOTE]
>
> Structured extraction with `schema` or `prompt` currently returns `501 structured_extraction_unavailable`.

For long requests, set `async_mode: true` and [poll the returned job](https://docs.tilion.dev/guides/read-page.md). For a single page without an existing session, use [`POST /v1/scrape`](https://docs.tilion.dev/reading/scrape-crawl).

The session remains open after extraction. Close it when finished. See the [extract reference](https://docs.tilion.dev/reading/extract.md) for all response and error fields.


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