# CBOR API
> Encode and decode CBOR (RFC 8949, Concise Binary Object Representation) — the IETF-standard binary data format behind COSE, WebAuthn/FIDO2, the EU Digital COVID Certificate, and many IoT and constrained-device protocols. The encode endpoint turns a JSON value into compact, definite-length CBOR, choosing the smallest head for each integer, string, array and map; the decode endpoint parses CBOR back into a JSON value. It implements the spec across all major types — unsigned and negative integers of every width, byte and text strings (including indefinite-length chunked strings), arrays, maps, tags, the simple values false/true/null, and half-, single- and double-precision floats — and rejects trailing or truncated data rather than silently mangling it. Byte strings and any non-UTF-8 text come back losslessly as {"_bytes_hex":"…"}, tags as {"_tag":{"tag":N,"value":…}}, non-finite floats as {"_float":"NaN|Infinity|-Infinity"}, and other simple values as {"_simple":N}, so encode and decode round-trip exactly. Bytes are exchanged as both hex and base64 so they survive any transport. Everything is computed locally and deterministically, so it is instant and private. Ideal for debugging CBOR, COSE and WebAuthn payloads, bridging JSON and CBOR systems, IoT and smart-card pipelines, and teaching the format. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is CBOR specifically; for MessagePack use the MessagePack API, for BitTorrent's Bencode use the Bencode API, for JSON, YAML, TOML or XML use those format APIs, and for base64, hex, URL or HTML encoding use a general encoding API.

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

## Pricing
- **Free** (Free) — 5,535 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 15,050 calls/Mo, 8 req/s
- **Pro** ($27/Mo) — 201,500 calls/Mo, 20 req/s
- **Mega** ($65/Mo) — 1,050,000 calls/Mo, 50 req/s

## Endpoints

### CBOR

#### `GET /v1/decode` — Decode CBOR to a JSON value

**Parameters:**
- `hex` (query, optional, string) — The CBOR bytes as hex Example: `a26161016162820203`
- `base64` (query, optional, string) — Or the bytes as base64

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cbor-api/v1/decode?hex=a26161016162820203"
```

**Response:**
```json
{
    "data": {
        "bytes": 9,
        "value": {
            "a": 1,
            "b": [
                2,
                3
            ]
        }
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:17.102Z",
        "request_id": "30ef7d2a-8dfc-4c38-86b7-0d8abef59bcb"
    },
    "status": "ok",
    "message": "Decode from CBOR",
    "success": true
}
```

#### `GET /v1/encode` — Encode a JSON value to CBOR

**Parameters:**
- `json` (query, required, string) — A JSON value to encode Example: `{"a":1,"b":[2,3]}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cbor-api/v1/encode?json=%7B%22a%22%3A1%2C%22b%22%3A%5B2%2C3%5D%7D"
```

**Response:**
```json
{
    "data": {
        "hex": "a26161016162820203",
        "bytes": 9,
        "base64": "omFhAWFiggID"
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:17.205Z",
        "request_id": "17bbac2b-2db5-448e-9e5b-cc497d6e193e"
    },
    "status": "ok",
    "message": "Encode to CBOR",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "CBOR API",
        "notes": "Encode emits definite-length items and float64 for non-integers; decode also accepts indefinite-length strings/arrays/maps and half/single floats. 64-bit integers beyond 2^53 decode to a decimal string. CBOR map keys that aren't text strings are stringified in the JSON output. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/encode",
                "params": {
                    "json": "a JSON value to encode (string)"
                },
                "returns": "the CBOR bytes as hex and base64, with byte length"
            },
            {
                "path": "/v1/decode",
                "params": {
                    "hex": "the CBOR bytes as hex",
                    "base64": "or as base64"
                },
                "returns": "the decoded JSON value"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Encode and decode CBOR (RFC 8949, Concise Binary Object Representation) — the IETF-standard binary data format behind COSE, WebAuthn/FIDO2, the EU Digital COVID Certificate, and many IoT and constrained-device protocols. The encode endpoint turns a JSON value into compact, definite-length CBOR, choosing the smallest head for each integer, string, array and map; the decode endpoint parses CBOR ba
…(truncated, see openapi.json for full schema)
```


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