# HTML API
> A fast, fully-local HTML toolkit: extract structured data from supplied HTML (title, meta description, canonical link, language, Open Graph and Twitter card tags, links, images, headings and word counts), convert HTML to readable plain text, list all links resolved against a base URL, and sanitize HTML with a strict allowlist (scripts, iframes, inline event handlers, javascript: URLs and unknown tags are stripped). It works on the HTML you send and never fetches URLs (for live link previews see the oanor URL Tools API). Input via the query string or the request body, up to 2 MB. Pure server-side compute, no third-party upstream, so responses are instant and always available. Ideal for scrapers and data pipelines, comment and email sanitization, RAG and content extraction, and CMS tooling.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/html-api/..."
```

## Pricing
- **Free** (Free) — 6,000 calls/Mo, 2 req/s
- **Basic** ($5/Mo) — 140,000 calls/Mo, 8 req/s
- **Pro** ($17/Mo) — 900,000 calls/Mo, 25 req/s
- **Mega** ($48/Mo) — 5,000,000 calls/Mo, 80 req/s

## Endpoints

### HTML

#### `GET /v1/extract` — Extract structured data

**Parameters:**
- `html` (query, required, string) — HTML markup Example: `<html><head><title>Example</title></head><body><h1>Hi</h1><a href="/about">About</a></body></html>`
- `base_url` (query, optional, string) — Base URL to resolve relative links Example: `https://example.com`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/html-api/v1/extract?html=%3Chtml%3E%3Chead%3E%3Ctitle%3EExample%3C%2Ftitle%3E%3C%2Fhead%3E%3Cbody%3E%3Ch1%3EHi%3C%2Fh1%3E%3Ca+href%3D%22%2Fabout%22%3EAbout%3C%2Fa%3E%3C%2Fbody%3E%3C%2Fhtml%3E&base_url=https%3A%2F%2Fexample.com"
```

**Response:**
```json
{
    "data": {
        "lang": null,
        "links": [
            {
                "href": "https://example.com/about",
                "text": "About"
            }
        ],
        "title": "Example",
        "counts": {
            "links": 1,
            "words": 1,
            "images": 0,
            "headings": 1
        },
        "images": [],
        "twitter": [],
        "headings": [
            {
                "text": "Hi",
                "level": 1
            }
        ],
        "canonical": null,
        "open_graph": [],
        "description": null
    },
    "meta": {
        "timestamp": "2026-05-30T09:00:22.850Z",
        "request_id": "b62f3f51-8ae9-48f5-8d0f-bad8d2a7438e"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/links` — List links

**Parameters:**
- `html` (query, required, string) — HTML markup Example: `<html><head><title>Example</title></head><body><h1>Hi</h1><a href="/about">About</a></body></html>`
- `base_url` (query, optional, string) — Base URL Example: `https://example.com`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/html-api/v1/links?html=%3Chtml%3E%3Chead%3E%3Ctitle%3EExample%3C%2Ftitle%3E%3C%2Fhead%3E%3Cbody%3E%3Ch1%3EHi%3C%2Fh1%3E%3Ca+href%3D%22%2Fabout%22%3EAbout%3C%2Fa%3E%3C%2Fbody%3E%3C%2Fhtml%3E&base_url=https%3A%2F%2Fexample.com"
```

**Response:**
```json
{
    "data": {
        "count": 1,
        "links": [
            {
                "rel": null,
                "href": "https://example.com/about",
                "text": "About"
            }
        ]
    },
    "meta": {
        "timestamp": "2026-05-30T09:00:22.926Z",
        "request_id": "27b26579-6bb9-4936-822a-8dd8cec69701"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/sanitize` — Sanitize HTML

**Parameters:**
- `html` (query, required, string) — HTML markup Example: `<p onclick="x()">Hi<script>bad()</script></p>`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/html-api/v1/sanitize?html=%3Cp+onclick%3D%22x%28%29%22%3EHi%3Cscript%3Ebad%28%29%3C%2Fscript%3E%3C%2Fp%3E"
```

**Response:**
```json
{
    "data": {
        "html": "<p>Hi</p>",
        "length": 9
    },
    "meta": {
        "timestamp": "2026-05-30T09:00:22.997Z",
        "request_id": "67d3bc59-668f-4984-ba92-9dadf3809203"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/text` — HTML to plain text

**Parameters:**
- `html` (query, required, string) — HTML markup Example: `<html><head><title>Example</title></head><body><h1>Hi</h1><a href="/about">About</a></body></html>`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/html-api/v1/text?html=%3Chtml%3E%3Chead%3E%3Ctitle%3EExample%3C%2Ftitle%3E%3C%2Fhead%3E%3Cbody%3E%3Ch1%3EHi%3C%2Fh1%3E%3Ca+href%3D%22%2Fabout%22%3EAbout%3C%2Fa%3E%3C%2Fbody%3E%3C%2Fhtml%3E"
```

**Response:**
```json
{
    "data": {
        "text": "Hi\nAbout",
        "length": 8
    },
    "meta": {
        "timestamp": "2026-05-30T09:00:23.062Z",
        "request_id": "aeccb657-806a-42cd-80f4-78001998eb4d"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/html-api
OpenAPI spec: https://www.oanor.com/api/html-api/openapi.json
