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

# Output formats

> Markdown, screenshot, PDF, CSV, and HTML output reference.

# Output formats

The scrape endpoint returns content in five formats. Choose with the `output` field;
`markdown` is the default.

| Format         | `output` value | Description                      | Response `data` shape                 |
| -------------- | -------------- | -------------------------------- | ------------------------------------- |
| Clean Markdown | `markdown`     | LLM-optimized Markdown (default) | `{title, markdown, character_count}`  |
| Screenshot     | `screenshot`   | Base64 PNG/JPEG                  | `{data, format, size_bytes}`          |
| PDF            | `pdf`          | Base64 PDF                       | `{data, format: "pdf", size_bytes}`   |
| CSV            | `csv`          | Table extraction                 | `{format, tables, table_count, data}` |
| Clean HTML     | `html`         | Sanitized HTML                   | `{html, format, size_bytes}`          |

## Markdown

The default. Raw HTML is cleaned (scripts, styles, nav, ads, trackers removed), run
through a readability extraction, and converted to ATX-style Markdown.

```json Response theme={null}
{
  "status": 200,
  "url": "https://example.com",
  "output": "markdown",
  "data": {
    "title": "Example Domain",
    "markdown": "Example Domain\n\nThis domain is for use in illustrative examples...",
    "character_count": 239
  }
}
```

## Screenshot

Base64-encoded PNG (or JPEG). Visual outputs automatically enable media/CSS loading
for correct rendering.

| Option             | Default | Description                  |
| ------------------ | ------- | ---------------------------- |
| `format`           | `png`   | `png` or `jpeg`              |
| `full_page`        | `true`  | Full-page capture (PNG only) |
| `width` / `height` | —       | Explicit viewport dimensions |
| `quality`          | `90`    | JPEG quality (0–100)         |

```bash theme={null}
curl -X POST https://api.tazpal.com/v1/scrape \
  -H "Authorization: Bearer baas_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "output": "screenshot", "options": {"format": "jpeg", "quality": 85}}'
```

```json Response theme={null}
{
  "output": "screenshot",
  "data": { "data": "/9j/4AAQSkZJRg...", "format": "jpeg", "size_bytes": 62104 }
}
```

<Tip>
  Decode the base64 payload to save the file: `echo "$B64" | base64 -d > page.png`.
</Tip>

## PDF

Base64-encoded PDF. Uses native `page.pdf()` when available, with a
screenshot-to-PDF fallback for Firefox-based engines (Camoufox).

| Option             | Description                            |
| ------------------ | -------------------------------------- |
| `format`           | Page size (`A4`, `Letter`, …)          |
| `landscape`        | Landscape orientation                  |
| `print_background` | Print background graphics              |
| `scale`            | Render scale (e.g. `0.8`)              |
| `margin`           | `{top, bottom, left, right}` in points |

```bash theme={null}
curl -X POST https://api.tazpal.com/v1/scrape \
  -H "Authorization: Bearer baas_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "output": "pdf", "options": {"format": "A4", "landscape": true}}'
```

```json Response theme={null}
{
  "output": "pdf",
  "data": { "data": "JVBERi0xLjQK...", "format": "pdf", "size_bytes": 41092 }
}
```

## CSV

Extracts `<table>` elements to CSV strings, honoring `rowspan`/`colspan`. Multiple
tables are separated by blank lines.

| Option           | Default | Description                        |
| ---------------- | ------- | ---------------------------------- |
| `table_selector` | `table` | CSS selector for tables to extract |

```bash theme={null}
curl -X POST https://api.tazpal.com/v1/scrape \
  -H "Authorization: Bearer baas_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/stats", "output": "csv", "options": {"table_selector": "table.data"}}'
```

```json Response theme={null}
{
  "output": "csv",
  "data": {
    "format": "csv",
    "tables": ["Name,Price\nWidget,19.99\nGadget,9.99"],
    "table_count": 1,
    "data": "Name,Price\nWidget,19.99\nGadget,9.99"
  }
}
```

## Clean HTML

Sanitized HTML with scripts, styles, ads, cookie banners, social buttons, trackers,
and `javascript:` URLs stripped. Event-handler and tracking attributes are removed.

```bash theme={null}
curl -X POST https://api.tazpal.com/v1/scrape \
  -H "Authorization: Bearer baas_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "output": "html"}'
```

```json Response theme={null}
{
  "output": "html",
  "data": { "html": "<html><body>...", "format": "html", "size_bytes": 15234 }
}
```
