Back to Eliza

Database API

packages/docs/rest/database.md

2.0.12.7 KB
Original Source

The Database API provides endpoints for inspecting the agent's database connection, listing tables, and running read-only queries. These endpoints power the Database Explorer in the Advanced section of the dashboard.

Endpoints

MethodPathDescription
GET/api/database/statusDatabase connection status
GET/api/database/configDatabase configuration
GET/api/database/tablesList all tables
POST/api/database/queryRun a read-only SQL query

GET /api/database/status

Returns the current database connection status.

Response

json
{
  "provider": "pglite",
  "connected": true,
  "serverVersion": "16.0",
  "tableCount": 42,
  "pgliteDataDir": "~/.eliza/workspace/.eliza/.elizadb",
  "postgresHost": null
}
FieldTypeDescription
providerstring"pglite" or "postgres"
connectedbooleanWhether the database is reachable
serverVersionstringPostgreSQL version
tableCountnumberTotal number of tables
pgliteDataDirstring | nullData directory for PGLite (null for Postgres)
postgresHoststring | nullHostname for Postgres (null for PGLite)

GET /api/database/config

Returns the current database configuration and whether a restart is needed to apply changes.

Response

json
{
  "config": {},
  "activeProvider": "pglite",
  "needsRestart": false
}
FieldTypeDescription
configobjectCurrent database configuration
activeProviderstringThe active provider ("pglite" or "postgres")
needsRestartbooleanWhether config changes require a restart

GET /api/database/tables

List all tables in the database.

Response

json
{
  "tables": [
    "accounts",
    "memories",
    "goals",
    "participants",
    "rooms"
  ]
}

POST /api/database/query

Run a read-only SQL query against the database.

<Warning> This endpoint is restricted to SELECT queries. Mutation queries (INSERT, UPDATE, DELETE, DROP, etc.) are rejected. </Warning>

Request body

FieldTypeRequiredDescription
querystringYesSQL SELECT query

Response

json
{
  "columns": ["id", "name"],
  "rows": [["uuid-1", "Agent 1"]],
  "rowCount": 1,
  "durationMs": 3
}
FieldTypeDescription
columnsstring[]Column names
rowsarray[]Row data as arrays of values
rowCountnumberNumber of rows returned
durationMsnumberQuery execution time in milliseconds