# XML API
> A fast, fully-local XML toolkit: convert XML to JSON and JSON to XML with configurable attribute handling, validate XML well-formedness with line and column error details, and pretty-print XML while preserving element order. Every endpoint accepts 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 system integrations, SOAP and legacy interop, RSS and sitemap processing, config tooling and data pipelines.

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

## Pricing
- **Free** (Free) — 13,000 calls/Mo, 2 req/s
- **Basic** ($3/Mo) — 280,000 calls/Mo, 12 req/s
- **Pro** ($13/Mo) — 1,500,000 calls/Mo, 40 req/s
- **Mega** ($34/Mo) — 7,500,000 calls/Mo, 120 req/s

## Endpoints

### XML

#### `GET /v1/format` — Pretty-print XML

**Parameters:**
- `xml` (query, required, string) — XML markup Example: `<a><b>1</b><c x="2">3</c></a>`
- `indent` (query, optional, string) — Indent 0-8 (default 2) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/xml-api/v1/format?xml=%3Ca%3E%3Cb%3E1%3C%2Fb%3E%3Cc+x%3D%222%22%3E3%3C%2Fc%3E%3C%2Fa%3E&indent=2"
```

**Response:**
```json
{
    "data": {
        "xml": "<a>\n  <b>1</b>\n  <c x=\"2\">3</c>\n</a>"
    },
    "meta": {
        "timestamp": "2026-05-30T10:10:57.251Z",
        "request_id": "b7275c2a-1e07-42c4-9dd9-f01f7750f368"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/to-json` — XML to JSON

**Parameters:**
- `xml` (query, required, string) — XML markup Example: `<note><to>Tove</to><body>Hi</body></note>`
- `attributes` (query, optional, string) — Include attributes (default true) Example: `true`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/xml-api/v1/to-json?xml=%3Cnote%3E%3Cto%3ETove%3C%2Fto%3E%3Cbody%3EHi%3C%2Fbody%3E%3C%2Fnote%3E&attributes=true"
```

**Response:**
```json
{
    "data": {
        "json": {
            "note": {
                "to": "Tove",
                "body": "Hi"
            }
        }
    },
    "meta": {
        "timestamp": "2026-05-30T10:10:57.327Z",
        "request_id": "5249a990-00ba-43e8-a2e1-64f4ba2bea54"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/to-xml` — JSON to XML

**Parameters:**
- `json` (query, required, string) — JSON object Example: `{"note":{"to":"Tove","body":"Hi"}}`
- `indent` (query, optional, string) — Indent 0-8 (default 2) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/xml-api/v1/to-xml?json=%7B%22note%22%3A%7B%22to%22%3A%22Tove%22%2C%22body%22%3A%22Hi%22%7D%7D&indent=2"
```

**Response:**
```json
{
    "data": {
        "xml": "<note>\n  <to>Tove</to>\n  <body>Hi</body>\n</note>"
    },
    "meta": {
        "timestamp": "2026-05-30T10:10:57.400Z",
        "request_id": "e23c5560-afb9-4c4b-be3f-b155fa98c800"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/validate` — Validate XML

**Parameters:**
- `xml` (query, required, string) — XML markup Example: `<a><b/></a>`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/xml-api/v1/validate?xml=%3Ca%3E%3Cb%2F%3E%3C%2Fa%3E"
```

**Response:**
```json
{
    "data": {
        "error": null,
        "valid": true
    },
    "meta": {
        "timestamp": "2026-05-30T10:10:57.481Z",
        "request_id": "639c1526-78ae-4058-8136-c1d898c4bc32"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```


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