# HTML to Markdown (`text.html_to_markdown`)

Convert an HTML document or fragment to clean Markdown (headings, lists, links, tables, code), ready for an LLM prompt.

- **Route:** `POST /v1/run/text.html_to_markdown`
- **Price:** $0.0002 per request ($0.20 per 1,000) · `cost_usd` on every response
- **Source:** GetAllAPIs compute (`compute`) · failover: no
- **Measured latency:** p50 3 ms · p95 3 ms · p99 3 ms (1 calls, 30d)
- **Heavy response:** no

## Input

| Field | Type | Required | Default | Notes |
|---|---|---|---|---|
| `html` | string | yes |  | HTML document or fragment |
| `main_only` | boolean | no | true | Keep only <main>/<article> and drop nav, header, footer, aside and forms |
| `base_url` | string | no |  | Base URL used to make relative links absolute |

## Output (`output` in the run envelope)

| Field | Meaning |
|---|---|
| `markdown` | The Markdown text. |
| `characters` | Length of the Markdown. |
| `words` | Word count of the Markdown. |

## Example

```bash
curl -s -X POST https://getallapis.com/v1/run/text.html_to_markdown \
  -H "Authorization: Bearer $GETALLAPIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<html><body><main><h1>Pricing</h1><p>Pay <strong>per request</strong>. See the <a href=\"/docs\">docs</a>.</p><ul><li>One key</li><li>One wallet</li></ul></main></body></html>","base_url":"https://example.com"}'
```

```python
from getallapis_client import Client
client = Client()  # reads GETALLAPIS_API_KEY
result = client.run('text.html_to_markdown', {'html': '<html><body><main><h1>Pricing</h1><p>Pay <strong>per request</strong>. See the <a href="/docs">docs</a>.</p><ul><li>One key</li><li>One wallet</li></ul></main></body></html>', 'base_url': 'https://example.com'})
print(result['cost_usd'], result['output'])
```

```bash
getallapis run text.html_to_markdown '{"html":"<html><body><main><h1>Pricing</h1><p>Pay <strong>per request</strong>. See the <a href=\"/docs\">docs</a>.</p><ul><li>One key</li><li>One wallet</li></ul></main></body></html>","base_url":"https://example.com"}'
```

Quote first (free, validates input): `POST /v1/quote/text.html_to_markdown` with the same body.
