# 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"
```

#### `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"
```

### Meta

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

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


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