Protocol
Nova's API is JSON over HTTP and protobuf over gRPC, served by every node and by the Gateway.
Call the API over HTTP or gRPC from a language without an SDK, from a shell script, or from a browser. Where your language has an SDK, use it: it batches records, retries within a time budget, follows each stream's leader, and returns typed errors.
curl -s localhost:8080/v1/streams/demo/events/records -d '{
"records": [
{
"body": "hello"
},
{
"body": "world",
"headers": [
{
"name": "content-type",
"value": "text/plain"
}
]
}
]
}'{
"start": {
"seq_num": 0,
"timestamp_ms": 1795359513291
},
"end": {
"seq_num": 2,
"timestamp_ms": 1795359513291
},
"tail": {
"seq_num": 2,
"timestamp_ms": 1795359513291
}
}The examples use the quickstart cluster: its Gateway at
localhost:8080 and a node at localhost:7781. Nova sends compact JSON on one
line; these pages format it for reading.
Where to send requests
| Base URL | Serves | Use when |
|---|---|---|
The Gateway: https://{location}.{domain}, or http://localhost:8080 locally | Every HTTP route | Clients outside your network, browsers, and HTTP in general. Use this by default |
A bucket host: https://{bucket}.b.{location}.{domain} | One bucket's stream routes | A client that works in one bucket and wants a hostname of its own |
A node's data bridge: http://{node}:{port}, or localhost:7791 locally | Every HTTP route | Callers inside your network that cannot use gRPC |
A node: {node}:7780 | Every gRPC service | The SDKs and other gRPC clients inside your network |
The Gateway is the internet-facing HTTP server in front of the nodes.
Depending on its flags, it ends TLS, checks tokens before a node sees the
request, answers browser CORS requests, serves bucket hosts, and applies
per-credential limits. It serves no gRPC, and GET /healthz answers 200
while it runs. A node's data bridge serves the same routes at
novad --http-listen, which is off by default. Any node, and the Gateway,
answers for any stream: it forwards the request to the stream's leader, so an
HTTP caller never sees a redirect.
Every route is under /v1, and a stream key is one percent-encoded path
segment: orders/eu is orders%2Feu. A path with an empty, ., or ..
segment gets 404 from a node and a redirect to the cleaned path from the
Gateway. A bucket host drops the bucket from the path. This request went to a
Gateway started with --domain nova.example:
curl -s -H 'Host: demo.b.local.nova.example' \
localhost:8080/v1/streams/events/records/tail{
"bookmark": "5",
"tail": {
"seq_num": 5,
"timestamp_ms": 1795359533400
}
}A bucket host serves only stream routes; bucket and credential routes stay on the Gateway's own address.
Authentication
When the cluster checks credentials, every route except the exchange needs an
Authorization: Bearer <token> header, the only place a token goes. The
quickstart cluster runs without authentication, so its examples send none. A
token is a short-lived JWT. Get one by exchanging an
API key, or let nova token exchange split the key
for you:
curl -s localhost:8080/v1/token/exchange -d '{
"key_id": "fa4bb0c3c34da3c0",
"secret": "…",
"bucket": "demo",
"ttl_seconds": 900
}'{
"token": "eyJhbGciOi…",
"expires_at_unix_ms": 1795360212000,
"scope": "nova:append:demo:* nova:read:demo:* nova:list:demo:* nova:create:demo:* nova:delete:demo:* nova:trim:demo:*"
}| Field | Meaning |
|---|---|
key_id | Characters 9 to 24 of the API key |
secret | Characters 26 to 68 of the API key |
bucket | Narrow the token to one bucket. Add key to narrow it to one stream |
scope | Ask for an explicit subset of the key's grants |
ttl_seconds | The token's lifetime: 15 minutes when 0 or absent, at most 1 hour |
Send exactly one of bucket and scope; neither or both fails with 400 and
{"error":"exchange: the ask names exactly one of bucket or scope"}. A token
narrowed to a bucket covers that bucket's streams, listing them included, but
cannot list buckets: GET /v1/buckets needs a list grant on every bucket,
or the admin grant, and answers 403 otherwise. A request without a token
fails with 401 and {"error":"auth: no credential"}, and one whose token
does not cover the stream with 403, as in
{"error":"dataplane: no grant covers read on other/events"}.
Over gRPC, send the token as authorization: Bearer <token> metadata, and
exchange keys with nova.v1.AuthService/ExchangeToken, which takes the same
fields. The exchange needs no token, because the key is the credential, and
any node answers it. A cluster that checks tokens but cannot sign them answers
the exchange with 501, UNIMPLEMENTED.
Bodies and bytes
Requests and responses are JSON, and 64-bit integers are JSON numbers. A record's body, and each header's name and value, are bytes. JSON carries them in one of two forms:
| Form | Fields | Cost | Use when |
|---|---|---|---|
| Text | body, name, value | None, and you can read it | The bytes are valid UTF-8 |
| Base64 | body_b64, name_b64, value_b64 | About a third larger on the wire | Any other bytes |
When you write, each record sets exactly one of body and body_b64, and a
header needs a name but may omit its value, which is then empty. When you
read, format=raw, the default, returns each field as text when its bytes are
valid UTF-8 and as base64 otherwise; format=base64 returns every field as
base64, under its plain name. The byte 0xFF is not UTF-8, and this append
stores it at sequence number 4:
curl -s localhost:8080/v1/streams/demo/events/records -d '{
"records": [
{
"body_b64": "/w=="
}
]
}'Read it back with each format:
curl -s 'localhost:8080/v1/streams/demo/events/records?seq_num=4'
curl -s 'localhost:8080/v1/streams/demo/events/records?seq_num=4&format=base64'{
"records": [
{
"seq_num": 4,
"timestamp_ms": 1795359533400,
"body_b64": "/w=="
}
],
"bookmark": "5",
"tail": {
"seq_num": 5,
"timestamp_ms": 1795359533400
}
}{
"records": [
{
"seq_num": 4,
"timestamp_ms": 1795359533400,
"body": "/w=="
}
],
"bookmark": "5",
"tail": {
"seq_num": 5,
"timestamp_ms": 1795359533400
}
}Use body_b64 for anything but plain text, because JSON escaping can make text
wider than its base64: quotes, backslashes and control characters always, and
<, >, & and non-ASCII text when your encoder escapes them. One record's
JSON may take about 1.36 MiB at the default limits; past that, the append
fails with 413, and the error says to send the body as body_b64. A key
named twice in one JSON object fails with 400.
Limits lists the size limits.
One-shot calls and sessions
A one-shot append is one request that sends one batch and waits for its acknowledgement. A producer session keeps one append request open and sends many batches through it without waiting for each acknowledgement, up to the session window. A session gives much higher throughput. Use one-shot appends for occasional writes and from browsers, and a session, through an SDK, for a steady flow.
To open a session over HTTP, send the append route
POST /v1/streams/{bucket}/{key}/records with
Content-Type: application/vnd.nova.session; both bodies are then streams of
frames. Over gRPC, open the bidirectional stream AppendSession. A refusal at
the open is an ordinary JSON error: 400, 403, 404, 412, 429, or
503. Once the session opens, the answer is 200 with the same content type.
A session needs both directions of one request open at once: HTTP/2, or
HTTP/1.1 where client and server both allow it. Proxies must forward request
bodies as they arrive. A browser cannot open a session, because fetch waits
for the request body to finish before it returns the response.
Producer sessions documents the messages, flow control,
failures, and the frame format.
Server-sent events
Subscribe answers with
Content-Type: text/event-stream and Cache-Control: no-cache, and sends
three kinds of event:
| Event | Form | Meaning |
|---|---|---|
| Batch | id: <bookmark> and data: {"records":[…],"bookmark":"…","tail":{…}} | One batch of records. The id is the bookmark after it |
| Heartbeat | : hb | Sent every 15 seconds. Ignore it |
| Expiry | event: auth-expired and data: {} | The token expired and the stream ends |
event: auth-expired
data: {}To resume, send the last id you received as the Last-Event-ID header. It
wins over any start in the query, and the stream goes on with the next record,
none lost or repeated. After auth-expired, resume the same way with a new
token.
- The node sends one batch at a time, never an empty one, and only as fast as you read. A client that stops reading for 60 seconds is disconnected.
- A host holds at most 4,096 long-lived connections by default, subscriptions
and sessions together; past that, a new one fails with
503. - A node shutdown or a failure ends the stream without an error event.
Reconnect with
Last-Event-ID, and the new request reports any error as a status. - In a browser,
EventSourcecannot send theAuthorizationheader. Usefetchand read the response body as a stream.
Headers
| Header | Direction | Use |
|---|---|---|
Authorization: Bearer <token> | Request | The credential, on every route except the exchange |
Content-Type: application/json | Both | Every JSON body |
Content-Type: application/vnd.nova.session | Both | A producer session on the append route |
Last-Event-ID | Request | The bookmark a subscription resumes after |
Retry-After: 1 | Response | On every 503 |
Allow | Response | On 405, the methods the path accepts |
gRPC
The gRPC API is three services, defined in proto/nova/v1/ in the repository:
nova.v1.DataPlaneService for records, streams, and buckets,
nova.v1.QueueService for queues, and nova.v1.AuthService for the exchange.
Connect to any node at the address novad --listen sets, port 7780 by
default. Use TLS when the node has a certificate.
Nodes do not offer gRPC reflection, so give a tool the proto files:
grpcurl -plaintext -import-path proto -proto nova/v1/dataplane.proto -d '{
"bucket": "demo",
"key": "events"
}' \
localhost:7781 nova.v1.DataPlaneService/CheckTail{
"tail": {
"seqNum": "6",
"timestampMs": "1795359533804"
}
}| HTTP | gRPC | |
|---|---|---|
| Bytes | Text or base64 in JSON | Raw bytes fields |
| Errors | An HTTP status and a JSON body | A gRPC status code with typed details |
| Sessions | One framed HTTP request | The bidirectional stream AppendSession |
| A node that does not lead the stream | Forwards the request | Answers FailedPrecondition with a NotOwner detail; redial its holder_addr |
Appends, sessions, CheckTail, Trim, Fence, ReconfigureStream, and
DeleteStream go to the stream's leader. Any node serves Read and
Subscribe.
Resources
Records
POST /v1/streams/{bucket}/{key}/records: append, read, tail, subscribe, trim, fence
Producer sessions
gRPC AppendSession, or a framed HTTP append: many batches, one request
Read plans
gRPC ReadPlan: the objects in storage that hold a stream's older records
Streams
POST /v1/streams/{bucket}/{key}: create, get, reconfigure, list, delete
Buckets
POST /v1/buckets/{bucket}: create, get, replace, list, delete
Queues
POST /v1/queues/{bucket}/{key}: settings, and sending messages
Claims
POST /v1/queues/{bucket}/{key}/claims: claim, ack, nack, extend, replay, purge
Every status code, and whether a retry is safe, is on Errors. The size and rate limits are on Limits.