# JSON Types API
> Infer a schema or types from a sample JSON document — the fastest way to get a contract out of an example API response. Pass a JSON sample and the schema endpoint returns a JSON Schema (Draft 2020-12) with detected types, required keys, array item schemas merged across elements, and recognised string formats (email, uri, uuid, date-time, date, ipv4); the typescript endpoint returns ready-to-paste TypeScript interfaces with named nested interfaces, typed arrays, unions for mixed-shape array elements and structural de-duplication. Supply the sample inline via ?json=, as a query parameter, or as a request body. Everything is computed locally with no network calls, so it is fast and deterministic. Built for scaffolding types from real API responses, generating validation schemas, documentation, contract testing and code generation. A JSON type/schema inferer — distinct from JSON-Schema validation (jsonschema), JSON pretty-printing and conversion (json), and JSON diff/patch (jsondiff). 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/jsontypes-api/..."
```

## Pricing
- **Free** (Free) — 2,140 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 41,500 calls/Mo, 8 req/s
- **Pro** ($21/Mo) — 218,000 calls/Mo, 20 req/s
- **Mega** ($53/Mo) — 825,000 calls/Mo, 50 req/s

## Endpoints

### JSON Types

#### `GET /v1/schema` — Infer a JSON Schema

**Parameters:**
- `json` (query, required, string) — JSON sample (inline or body) Example: `{"id":"a1b2c3d4-e5f6-7890-abcd-ef1234567890","name":"Ada","email":"ada@example.com","age":36,"tags":["x","y"],"address":{"city":"London"}}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/jsontypes-api/v1/schema?json=%7B%22id%22%3A%22a1b2c3d4-e5f6-7890-abcd-ef1234567890%22%2C%22name%22%3A%22Ada%22%2C%22email%22%3A%22ada%40example.com%22%2C%22age%22%3A36%2C%22tags%22%3A%5B%22x%22%2C%22y%22%5D%2C%22address%22%3A%7B%22city%22%3A%22London%22%7D%7D"
```

#### `GET /v1/typescript` — Infer TypeScript interfaces

**Parameters:**
- `json` (query, required, string) — JSON sample (inline or body) Example: `{"id":"a1b2c3d4-e5f6-7890-abcd-ef1234567890","name":"Ada","email":"ada@example.com","age":36,"tags":["x","y"],"address":{"city":"London"}}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/jsontypes-api/v1/typescript?json=%7B%22id%22%3A%22a1b2c3d4-e5f6-7890-abcd-ef1234567890%22%2C%22name%22%3A%22Ada%22%2C%22email%22%3A%22ada%40example.com%22%2C%22age%22%3A36%2C%22tags%22%3A%5B%22x%22%2C%22y%22%5D%2C%22address%22%3A%7B%22city%22%3A%22London%22%7D%7D"
```

### Meta

#### `GET /v1/meta` — Outputs & detected formats

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


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