API Overview
API Overview
The AI for Database REST API lets you integrate natural-language querying, dashboards, and workflows into your own applications. Everything you can do in the UI is available through the API.
Base URL
https://api.aifordatabase.com/v1For self-hosted deployments, the base URL is your instance's address followed by /api/v1.
Versioning
The API is versioned using URL path prefixes (/v1). We guarantee backward compatibility within a major version. Breaking changes will be released under a new version prefix with a migration guide.
Authentication
All API requests require authentication via a Bearer token in the Authorization header:
curl -H "Authorization: Bearer your_api_key" \
https://api.aifordatabase.com/v1/queriesGenerate API keys in Settings > API Keys. Each key can be scoped to specific permissions (read-only, full access) and has an optional expiration date.
Response Format
All responses are JSON. Successful responses have this structure:
{
"data": { ... },
"meta": {
"request_id": "req_abc123",
"timestamp": "2024-01-15T10:30:00Z"
}
}Error responses:
{
"error": {
"code": "validation_error",
"message": "The 'question' field is required.",
"details": { ... }
},
"meta": {
"request_id": "req_abc123"
}
}Rate Limits
| Plan | Requests/minute | Requests/day |
|---|---|---|
| Free | 30 | 1,000 |
| Pro | 120 | 10,000 |
| Enterprise | Custom | Custom |
Rate limit headers are included in every response:
X-RateLimit-Limit-- your limitX-RateLimit-Remaining-- requests remainingX-RateLimit-Reset-- when the limit resets (Unix timestamp)
Pagination
List endpoints support cursor-based pagination:
GET /v1/queries?limit=20&cursor=cur_abc123The response includes a next_cursor field. Pass it as the cursor parameter to get the next page.
SDKs
We publish official SDKs for:
- JavaScript/TypeScript --
npm install @aifordatabase/sdk - Python --
pip install aifordatabase
Community SDKs are available for Go, Ruby, and PHP.