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

**Response:**
```json
{
    "data": {
        "schema": {
            "type": "object",
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "required": [
                "id",
                "name",
                "email",
                "age",
                "tags",
                "address"
            ],
            "properties": {
                "id": {
                    "type": "string",
                    "format": "uuid"
                },
                "age": {
                    "type": "integer"
                },
                "name": {
                    "type": "string"
                },
                "tags": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "email": {
                    "type": "string",
                    "format": "email"
                },
                "address": {
                    "type": "object",
                    "required": [
                        "city"
                    ],
                    "properties": {
                        "city": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    },
    "meta": {
        "timestamp": "2026-06-01T23:40:43.723Z",
        "request_id": "c05b17de-8632-4242-a781-e2f13828f84d"
    },
    "status": "ok",
    "message": "Schema inferred",
    "success": tru
…(truncated, see openapi.json for full schema)
```

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

**Response:**
```json
{
    "data": {
        "root": "Root",
        "typescript": "interface Address {\n  city: string;\n}\n\ninterface Root {\n  id: string;\n  name: string;\n  email: string;\n  age: number;\n  tags: string[];\n  address: Address;\n}"
    },
    "meta": {
        "timestamp": "2026-06-01T23:40:43.824Z",
        "request_id": "520a3d60-3c7d-4447-b146-8365259eba71"
    },
    "status": "ok",
    "message": "TypeScript inferred",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "note": "Infer a schema or types from a sample JSON document — the fastest way to get a contract out of an example API response. /v1/schema returns a JSON Schema (Draft 2020-12) with detected types, required keys, array item schemas (merged across elements) and string formats (email, uri, uuid, date-time, date, ipv4). /v1/typescript returns ready-to-paste TypeScript interfaces with named nested interfaces, arrays, unions for mixed types and structural de-duplication. Supply the sample via ?json=, a query parameter or a request body. Everything is computed locally with no network calls. Ideal for scaffolding types from real API responses, generating validation schemas, documentation and contract testing. A JSON type/schema inferer — distinct from JSON-Schema validation (jsonschema), JSON pretty-print/convert (json) and JSON diff/patch (jsondiff). No key, no cache.",
        "outputs": [
            "JSON Schema (Draft 2020-12)",
            "TypeScript interfaces"
        ],
        "endpoints": [
            "/v1/schema",
            "/v1/typescript",
            "/v1/meta"
        ],
        "detected_string_formats": [
            "email",
            "uri",
            "uuid",
            "date-time",
            "date",
            "ipv4"
        ]
    },
    "meta": {
        "timestamp": "2026-06-01T23:40:43.899Z",
        "request_id": "2285c6b0-f632-46e0-91d8-db851f294dc4"
    },
    "status": "ok",
    "message": "Meta retrieved",
    "suc
…(truncated, see openapi.json for full schema)
```


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