intermediate5 min read

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/v1

For 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:

bash
curl -H "Authorization: Bearer your_api_key" \
  https://api.aifordatabase.com/v1/queries

Generate 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:

json
{
  "data": { ... },
  "meta": {
    "request_id": "req_abc123",
    "timestamp": "2024-01-15T10:30:00Z"
  }
}

Error responses:

json
{
  "error": {
    "code": "validation_error",
    "message": "The 'question' field is required.",
    "details": { ... }
  },
  "meta": {
    "request_id": "req_abc123"
  }
}

Rate Limits

PlanRequests/minuteRequests/day
Free301,000
Pro12010,000
EnterpriseCustomCustom

Rate limit headers are included in every response:

  • X-RateLimit-Limit -- your limit
  • X-RateLimit-Remaining -- requests remaining
  • X-RateLimit-Reset -- when the limit resets (Unix timestamp)

Pagination

List endpoints support cursor-based pagination:

bash
GET /v1/queries?limit=20&cursor=cur_abc123

The 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.