HTTP API
The Traverse HTTP API provides RESTful endpoints for queries, database management, import/export, and Studio integration.
Base URL: http://localhost:7691. The HTTP API is on by default; --http-listen (or TRAVERSE_HTTP_LISTEN) moves it, and none turns it off.
API Documentation
Traverse ships with built-in interactive API documentation:
- Scalar API Reference (
GET /api/docs) - interactive UI for exploring and testing all endpoints - OpenAPI 3.1.0 Specification (
GET /api/openapi.json) - machine-readable spec for code generation and tooling
Authentication
Protected endpoints require an API key. The server auto-generates a random key on startup (printed as API key tvs_... in the log) unless you provide one via --api-key. Supply it in requests via one of:
Authorization: Bearer tvs_...headerX-API-Key: tvs_...header?token=tvs_...query parameter (useful for WebSocket)
API keys use the tvs_ prefix followed by 32 hex characters (128-bit random). Comparison uses constant-time XOR to prevent timing attacks.
Public Endpoints (no key required)
/api/health, /api/ready, /api/docs, /api/openapi.json, /metrics and Studio's static files. /ws takes the key like the rest (in browsers, as ?token=).
CORS
The HTTP server allows cross-origin requests from any origin:
- Allowed origins:
* - Allowed methods: GET, POST, PUT, DELETE
- Allowed headers:
*
Health & Status
GET /api/health
Server status: status, version, uptime_secs, memory_bytes, the databases with their node and relationship counts and memory, allow_drop_database, auth_required, and the features the binary was built with (gql, grpc, mcp, ml, tls, and ai when a Graph Assistant provider is set).
GET /api/ready
Simple readiness probe. Returns 200 OK when the server is ready.
GET /metrics
Prometheus-format metrics: memory usage, uptime, node count and edge count per database.
Query Execution
POST /api/query
Execute a Cypher query.
POST /api/query
Content-Type: application/json
Authorization: Bearer tvs_...
{
"query": "MATCH (n:Person) RETURN n.name LIMIT 10",
"database": "mydb",
"parameters": {"limit": 10}
}To run ISO/IEC 39075 GQL instead of openCypher, send the X-Query-Dialect: gql header (or "dialect": "gql" in the body). Without either, or with cypher, the query is openCypher. GQL needs a server built with the gql feature, which the release builds have.
POST /api/query
Content-Type: application/json
Authorization: Bearer tvs_...
X-Query-Dialect: gql
{
"query": "MATCH (n:Person) FILTER n.age > 30 RETURN n.name AS name"
}The response includes:
columns: the column namesrows: the result rows (at most 10,000;truncated: truewhen there were more)total_rows: the row count before truncationnodes,edges: the graph entities in the result, for drawing it (entities_truncatedwhen capped)query_type:"Read","Write","ReadWrite"or"Schema"stats: nodes and relationships created or deleted, properties set, labels added or removedtime_ms,parsing_time_ms,planning_time_ms,execution_time_ms: the timing breakdown
A query runs as a transaction of its own. A GQL transaction block (START TRANSACTION ... COMMIT) runs its statements as one unit. A client that disconnects or aborts the request stops the query.
Async Tasks
GET /api/tasks/{id}
Poll the status of an async operation (drop, unload, load, save).
{
"id": "...",
"operation": "drop",
"status": "running", // "running", "completed", "failed"
"result": {...}, // present when completed
"error": "...", // present when failed
"createdAt": "...",
"finishedAt": "..."
}Endpoints that take ?async=true and answer 202 with a task id: DELETE /api/databases/{name}, POST /api/databases/{name}/unload, POST /api/databases/load and POST /api/save.
Database Management
GET /api/databases
List all databases. Returns name, default flag, read-only flag, aliases, node/edge counts, and memory usage.
POST /api/databases
Create a new database.
{"name": "analytics"}DELETE /api/databases/{name}
Drop a database. Returns 403 when the server runs with allow_drop_database = false. Supports ?async=true.
POST /api/databases/{name}/rename
Rename a database.
{"name": "analytics_v2"}POST /api/databases/{name}/unload
Unload a database from memory (keeps the file on disk). Supports ?async=true.
POST /api/databases/load
Load an existing .tvdb file from disk. Supports ?async=true.
{"name": "mydb", "file": "mydb.tvdb"}Schema
GET /api/schema
Returns labels, relationship types, property keys, indexes, and constraints. Use ?database=name to target a specific database.
Data Import
Body limit: Import endpoints accept up to 512 MB.
POST /api/import
Import Cypher statements (one per line).
{
"cypher": "CREATE (n:Person {name: 'Alice'});\nCREATE (n:Person {name: 'Bob'});",
"database": "mydb"
}Response:
{
"total_statements": 2,
"executed": 2,
"errors": [],
"stats": {...},
"time_ms": 12.5
}POST /api/import/csv
Import a CSV file as nodes.
{
"csv": "id,name,age\n1,Alice,30\n2,Bob,25",
"label": "Person",
"columns": [
{"name": "id", "property": "id", "type": "integer"},
{"name": "name"},
{"name": "age", "type": "integer"}
],
"database": "mydb",
"delimiter": ",",
"skip_header": true
}Supported column types: string (default), integer, float, boolean.
Supported delimiters: , (default), \t / tab, ;, |.
POST /api/import/csv/edges
Import a CSV file as relationships.
{
"csv": "...",
"edge_type": "KNOWS",
"source": {"label": "Person", "column": "from_id", "property": "id"},
"target": {"label": "Person", "column": "to_id", "property": "id"},
"columns": [...],
"database": "mydb"
}File Management
GET /api/files
List all .tvdb files on disk. Returns name, file path, size in bytes, and whether loaded.
GET /api/files/{name}
Download a .tvdb file (streamed).
PUT /api/files/{name}
Upload a .tvdb file. The first 4 bytes must be the TVDB magic header. Written atomically via a .upload temp file.
DELETE /api/files/{name}
Delete a .tvdb file from disk.
Database Aliases
GET /api/aliases
List all database aliases.
POST /api/aliases
Create an alias.
{"alias": "production", "database": "mydb_v2"}PUT /api/aliases/{name}
Change the target database of an alias.
{"database": "mydb_v3"}DELETE /api/aliases/{name}
Delete an alias.
User Management
GET /api/users
List all users with username and role.
POST /api/users
Create a new user.
{"username": "alice", "password": "s3cret", "role": "EDITOR"}Roles: admin, editor, reader (any case; reader when left out). Passwords are hashed with bcrypt (cost 12), and each change is saved before the request returns.
PUT /api/users/{username}
Update a user's password or role.
{"password": "new_pass", "role": "ADMIN"}DELETE /api/users/{username}
Delete a user.
Persistence
POST /api/save
Save all databases to disk immediately. Supports ?async=true. Studio calls this automatically after imports.
POST /api/quiesce
Before a planned stop: waits for background tasks, saves every changed database, and returns a node and relationship inventory to check against after the restart. ?timeout_ms= bounds the wait (default 120000).
Studio Integration
Studio's saved queries and styles are kept in a <name>.studio.json file next to each .tvdb.
GET /api/studio/queries
List saved queries. Optional: ?database=name.
POST /api/studio/queries
Save a query. Optional: ?database=name.
{"name": "Find all people", "query": "MATCH (n:Person) RETURN n"}DELETE /api/studio/queries/{name}
Delete a saved query. Optional: ?database=name.
GET /api/studio/styles
Get custom visualization styles. Optional: ?database=name.
PUT /api/studio/styles
Save custom visualization styles. Optional: ?database=name.
WebSocket
GET /ws
WebSocket endpoint for streaming queries. Authenticate via Bearer token or ?token= query parameter.
Request message
{
"type": "query",
"id": "unique-message-id",
"query": "MATCH (n) RETURN n LIMIT 10",
"database": "mydb",
"parameters": {}
}To stop a running query, send {"type": "cancel", "id": "unique-message-id"}; the query is answered with an error and the socket stays open.
Response messages
// Row (streamed for each result row)
{"type": "result", "id": "...", "columns": [...], "row": [...]}
// Completion
{"type": "complete", "id": "...", "stats": {"rows": 100, "time_ms": 12.3}}
// Error
{"type": "error", "id": "...", "message": "error description"}Graph Assistant
POST /api/ai/chat
Studio's Graph Assistant: a Server-Sent Events stream, answered by the model the server is configured with (ai_provider; see Server Configuration). Without a provider it isn't available.
MCP
POST /api/mcp
The Model Context Protocol endpoint (JSON-RPC 2.0 over Streamable HTTP), through which AI assistants query and explore the databases. See MCP.
Error Responses
Errors have one shape. A query error also carries its GQLSTATUS code (the ISO/IEC 39075 code where the standard has one):
{"error": "error message", "gql_status": "42001"}| Status | Meaning |
|---|---|
200 | Success |
202 | Async task created (poll via /api/tasks/{id}) |
400 | Invalid input or missing required fields |
401 | Missing or invalid API key |
403 | Forbidden (a read-only database, dropping turned off, a role without the right) |
404 | Database, file, user, or query not found |
409 | Conflict (database or user already exists) |
500 | Internal server error |