# YAML API
> Convert, validate and tidy YAML through a fast, fully-local API. Turn YAML into JSON (including multi-document streams) or JSON into clean YAML with optional key sorting and custom indentation, validate a document and get the exact line and column of any syntax error with a context snippet, or reformat and normalize existing YAML. Inputs can be sent as a raw text/plain body, a JSON field or a query parameter; outputs are tidy JSON. Pure server-side compute with no third-party upstream, so responses are instant and the service is always available. Ideal for DevOps and CI/CD, configuration and infrastructure-as-code tooling, no-code platforms, editors 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/yaml-api/..."
```

## Pricing
- **Free** (Free) — 1,000 calls/Mo, 2 req/s
- **Basic** ($4/Mo) — 60,000 calls/Mo, 8 req/s
- **Pro** ($11/Mo) — 400,000 calls/Mo, 20 req/s
- **Mega** ($31/Mo) — 2,000,000 calls/Mo, 50 req/s

## Endpoints

### YAML

#### `GET /v1/format` — Format / normalize YAML

**Parameters:**
- `yaml` (query, required, string) — YAML document Example: `{b: 2, a: 1}`
- `sort_keys` (query, optional, string) — Sort keys (true/false) Example: `true`
- `indent` (query, optional, string) — Indent 1-10 Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/yaml-api/v1/format?yaml=%7Bb%3A+2%2C+a%3A+1%7D&sort_keys=true&indent=2"
```

**Response:**
```json
{
    "data": {
        "yaml": "a: 1\nb: 2\n",
        "documents": 1
    },
    "meta": {
        "timestamp": "2026-05-30T18:16:53.767Z",
        "request_id": "bb9c5cc2-d621-4138-9c4d-4bc1f2dff440"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

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

**Parameters:**
- `yaml` (query, required, string) — YAML document (raw text body, field or query) Example: `{name: Ada, age: 36, tags: [a, b]}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/yaml-api/v1/to-json?yaml=%7Bname%3A+Ada%2C+age%3A+36%2C+tags%3A+%5Ba%2C+b%5D%7D"
```

**Response:**
```json
{
    "data": {
        "json": {
            "age": 36,
            "name": "Ada",
            "tags": [
                "a",
                "b"
            ]
        },
        "documents": 1
    },
    "meta": {
        "timestamp": "2026-05-30T18:16:53.843Z",
        "request_id": "c3de528c-4be5-4218-8df7-7b2291a17bac"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

#### `GET /v1/to-yaml` — JSON to YAML

**Parameters:**
- `json` (query, required, string) — JSON value (object or string) Example: `{"server":{"host":"x","ports":[80,443]}}`
- `sort_keys` (query, optional, string) — Sort keys (true/false) Example: `true`
- `indent` (query, optional, string) — Indent 1-10 (default 2) Example: `2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/yaml-api/v1/to-yaml?json=%7B%22server%22%3A%7B%22host%22%3A%22x%22%2C%22ports%22%3A%5B80%2C443%5D%7D%7D&sort_keys=true&indent=2"
```

**Response:**
```json
{
    "data": {
        "yaml": "server:\n  host: x\n  ports:\n    - 80\n    - 443\n"
    },
    "meta": {
        "timestamp": "2026-05-30T18:16:53.921Z",
        "request_id": "6d40377b-5362-4be8-bebb-5964f0d7f458"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```

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

**Parameters:**
- `yaml` (query, required, string) — YAML document Example: `{name: Ada, age: 36, tags: [a, b]}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/yaml-api/v1/validate?yaml=%7Bname%3A+Ada%2C+age%3A+36%2C+tags%3A+%5Ba%2C+b%5D%7D"
```

**Response:**
```json
{
    "data": {
        "valid": true,
        "documents": 1
    },
    "meta": {
        "timestamp": "2026-05-30T18:16:53.995Z",
        "request_id": "898272d4-1945-4435-b5a7-d09b576fb0a8"
    },
    "status": "ok",
    "message": "OK",
    "success": true
}
```


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