API

Interact with OpenAnalyst programmatically using the REST API. Authenticate with API keys, query datasets, run agents, and integrate analytics into your own applications.

REST API Overview

The OpenAnalyst REST API provides full programmatic access to the platform. You can query datasets, retrieve reports, trigger AI agent runs, and manage resources — all without using the web interface. The API follows REST conventions and returns JSON responses.

The base URL for all API requests is:

https://api.openanalyst.com/v1

All endpoints require HTTPS. HTTP requests will be redirected to HTTPS automatically.

Authentication

Authenticate API requests by including your API key in the Authorization header using the Bearer scheme.

Authorization: Bearer oa_your_api_key_here

To generate an API key:

  1. Log in to app.openanalyst.com.
  2. Navigate to Settings in the sidebar.
  3. Click the API Keys tab.
  4. Click Generate New Key, give it a descriptive label, and set an optional expiry date.
  5. Copy the key immediately — it will not be shown again.

Warning: API keys grant full access to your workspace. Store them securely using environment variables or a secrets manager. Never commit API keys to source control.

Key Endpoints

The following table summarizes the most commonly used API endpoints:

MethodEndpointDescription
GET/datasetsList all datasets in the workspace.
GET/datasets/:idRetrieve metadata and schema for a specific dataset.
POST/queriesExecute a query against a connected data source.
GET/reportsList all reports in the workspace.
GET/reports/:idRetrieve a specific report and its data.
POST/agents/runTrigger an AI agent run with a task prompt.
GET/agents/runs/:idPoll the status and results of an agent run.
GET/dashboardsList all dashboards in the workspace.

Example Requests

The following examples show how to authenticate and make requests using curl and the JavaScript fetch API.

List datasets using curl

curl -X GET https://api.openanalyst.com/v1/datasets \
  -H "Authorization: Bearer oa_your_api_key_here" \
  -H "Content-Type: application/json"

Execute a query using curl

curl -X POST https://api.openanalyst.com/v1/queries \
  -H "Authorization: Bearer oa_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "dataset_id": "ds_abc123",
    "query": "SELECT date, revenue FROM sales WHERE date >= \'2024-01-01\' ORDER BY date DESC LIMIT 100"
  }'

Run an AI agent using JavaScript fetch

const response = await fetch('https://api.openanalyst.com/v1/agents/run', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer oa_your_api_key_here',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    agent_id: 'agent_xyz789',
    task: 'Summarize weekly sales performance and flag any anomalies.',
    context: {
      dataset_id: 'ds_abc123',
      date_range: { start: '2024-01-01', end: '2024-01-07' },
    },
  }),
});

const data = await response.json();
console.log(data.run_id); // Poll this ID for results

Pagination

List endpoints return paginated results. Use the page and per_page query parameters to control pagination:

GET /datasets?page=2&per_page=25

Each paginated response includes a meta object:

{
  "data": [...],
  "meta": {
    "page": 2,
    "per_page": 25,
    "total": 143,
    "total_pages": 6
  }
}

Rate Limits

API rate limits are applied per workspace and vary by plan:

PlanRequests per minuteRequests per day
Free30500
Basic1205,000
Pro60050,000
Max1,200200,000
EnterpriseCustomCustom

When a rate limit is exceeded, the API returns a 429 Too Many Requests response. The Retry-After header indicates how many seconds to wait before retrying.

Error Handling

The API uses standard HTTP status codes. Error responses include a JSON body with a code and message field:

{
  "error": {
    "code": "DATASET_NOT_FOUND",
    "message": "No dataset with the given ID exists in this workspace.",
    "status": 404
  }
}

Common error codes:

HTTP StatusCodeMeaning
401UNAUTHORIZEDMissing or invalid API key.
403FORBIDDENThe API key does not have permission for this action.
404NOT_FOUNDThe requested resource does not exist.
422VALIDATION_ERRORThe request body failed validation.
429RATE_LIMITEDToo many requests. Check the Retry-After header.
500INTERNAL_ERRORAn unexpected server-side error occurred.

Webhook Callbacks

For long-running operations such as agent runs and large query executions, you can provide a webhook URL to receive a callback when the operation completes, rather than polling.

curl -X POST https://api.openanalyst.com/v1/agents/run \
  -H "Authorization: Bearer oa_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agent_xyz789",
    "task": "Generate monthly revenue summary.",
    "webhook_url": "https://your-app.com/webhooks/openanalyst"
  }'

OpenAnalyst will send a POST request to the provided URL with a JSON payload containing the run ID, status, and result when the operation finishes. Webhook payloads are signed with an X-OpenAnalyst-Signature header for verification.

Note: Webhook URLs must use HTTPS and must respond with a 2xx status code within 10 seconds. Failed deliveries are retried up to 5 times with exponential backoff.