Skip to content

Stats

Read record counts by collection, operator and client counts, and Jetstream status. Every endpoint needs stats:read, or the platform key.

const TOKEN = "hv_..."; // your API key
const headers = { Authorization: `Bearer ${TOKEN}` };
GET /admin/stats
interface CollectionCount {
collection: string;
count: number;
indexed: boolean;
}
interface Stats {
total_records: number;
collections: CollectionCount[];
}
const response = await fetch("http://127.0.0.1:3000/admin/stats", {
headers,
});
const data: Stats = await response.json();

Response: 200 OK

{
"total_records": 12345,
"collections": [{ "collection": "xyz.statusphere.status", "count": 500, "indexed": true }]
}

collections has one entry for every record lexicon on the instance, with a count of 0 when it has no records. indexed is false for a record lexicon installed without indexing, whose collection nothing subscribes to or backfills. Returns 503 Service Unavailable when a collection’s records live in external record storage that can’t be reached.

GET /admin/stats/counts

Returns the number of operators (seats, including those with superadmin) and registered API clients. The client count includes hvc_hpy, the built-in client hpy signs in with. It is cheap to call often, unlike the record counts above. Requires stats:read.

const response = await fetch("http://127.0.0.1:3000/admin/stats/counts", {
headers,
});
const data = await response.json();

Response: 200 OK

{
"users": 3,
"api_clients": 2
}
GET /admin/jetstream/status

The live Jetstream consumer’s state since the process started. Requires stats:read; the platform key may call it too. This route exists only when the instance’s records come from Jetstream, which is the default.

Response: 200 OK

{
"protocol": "v2",
"host": "jetstream1.us-east.bsky.network",
"connected": true,
"compression": true,
"dictionary_id": 3,
"applied_seq": 18300422,
"applied_time_us": 1793390000000000,
"lag_ms": 412,
"last_frame_ms": 1793390000498,
"idle_ms": 14,
"worker_queue_depths": [0, 2, 0, 0, 1, 0, 0, 0],
"worker_busy_since_ms": [null, 1793390000100, null, null, null, null, null, null],
"now_ms": 1793390000512
}

Unknown values are an explicit null: protocol, host, dictionary_id, applied_seq, applied_time_us and lag_ms are all null before the first connection or event, last_frame_ms until the first event arrives, and idle_ms until the first connection, and the two worker arrays are empty until the worker pool starts.

FieldMeaning
protocolv2 (subscribeEvents) or v1 (/subscribe); null before the first connection
hostThe Jetstream host from JETSTREAM_URL
connectedWhether a subscription is open now
compressionWhether frames arrive zstd-compressed
dictionary_idThe zstd dictionary in use, or null
applied_seqThe newest event that it and every event before it have been applied: the position saved for a restart. null on v1, which has no seq
applied_time_usWhen Jetstream witnessed that event, in microseconds since the Unix epoch
lag_msMilliseconds from applied_time_us to now
last_frame_msWhen an event last arrived, on any connection, in milliseconds since the Unix epoch. Kept across reconnects
idle_msMilliseconds since an event last arrived, or since the first connection when none has. It is reported whether or not JETSTREAM_STALL_TIMEOUT_SECS is set, even at 0. It grows on a connection that is open but silent, even before anything was applied, and keeps growing across reconnects that don’t help. It also grows while the workers are too far behind for HappyView to read more. Past JETSTREAM_STALL_TIMEOUT_SECS with nothing arriving, HappyView reconnects, unless that’s 0, which turns reconnecting off but not idle_ms
worker_queue_depthsEvents waiting in each worker’s queue, one entry per JETSTREAM_WORKERS. The event a worker is applying or retrying is not counted
now_msServer time when the snapshot was taken, in milliseconds since the Unix epoch. Subtract worker_busy_since_ms from it rather than using your own clock
worker_busy_since_msOne entry per worker: when its current event started, in milliseconds since the Unix epoch, or null when idle. An old value with an empty queue means the worker is stuck retrying