REST API

Full OpenAPI 3.2 spec. Use from curl, Node.js, Python, Go, or any HTTP client. Ephemeral endpoints require no authentication.

OpenAPI 3.2 spec

Import into ChatGPT, Postman, Insomnia, or generate a typed client.

openapi.yaml โ†—

Authentication

Ephemeral endpoints

No auth required. Open to all. Rate limited by IP.

POST /v1/ephemeral/create
GET /v1/ephemeral/:id
POST /v1/ephemeral/:id/sql

Persistent endpoints

Requires API key in Authorization header.

Authorization: Bearer dbaas_live_โ€ฆ

Endpoint reference

MethodPathAuthDescription
POST/v1/ephemeral/createnoneCreate ephemeral database
GET/v1/ephemeral/:idnoneGet status + connection info
POST/v1/ephemeral/:id/sqlnoneExecute SQL (ephemeral)
POST/v1/ephemeral/:id/sql/batchnoneExecute multiple SQL statements (1 round-trip)
DELETE/v1/ephemeral/:idnoneDelete on demand (frees IP slot, skips TTL wait)
GET/v1/resources/listAPI keyList all your databases
POST/v1/services/createAPI keyProvision persistent database
GET/v1/resources/:id/addressAPI keyGet host / port / credentials
POST/v1/resources/:id/sqlAPI keyExecute SQL (persistent)
POST/v1/resources/:id/sql/explainAPI keyEXPLAIN plan (set analyze=true for real timings)
POST/v1/resources/:id/stopAPI keyStop database
POST/v1/resources/:id/startAPI keyStart database
DELETE/v1/resources/:idAPI keyDelete database
GET/v1/resources/:id/backupsAPI keyList backups
POST/v1/resources/:id/backupsAPI keyTrigger manual backup
POST/v1/resources/:id/backups/:bid/restoreAPI keyRestore from backup
GET/v1/resources/:id/metricsAPI keyCPU / memory / storage metrics

Code examples

๐Ÿš

curl โ€” ephemeral (no auth)

# 1. Create an ephemeral database (auto-deletes after TTL minutes)
curl -s -X POST https://api.dbaas.dev/v1/ephemeral/create \
  -H "Content-Type: application/json" \
  -d '{"ttl":10}' | jq .

# 2. Poll until status == "running" (~30s)
curl -s https://api.dbaas.dev/v1/ephemeral/<id> | jq .data.status

# 3. Run SQL
curl -s -X POST https://api.dbaas.dev/v1/ephemeral/<id>/sql \
  -H "Content-Type: application/json" \
  -d '{"sql":"SELECT version()"}' | jq .data.rows

# 4. Batch โ€” N statements in one call (each runs as its own implicit transaction)
curl -s -X POST https://api.dbaas.dev/v1/ephemeral/<id>/sql/batch \
  -H "Content-Type: application/json" \
  -d '{"statements":[
    "CREATE TABLE users (id SERIAL PRIMARY KEY, email TEXT UNIQUE)",
    "INSERT INTO users (email) VALUES (\'[email protected]\'), (\'[email protected]\')",
    "SELECT * FROM users"
  ]}' | jq .data

# 5. Atomic multi-statement โ€” wrap in BEGIN/COMMIT in a SINGLE /sql call.
#    Either every statement commits or postgres rolls back the whole thing.
#    Use this for migrations and FK-coupled inserts. /sql/batch runs each
#    statement in its own session, so it cannot be atomic across statements.
curl -s -X POST https://api.dbaas.dev/v1/ephemeral/<id>/sql \
  -H "Content-Type: application/json" \
  -d '{"sql":"
    BEGIN;
      CREATE TABLE accounts (id SERIAL PRIMARY KEY, balance NUMERIC NOT NULL);
      INSERT INTO accounts (balance) VALUES (100);
      INSERT INTO accounts (balance) VALUES (200);
    COMMIT;
  "}' | jq .data
๐Ÿš

curl โ€” persistent (API key)

# List your databases
curl -s https://api.dbaas.dev/v1/resources/list \
  -H "Authorization: Bearer dbaas_live_your_key_here" | jq .

# Run SQL on a persistent database
curl -s -X POST https://api.dbaas.dev/v1/resources/<id>/sql \
  -H "Authorization: Bearer dbaas_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"sql":"SELECT count(*) FROM users"}' | jq .data.rows
๐ŸŸจ

Node.js / TypeScript

import fetch from "node-fetch"; // or global fetch in Node 18+

const API = "https://api.dbaas.dev/v1";
const KEY = process.env.DBAAS_API_KEY;

// List databases
const res = await fetch(`${API}/resources/list`, {
  headers: { Authorization: `Bearer ${KEY}` },
});
const { data } = await res.json();
console.log(data); // array of database objects

// Run SQL
const sql = await fetch(`${API}/resources/${data[0].id}/sql`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ sql: "SELECT NOW()" }),
});
const result = await sql.json();
console.log(result.data.rows);
๐Ÿ

Python

import os, requests

API = "https://api.dbaas.dev/v1"
KEY = os.environ["DBAAS_API_KEY"]
HEADERS = {"Authorization": f"Bearer {KEY}"}

# List databases
dbs = requests.get(f"{API}/resources/list", headers=HEADERS).json()
db_id = dbs["data"][0]["id"]

# Run SQL
result = requests.post(
    f"{API}/resources/{db_id}/sql",
    headers={**HEADERS, "Content-Type": "application/json"},
    json={"sql": "SELECT NOW()"},
).json()
print(result["data"]["rows"])

Rate limits

Client typeGlobal limitSQL / mutation limit
Anonymous (no key)60 req / min per IP10 mutations / min per IP
API keyBypasses IP limit60 mutations / min per key ยท 60 SQL / min per DB