HTTP API
The basic cycle: login → opendb → query
TOKEN=$(curl -s -X POST http://localhost:8080/api/auth/login
-H "Content-Type: application/json"
-d '{"password":"mypass"}' | jq -r .data.token)
curl -X POST http://localhost:8080/api/createdb
-H "X-Token: $TOKEN" --data-urlencode "name=blog"
curl -X POST http://localhost:8080/api/opendb
-H "X-Token: $TOKEN" --data-urlencode "name=blog"
curl -X POST http://localhost:8080/api/query
-H "X-Token: $TOKEN"
-H "Content-Type: application/json"
-d '{"sql":"CREATE TABLE posts (id INT AUTO_INCREMENT PRIMARY KEY, title TEXT, body TEXT)"}'
/api/opendb creates the .fdb file if it doesn't exist yet — calling /api/createdb separately for an existing database isn't required.
PostgreSQL/MySQL dialects over HTTP
The same dialect translator used by the wire protocol is also available over HTTP — handy when you're already on HTTP but writing SQL in PG/MySQL syntax:
-- PG-style:
INSERT INTO users (name) VALUES ($1) RETURNING id;
INSERT INTO users (id, name) VALUES (1, 'Alice') ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name;
-- MySQL-style:
INSERT INTO users (name) VALUES (?);
INSERT INTO users (id, name) VALUES (1, 'Alice') ON DUPLICATE KEY UPDATE name = VALUES(name);
INSERT IGNORE INTO users ...
REPLACE INTO users ...
Pass the flavor via the JSON body, ?flavor=mysql in the URL, or an X-SQL-Flavor: mysql header.
Metrics
GET /api/metrics (JSON) and GET /metrics (Prometheus format): filedb_open_databases, filedb_active_sessions, filedb_select_total/_insert_total/_update_total/_delete_total, filedb_auth_attempts_total/_auth_success_total, filedb_table_rows{database, table}.
← Previous
TransactionsNext →
Native drivers