# NDJSON API
> Work with NDJSON / JSON Lines — the one-JSON-value-per-line format used by application and audit logs, streaming and LLM responses, jq, BigQuery, Elasticsearch bulk and many data pipelines. The to-array endpoint parses an NDJSON stream into a regular JSON array; to-ndjson does the reverse, turning a JSON array into NDJSON (one compact value per line); and validate checks every line independently, reporting which lines are valid and the exact parse error for any that are not. Blank lines are ignored. Perfect for log processing, ETL, data import/export and stream debugging. Pure local computation — no key, no third-party service, instant; up to 4 MB via POST. Live, nothing stored. 4 endpoints. Distinct from JSON validation/formatting and from CSV tooling.

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

## Pricing
- **Free** (Free) — 1,015 calls/Mo, 2 req/s
- **Starter** ($1/Mo) — 8,550 calls/Mo, 8 req/s
- **Pro** ($20/Mo) — 136,500 calls/Mo, 20 req/s
- **Mega** ($58/Mo) — 720,000 calls/Mo, 50 req/s

## Endpoints

### NDJSON

#### `GET /v1/to-array` — NDJSON to JSON array

**Parameters:**
- `ndjson` (query, required, string) — NDJSON text Example: `{"id":1,"name":"Alice"}
{"id":2,"name":"Bob"}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/ndjson-api/v1/to-array?ndjson=%7B%22id%22%3A1%2C%22name%22%3A%22Alice%22%7D%0A%7B%22id%22%3A2%2C%22name%22%3A%22Bob%22%7D"
```

**Response:**
```json
{
    "data": {
        "array": [
            {
                "id": 1,
                "name": "Alice"
            },
            {
                "id": 2,
                "name": "Bob"
            }
        ],
        "count": 2
    },
    "meta": {
        "timestamp": "2026-06-03T01:09:43.923Z",
        "request_id": "fb2e7503-ddbb-4986-9d0f-c0fb24f7f8ea"
    },
    "status": "ok",
    "message": "NDJSON to JSON array",
    "success": true
}
```

#### `GET /v1/to-ndjson` — JSON array to NDJSON

**Parameters:**
- `json` (query, required, string) — JSON array Example: `[{"id":1},{"id":2}]`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/ndjson-api/v1/to-ndjson?json=%5B%7B%22id%22%3A1%7D%2C%7B%22id%22%3A2%7D%5D"
```

**Response:**
```json
{
    "data": {
        "count": 2,
        "ndjson": "{\"id\":1}\n{\"id\":2}"
    },
    "meta": {
        "timestamp": "2026-06-03T01:09:44.006Z",
        "request_id": "0c3ca996-4d3b-496d-bf38-598c7292b66c"
    },
    "status": "ok",
    "message": "JSON array to NDJSON",
    "success": true
}
```

#### `GET /v1/validate` — Validate NDJSON line by line

**Parameters:**
- `ndjson` (query, required, string) — NDJSON text Example: `{"id":1,"name":"Alice"}
{"id":2,"name":"Bob"}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/ndjson-api/v1/validate?ndjson=%7B%22id%22%3A1%2C%22name%22%3A%22Alice%22%7D%0A%7B%22id%22%3A2%2C%22name%22%3A%22Bob%22%7D"
```

**Response:**
```json
{
    "data": {
        "lines": [
            {
                "line": 1,
                "valid": true
            },
            {
                "line": 2,
                "valid": true
            }
        ],
        "all_valid": true,
        "total_lines": 2,
        "valid_lines": 2,
        "invalid_lines": 0
    },
    "meta": {
        "timestamp": "2026-06-03T01:09:44.087Z",
        "request_id": "a1d83896-b4ca-40da-bc63-3a86310a677d"
    },
    "status": "ok",
    "message": "Validate NDJSON line by line",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "NDJSON API",
        "notes": "Blank lines are ignored. to-array fails on the first invalid line; validate reports every line. Max 4 MB; send via POST.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/to-array",
                "params": {
                    "ndjson": "NDJSON text (required)"
                },
                "returns": "a JSON array of the parsed lines"
            },
            {
                "path": "/v1/to-ndjson",
                "params": {
                    "json": "a JSON array (required)"
                },
                "returns": "NDJSON text (one value per line)"
            },
            {
                "path": "/v1/validate",
                "params": {
                    "ndjson": "NDJSON text (required)"
                },
                "returns": "per-line validity with error messages"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Convert between NDJSON / JSON Lines (one JSON value per line) and a JSON array, in both directions, and validate an NDJSON stream line by line. NDJSON is the format used by logs, streaming APIs and LLM responses, jq, BigQuery and many data pipelines. Pure local, no key."
    },
    "meta": {
        "timestamp": "2026-06-03T01:09:44.176Z",
        "request_id": "5855095d-8978-4eab-bed2-
…(truncated, see openapi.json for full schema)
```


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