Skip to main content

REST API Overview

LynxDB exposes a clean, streaming-first HTTP API at http://localhost:3100/api/v1. The same API powers the Web UI, CLI (in server mode), and any programmatic integration.

Base URL

All endpoints described in this section are relative to /api/v1. For example, POST /ingest means POST http://localhost:3100/api/v1/ingest.

Design Principles

1. One URL -- One Resource

Each endpoint does exactly one thing:

EndpointPurpose
POST /ingestIngest events
POST /queryExecute SPL2 query
GET /fieldsList fields
GET /healthHealth check

No overloaded endpoints, no action parameters. The HTTP method and path tell you everything.

2. Streaming-First

Large-data endpoints support NDJSON (newline-delimited JSON) via Accept: application/x-ndjson. Real-time endpoints use Server-Sent Events (SSE). This means you can curl | jq any result set, pipe exports to files, and build reactive UIs with native EventSource.

3. Errors Are UX

Every error response carries machine-readable code, human-readable message, and optionally a suggestion and docs_url:

{
"error": {
"code": "INVALID_QUERY",
"message": "Unknown field 'stauts'.",
"suggestion": "status",
"docs_url": "https://lynxdb.io/docs/spl2/overview"
}
}

Error codes use SCREAMING_SNAKE_CASE. The suggestion field powers "did you mean?" in the CLI and Web UI.

4. Zero Required Headers

Content-Type defaults to application/json. You do not need to set any headers for basic usage -- curl just works:

curl -X POST localhost:3100/api/v1/ingest \
-d '{"message": "hello", "level": "info"}'

5. Three Execution Modes

The POST /query endpoint supports three modes via the wait parameter:

wait valueModeBehavior
null (default)SyncBlock until complete or server timeout (30s). Returns 200 with results.
0AsyncReturn 202 immediately with a job handle. Poll or subscribe to SSE.
N (seconds)HybridWait up to N seconds. 200 if done in time, 202 with job handle otherwise.

Hybrid mode (wait: 5) is ideal for Web UI -- fast queries feel instant, slow queries degrade gracefully to async with progress tracking.

See Query API for full details.

Authentication

Authentication is off by default. When enabled via lynxdb server --auth, all requests require a Bearer token:

curl -H "Authorization: Bearer <token>" \
localhost:3100/api/v1/query -d '{"q": "level=error"}'

Unauthenticated requests return 401:

{
"error": {
"code": "AUTH_REQUIRED",
"message": "Authentication is enabled. Provide a Bearer token.",
"docs_url": "https://lynxdb.io/docs/deployment/tls-auth"
}
}

See TLS & Authentication for setup instructions.

Response Envelope

All JSON responses follow a consistent envelope:

Success

{
"data": { ... },
"meta": {
"took_ms": 89,
"scanned": 12400000,
"query_id": "qry_7f3a..."
}
}
  • data -- the resource or result
  • meta -- timing, scan stats, query ID (present on query endpoints)

Error

{
"error": {
"code": "INVALID_QUERY",
"message": "Unknown command 'staats'.",
"suggestion": "stats"
}
}
  • error.code -- machine-readable SCREAMING_SNAKE_CASE code
  • error.message -- human-readable description
  • error.suggestion -- optional "did you mean?" hint
  • error.docs_url -- optional link to relevant documentation

No "status": "ok" wrapper. HTTP status codes carry success/failure.

Common HTTP Status Codes

CodeMeaning
200Success
201Resource created
202Accepted (async job started)
204Deleted (no content)
207Partial success (some events failed)
400Bad request (invalid query, malformed JSON)
401Authentication required
404Resource not found
408Query timeout
410Job results expired
413Payload too large
422Validation error
429Rate limited (check Retry-After header)
503Server unhealthy

Common Headers

Request Headers

HeaderDescriptionDefault
Content-TypeRequest body formatapplication/json
AcceptResponse format (application/json or application/x-ndjson)application/json
AuthorizationBearer <token> (when auth enabled)--
X-SourceTag ingested events with a source label--
X-FormatForce log format parser: json, syslog, clf, raw, autoauto

Response Headers

HeaderDescription
Content-Typeapplication/json, application/x-ndjson, or text/event-stream
Retry-AfterSeconds to wait (on 429 responses)
Transfer-Encodingchunked (on streaming responses)

Endpoint Summary

MethodEndpointDescriptionDocs
POST/ingestIngest events (JSON, NDJSON, text)Ingest
POST/ingest/bulkES-compatible bulk ingestIngest
POST/queryExecute SPL2 queryQuery
GET/queryExecute query (GET convenience)Query
POST/query/streamNDJSON streaming exportQuery
GET/query/explainParse and explain queryQuery
GET/query/jobsList query jobsQuery
GET/query/jobs/{id}Get job status and resultsQuery
GET/query/jobs/{id}/streamSSE job progress streamQuery
DELETE/query/jobs/{id}Cancel a running jobQuery
GET/tailSSE live tailLive Tail & Histogram
GET/histogramTime-bucketed event countsLive Tail & Histogram
GET/fieldsField catalogFields & Sources
GET/fields/{name}/valuesTop values for a fieldFields & Sources
GET/sourcesLog sources with statsFields & Sources
GET/POST/queriesList/create saved queriesSaved Queries
PUT/DELETE/queries/{id}Update/delete saved querySaved Queries
GET/POST/alertsList/create alertsAlerts
PUT/DELETE/alerts/{id}Update/delete alertAlerts
POST/alerts/{id}/testTest alert (dry run)Alerts
POST/alerts/{id}/test-channelsTest notification channelsAlerts
GET/POST/dashboardsList/create dashboardsDashboards
GET/PUT/DELETE/dashboards/{id}Get/update/delete dashboardDashboards
GET/POST/viewsList/create materialized viewsViews
GET/PATCH/DELETE/views/{name}Get/update/delete viewViews
GET/views/{name}/backfillBackfill progressViews
GET/statusServer status and metricsServer
GET/healthHealth checkServer
GET/configRuntime configurationServer
PATCH/configUpdate runtime configurationServer
POST/es/_bulkElasticsearch bulk APICompatibility
POST/es/{index}/_docES single-doc ingestCompatibility
GET/es/ES cluster info (handshake)Compatibility
POST/otlp/v1/logsOpenTelemetry OTLP logsCompatibility
  • CLI Reference -- the lynxdb query and lynxdb ingest commands use this API under the hood
  • Configuration -- server listen address, auth, rate limits
  • Quick Start -- first API call walkthrough