Skip to content

HTTP API

graphd listens on port 8080. The Compose file publishes it on 127.0.0.1:7860.

Conventions

  • If API_TOKENS is set, every endpoint except /healthz and /v1/info needs Authorization: Bearer <token>.
  • Endpoints marked signed need a nonce of 16 to 128 characters and return a signed answer. Use a fresh random nonce for each request.
  • graph selects a graph as author/name and can be repeated up to 32 times. Without it, all loaded graphs are used.
  • type restricts edge types and can be repeated. direction is out (default), in or both.
  • Errors are {"error": "..."} with status 400 (invalid request), 401 (missing token), 404 (graph not loaded), 422 (query too expensive) or 503 (busy).

Endpoints

Method and path Signed Parameters Result
GET /healthz no {"status":"ok"}
GET /v1/info no pubkey and configured graphs
GET /v1/graphs no Status of each graph
POST /v1/query yes Body, see below columns, rows, truncated
GET /v1/node yes id node (or null), and the number of out and in edges
GET /v1/neighbors yes id, direction, type, limit (100, max 1000) neighbors: edge and node, and total
GET /v1/traverse yes id, direction, type, depth (2, max 16), limit (100, max 1000) reached: node and depth, and truncated
GET /v1/path yes from, to, direction, type, depth (8, max 64) path: nodes and edges, or null
GET /v1/common yes from, to, direction, type common: up to 1000 ids, and total
GET /v1/suggest yes id, type, limit (20, max 1000) suggestions: id and score
GET /v1/rank yes type, seed (repeatable), limit (20, max 1000) ranking: id and score
GET /v1/components yes type, limit (20, max 1000) components: size and up to 1000 nodes each, and total
GET /v1/proof yes one graph, and id, or edge with from, to and optional key proofs

If the service serves exactly one graph, graph can be omitted for proof.

Query body

{
  "query": "MATCH (n) WHERE id(n) = $who RETURN n",
  "params": {"who": "agent:ann"},
  "graphs": ["<author>/social/main"],
  "nonce": "0123456789abcdef0123456789abcdef"
}

The body can be up to 256 KiB.

Graph status

{
  "graphs": [{
    "name": "<author>/social/main",
    "loaded": true,
    "version": 1,
    "manifest": "<event id>",
    "root": "<hex>",
    "size": 13,
    "nodes": 7,
    "edges": 5,
    "segments": ["social.graph.jsonl"],
    "updated": 1796118731
  }]
}

size is the number of Merkle leaves: every statement plus the header. error appears when the last synchronization failed. The rest then describes the state that is still being served.