# Highlight API
> Highlight search terms in text. The highlight endpoint wraps every match of one or more terms in a marker — defaulting to <mark>…</mark>, or any open/close strings you choose (** for Markdown, ANSI codes for the terminal, a CSS span, anything) — and returns the marked-up text and a match count. The snippets endpoint returns short excerpts of the surrounding context around each match, the way a search-results page shows where your query appears. Matching is case-insensitive by default with optional whole-word mode, and terms are matched literally (regex characters are safely escaped). Perfect for search results and in-page find, keyword spotting, log review and document previews. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. Distinct from search, summarization and diff APIs.

## 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/highlight-api/..."
```

## Pricing
- **Free** (Free) — 1,215 calls/Mo, 2 req/s
- **Starter** ($3/Mo) — 10,550 calls/Mo, 8 req/s
- **Pro** ($22/Mo) — 156,500 calls/Mo, 20 req/s
- **Mega** ($60/Mo) — 825,000 calls/Mo, 50 req/s

## Endpoints

### Highlight

#### `GET /v1/highlight` — Highlight terms in text

**Parameters:**
- `text` (query, required, string) — Text to search Example: `The quick brown fox jumps over the lazy dog`
- `query` (query, required, string) — Term or comma-separated terms Example: `fox,dog`
- `open` (query, optional, string) — Marker start (default <mark>)
- `close` (query, optional, string) — Marker end (default </mark>)
- `case_insensitive` (query, optional, string) — true/false (default true)
- `whole_word` (query, optional, string) — true/false

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/highlight-api/v1/highlight?text=The+quick+brown+fox+jumps+over+the+lazy+dog&query=fox%2Cdog"
```

**Response:**
```json
{
    "data": {
        "count": 2,
        "terms": [
            "fox",
            "dog"
        ],
        "highlighted": "The quick brown <mark>fox</mark> jumps over the lazy <mark>dog</mark>"
    },
    "meta": {
        "timestamp": "2026-06-03T09:25:08.672Z",
        "request_id": "4700bb9e-c23f-4cdc-a2b9-efa98c69430b"
    },
    "status": "ok",
    "message": "Highlight terms in text",
    "success": true
}
```

#### `GET /v1/snippets` — Snippets around matches

**Parameters:**
- `text` (query, required, string) — Text to search Example: `The quick brown fox jumps over the lazy dog`
- `query` (query, required, string) — Term or terms Example: `fox`
- `context` (query, optional, string) — Chars of context each side (default 40) Example: `40`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/highlight-api/v1/snippets?text=The+quick+brown+fox+jumps+over+the+lazy+dog&query=fox&context=40"
```

**Response:**
```json
{
    "data": {
        "count": 1,
        "terms": [
            "fox"
        ],
        "snippets": [
            {
                "match": "fox",
                "start": 16,
                "snippet": "The quick brown <mark>fox</mark> jumps over the lazy dog"
            }
        ]
    },
    "meta": {
        "timestamp": "2026-06-03T09:25:08.773Z",
        "request_id": "0f6f38cb-a48d-4cb8-bacf-3e7b0ec0e0e0"
    },
    "status": "ok",
    "message": "Snippets around matches",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/highlight-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "name": "Highlight API",
        "notes": "Terms are matched literally (regex characters are escaped). The markers are inserted as-is — pick HTML-safe markers if you will render the result as HTML. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/highlight",
                "params": {
                    "open": "marker start (default <mark>)",
                    "text": "the text (required)",
                    "close": "marker end (default </mark>)",
                    "query": "a term or comma-separated terms (required)",
                    "whole_word": "true/false",
                    "case_insensitive": "default true"
                },
                "returns": "the highlighted text and match count"
            },
            {
                "path": "/v1/snippets",
                "params": {
                    "text": "the text (required)",
                    "query": "terms (required)",
                    "context": "chars of context each side (default 40)"
                },
                "returns": "a snippet around each match"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Highlight one or more search terms in text by wrapping every match in a marker (defaults to <mark>…</mark>, or any open/close strings you choose), and ex
…(truncated, see openapi.json for full schema)
```


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