# Data URI API
> Encode content into a data: URI and decode a data: URI back to its content (RFC 2397). data: URIs inline a file directly into HTML, CSS, JSON or email — perfect for small images, SVG, fonts and icons that you want to embed without a separate HTTP request. The encode endpoint wraps your content (given as UTF-8 text, base64 or hex for binary) with a chosen media type and charset, in either base64 or URL (percent) encoding; the decode endpoint parses any data: URI and returns its media type, charset, whether it was base64, the byte size, and the payload as text and/or base64. Pure local computation — no key, no third-party service, instant; up to 4 MB via POST. Live, nothing stored. 3 endpoints. Distinct from a plain base64/hex encoder and from SVG-specific 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/dataurl-api/..."
```

## Pricing
- **Free** (Free) — 580 calls/Mo, 2 req/s
- **Starter** ($0/Mo) — 4,300 calls/Mo, 8 req/s
- **Pro** ($17/Mo) — 116,000 calls/Mo, 20 req/s
- **Mega** ($53/Mo) — 600,000 calls/Mo, 50 req/s

## Endpoints

### Data URI

#### `GET /v1/decode` — Decode a data: URI

**Parameters:**
- `datauri` (query, required, string) — A data: URI Example: `data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dataurl-api/v1/decode?datauri=data%3Atext%2Fplain%3Bbase64%2CSGVsbG8sIFdvcmxkIQ%3D%3D"
```

**Response:**
```json
{
    "data": {
        "text": "Hello, World!",
        "bytes": 13,
        "base64": "SGVsbG8sIFdvcmxkIQ==",
        "charset": null,
        "is_base64": true,
        "mediatype": "text/plain"
    },
    "meta": {
        "timestamp": "2026-06-03T01:09:46.415Z",
        "request_id": "ecde316d-7238-4b90-b83a-fe42e942ce6e"
    },
    "status": "ok",
    "message": "Decode a data: URI",
    "success": true
}
```

#### `GET /v1/encode` — Encode content to a data: URI

**Parameters:**
- `text` (query, required, string) — Content Example: `Hello, World!`
- `mediatype` (query, optional, string) — e.g. image/png (default text/plain) Example: `text/plain`
- `charset` (query, optional, string) — e.g. utf-8 Example: `utf-8`
- `encoding` (query, optional, string) — base64|url (default base64) Example: `base64`
- `input_encoding` (query, optional, string) — utf8|base64|hex (how text is given)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dataurl-api/v1/encode?text=Hello%2C+World%21&mediatype=text%2Fplain&charset=utf-8&encoding=base64"
```

**Response:**
```json
{
    "data": {
        "bytes": 13,
        "length": 57,
        "charset": "utf-8",
        "datauri": "data:text/plain;charset=utf-8;base64,SGVsbG8sIFdvcmxkIQ==",
        "encoding": "base64",
        "mediatype": "text/plain"
    },
    "meta": {
        "timestamp": "2026-06-03T01:09:46.509Z",
        "request_id": "b38b51e0-9a23-460f-995e-2e503eaee167"
    },
    "status": "ok",
    "message": "Encode content to a data: URI",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Data URI API",
        "notes": "Send binary content as base64 or hex via input_encoding. Max 4 MB. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/encode",
                "params": {
                    "text": "content (required)",
                    "charset": "e.g. utf-8",
                    "encoding": "base64|url (default base64)",
                    "mediatype": "e.g. image/png (default text/plain)",
                    "input_encoding": "utf8|base64|hex (how `text` is given)"
                },
                "returns": "the data: URI"
            },
            {
                "path": "/v1/decode",
                "params": {
                    "datauri": "a data: URI (required)"
                },
                "returns": "mediatype, charset, is_base64, the text and/or base64 payload"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Encode content into a data: URI (RFC 2397) and decode a data: URI back to its content — the inline format used to embed images, fonts, SVG and small files directly in HTML, CSS, JSON and email. Choose base64 or URL (percent) encoding, set the media type and charset. Pure local, no key."
    },
    "meta": {
        "timestamp": "2026-06-03T01:09:46.597Z",
        "request_id": "bedbcd75-f21d-4ad
…(truncated, see openapi.json for full schema)
```


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