# SVG Optimizer API
> Shrink and clean SVG files automatically with SVGO, the industry-standard SVG optimiser. The optimize endpoint strips comments, metadata, editor cruft and redundant attributes, collapses and merges paths, and returns minified markup together with the original and optimised byte sizes and the percentage saved — typically 30-60% smaller. The data-uri endpoint goes one step further and returns a ready-to-paste CSS data URI (URL-encoded or base64) plus the matching background-image rule, so you can inline icons without an extra HTTP request. Perfect for build pipelines, icon systems, design tooling, email and embedding SVGs in CSS. Pure local processing — no key, no third-party service, instant; send markup via POST for large files (up to 2 MB). Live, nothing stored. 3 endpoints. Distinct from raster image compression, QR/code generation and JSON/HTML formatting.

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

## Pricing
- **Free** (Free) — 960 calls/Mo, 2 req/s
- **Starter** ($2/Mo) — 8,100 calls/Mo, 8 req/s
- **Pro** ($21/Mo) — 135,000 calls/Mo, 20 req/s
- **Mega** ($57/Mo) — 695,000 calls/Mo, 50 req/s

## Endpoints

### SVG

#### `GET /v1/datauri` — SVG to CSS data URI

**Parameters:**
- `svg` (query, required, string) — SVG markup Example: `<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><!-- icon --><rect x="0" y="0" width="100" height="100" fill="#ff0000"/></svg>`
- `encoding` (query, optional, string) — uri|base64 (default uri) Example: `uri`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/svgo-api/v1/datauri?svg=%3Csvg+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22+width%3D%22100%22+height%3D%22100%22%3E%3C%21--+icon+--%3E%3Crect+x%3D%220%22+y%3D%220%22+width%3D%22100%22+height%3D%22100%22+fill%3D%22%23ff0000%22%2F%3E%3C%2Fsvg%3E&encoding=uri"
```

**Response:**
```json
{
    "data": {
        "css": "background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cpath fill='red' d='M0 0h100v100H0z'/%3E%3C/svg%3E\");",
        "datauri": "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cpath fill='red' d='M0 0h100v100H0z'/%3E%3C/svg%3E",
        "encoding": "uri",
        "optimized_bytes": 109
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:47.361Z",
        "request_id": "b6c55ece-4955-4cab-b44d-73caf33b94ae"
    },
    "status": "ok",
    "message": "SVG to CSS data URI",
    "success": true
}
```

#### `GET /v1/optimize` — Optimize SVG markup

**Parameters:**
- `svg` (query, required, string) — SVG markup Example: `<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><!-- icon --><rect x="0" y="0" width="100" height="100" fill="#ff0000"/></svg>`
- `multipass` (query, optional, string) — true/false (default true) Example: `true`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/svgo-api/v1/optimize?svg=%3Csvg+xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22+width%3D%22100%22+height%3D%22100%22%3E%3C%21--+icon+--%3E%3Crect+x%3D%220%22+y%3D%220%22+width%3D%22100%22+height%3D%22100%22+fill%3D%22%23ff0000%22%2F%3E%3C%2Fsvg%3E&multipass=true"
```

**Response:**
```json
{
    "data": {
        "multipass": true,
        "optimized": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"100\" height=\"100\"><path fill=\"red\" d=\"M0 0h100v100H0z\"/></svg>",
        "saved_bytes": 34,
        "saved_percent": 23.8,
        "original_bytes": 143,
        "optimized_bytes": 109
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:47.486Z",
        "request_id": "96b27d68-7100-45e9-b086-7e510065f5dc"
    },
    "status": "ok",
    "message": "Optimize SVG markup",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "SVG Optimizer API",
        "notes": "Max input 2 MB. Uses SVGO's default preset (removes comments, metadata, redundant attributes; merges paths). Send markup via POST for large files.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/optimize",
                "params": {
                    "svg": "SVG markup (required)",
                    "multipass": "true/false, default true"
                },
                "returns": "optimised SVG + byte sizes + savings"
            },
            {
                "path": "/v1/datauri",
                "params": {
                    "svg": "SVG markup (required)",
                    "encoding": "uri|base64 (default uri)",
                    "multipass": "default true"
                },
                "returns": "a data: URI + ready CSS rule"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Minify and clean SVG markup with SVGO, and turn an SVG into a CSS-ready data URI. Pure local, no key."
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:47.593Z",
        "request_id": "357f8ba3-dff6-41b4-a907-a2fcd6d77262"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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