# MessagePack API
> Encode and decode MessagePack — the compact binary serialization format ("it's like JSON, but fast and small") used by Redis, Fluentd, many RPC systems and IoT protocols. The encode endpoint turns a JSON value into MessagePack bytes, automatically choosing the smallest representation for each integer, string, array and map; the decode endpoint parses MessagePack back into a JSON value. It implements the full spec — nil, booleans, every fixed and variable integer width, float32 and float64, str and bin, arrays and maps, and the ext family — and rejects trailing or truncated data rather than silently mangling it. Binary (bin) values and any non-UTF-8 string come back losslessly as a {"_bytes_hex":"…"} object, and ext values as {"_ext":{"type":N,"hex":"…"}}, 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 MessagePack payloads, bridging JSON and msgpack systems, RPC and cache tooling, IoT pipelines, and teaching the format. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is MessagePack specifically; for JSON, YAML, TOML or XML use those format APIs, for BitTorrent's Bencode use the Bencode API, 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/msgpack-api/..."
```

## Pricing
- **Free** (Free) — 5,435 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 14,950 calls/Mo, 8 req/s
- **Pro** ($27/Mo) — 200,500 calls/Mo, 20 req/s
- **Mega** ($65/Mo) — 1,045,000 calls/Mo, 50 req/s

## Endpoints

### MessagePack

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

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

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

**Response:**
```json
{
    "data": {
        "bytes": 18,
        "value": {
            "schema": 0,
            "compact": true
        }
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:17.513Z",
        "request_id": "0c266bf9-56a7-4a74-9834-c5bfc0f1b071"
    },
    "status": "ok",
    "message": "Decode from MessagePack",
    "success": true
}
```

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

**Parameters:**
- `json` (query, required, string) — A JSON value to encode Example: `{"compact":true,"schema":0}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/msgpack-api/v1/encode?json=%7B%22compact%22%3Atrue%2C%22schema%22%3A0%7D"
```

**Response:**
```json
{
    "data": {
        "hex": "82a7636f6d70616374c3a6736368656d6100",
        "bytes": 18,
        "base64": "gqdjb21wYWN0w6ZzY2hlbWEA"
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:17.629Z",
        "request_id": "b87b4a87-7400-4ea9-beaf-8984e6454691"
    },
    "status": "ok",
    "message": "Encode to MessagePack",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "MessagePack API",
        "notes": "Integers use the smallest fitting width; 64-bit integers beyond 2^53 decode to a decimal string to avoid precision loss. Map keys are kept in order. bin -> {_bytes_hex}, ext -> {_ext:{type,hex}} round-trip exactly. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/encode",
                "params": {
                    "json": "a JSON value to encode (string)"
                },
                "returns": "the MessagePack bytes as hex and base64, with byte length"
            },
            {
                "path": "/v1/decode",
                "params": {
                    "hex": "the MessagePack bytes as hex",
                    "base64": "or as base64"
                },
                "returns": "the decoded JSON value"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Encode and decode MessagePack — the compact binary serialization format (\"it's like JSON, but fast and small\") used by Redis, Fluentd, many RPC systems and IoT protocols. The encode endpoint turns a JSON value into MessagePack bytes, automatically choosing the smallest representation for each integer, string, array and map; the decode endpoint parses MessagePack back into a JSON value. It implements the full spec — nil, booleans, ev
…(truncated, see openapi.json for full schema)
```


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