Skip to content

Database

Projects with Frontend Cloud enabled get their own SQL (SQLite) database. These endpoints run SQL and inspect the schema over HTTP. If Frontend Cloud is not enabled for the project, both return 409 database_not_connected.

POST /api/v1/projects/{id}/database/query

Body: sql (required), optional params (array, for parameterized statements). Returns { result } with the query’s result set.

Terminal window
curl -X POST "https://www.frontend.co/api/v1/projects/$ID/database/query" \
-H "Authorization: Bearer $FRONTEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "sql": "select * from posts limit 5" }'
const rows = await client.database.query(projectId, 'select * from posts limit 5')
await client.database.query(projectId, 'insert into posts (title) values (?)', ['Hello'])
GET /api/v1/projects/{id}/database/schema

Returns { schema } — a map of table name to its columns (name, type, nullability, default, primary key).

const schema = await client.database.schema(projectId)