# JSON Diff & Patch API
> Compare and patch JSON documents to RFC standards. Pass two documents and the service returns whether they are equal, an RFC 6902 JSON Patch (the precise add/remove/replace operations that turn the first into the second, using RFC 6901 JSON-Pointer paths), a change summary, and an RFC 7386 JSON Merge Patch. The patch endpoint goes the other way: apply an RFC 6902 patch (add, remove, replace, move, copy and test operations) or an RFC 7386 merge patch to a document and get the result. Documents can be sent inline or as a JSON body. Everything is computed locally with no network calls, so it is fast and deterministic. Built for configuration and state management, API change detection, audit trails and change logs, optimistic-concurrency checks and data-sync pipelines. A JSON diff/patch engine — distinct from text diffing (textdiff), JSONPath querying (jsonpath), JSON validation and pretty-printing (json) and JSON-Schema validation (jsonschema). No upstream key, no cache.

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

## Pricing
- **Free** (Free) — 2,260 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 44,500 calls/Mo, 8 req/s
- **Pro** ($21/Mo) — 230,000 calls/Mo, 20 req/s
- **Mega** ($55/Mo) — 855,000 calls/Mo, 50 req/s

## Endpoints

### JSON Diff & Patch

#### `GET /v1/diff` — Diff two JSON docs → patch

**Parameters:**
- `a` (query, required, string) — First JSON document (inline or body) Example: `{"x":1,"y":2}`
- `b` (query, required, string) — Second JSON document Example: `{"x":1,"y":3}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/jsondiff-api/v1/diff?a=%7B%22x%22%3A1%2C%22y%22%3A2%7D&b=%7B%22x%22%3A1%2C%22y%22%3A3%7D"
```

**Response:**
```json
{
    "data": {
        "equal": false,
        "patch": [
            {
                "op": "replace",
                "path": "/y",
                "value": 3
            }
        ],
        "summary": {
            "added": 0,
            "changed": 1,
            "removed": 0
        },
        "merge_patch": {
            "y": 3
        },
        "patch_op_count": 1
    },
    "meta": {
        "timestamp": "2026-06-01T23:40:47.866Z",
        "request_id": "ea1a9f38-d23a-4bef-a69a-83823ec6e338"
    },
    "status": "ok",
    "message": "Diff computed",
    "success": true
}
```

#### `GET /v1/patch` — Apply a patch to a document

**Parameters:**
- `doc` (query, required, string) — JSON document Example: `{"x":1,"y":2}`
- `patch` (query, optional, string) — RFC 6902 operations array Example: `[{"op":"replace","path":"/y","value":9}]`
- `merge_patch` (query, optional, string) — RFC 7386 merge patch (alternative)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/jsondiff-api/v1/patch?doc=%7B%22x%22%3A1%2C%22y%22%3A2%7D&patch=%5B%7B%22op%22%3A%22replace%22%2C%22path%22%3A%22%2Fy%22%2C%22value%22%3A9%7D%5D"
```

**Response:**
```json
{
    "data": {
        "kind": "json_patch",
        "result": {
            "x": 1,
            "y": 9
        },
        "applied": 1
    },
    "meta": {
        "timestamp": "2026-06-01T23:40:47.952Z",
        "request_id": "87b88729-3dcc-493f-bd82-c299a0d95109"
    },
    "status": "ok",
    "message": "Patch applied",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Supported standards

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

**Response:**
```json
{
    "data": {
        "note": "Compare and patch JSON documents. /v1/diff takes two documents (a and b — inline via ?a=&b= or as a JSON body {\"a\":…,\"b\":…}) and returns whether they are equal, an RFC 6902 JSON Patch (the add/remove/replace operations that turn a into b), a change summary and an RFC 7386 JSON Merge Patch. /v1/patch applies a patch to a document: supply {\"doc\":…,\"patch\":[…]} for an RFC 6902 patch (add/remove/replace/move/copy/test with JSON-Pointer paths) or {\"doc\":…,\"merge_patch\":…} for an RFC 7386 merge patch, and get the resulting document. Everything is computed locally with no network calls. Ideal for config and state management, API change detection, audit trails, optimistic-concurrency checks and data-sync pipelines. A JSON diff/patch engine — distinct from text diffing (textdiff), JSONPath querying (jsonpath), JSON validation/pretty-printing (json) and JSON-Schema validation (jsonschema). No key, no cache.",
        "endpoints": [
            "/v1/diff",
            "/v1/patch",
            "/v1/meta"
        ],
        "standards": [
            "RFC 6902 (JSON Patch)",
            "RFC 7386 (JSON Merge Patch)",
            "RFC 6901 (JSON Pointer)"
        ]
    },
    "meta": {
        "timestamp": "2026-06-01T23:40:48.056Z",
        "request_id": "1129011e-0529-492a-9469-10432adea356"
    },
    "status": "ok",
    "message": "Meta retrieved",
    "success": true
}
```


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