/

Loading...
Integrate DataChonk into your workflows with our REST API. Generate dbt code, analyze projects, and interact with the AI assistant programmatically.
https://datachonk.dev/apiInclude your API key in the Authorization header:
Authorization: Bearer your_api_key_here
Content-Type: application/jsonGet your API key from the Settings page in your dashboard.
Here's an example of generating a staging model using the API:
curl -X POST https://datachonk.dev/api/generate \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"type": "staging",
"source": "raw.stripe.payments",
"options": {
"addTests": true,
"addDocs": true
}
}'All API responses are JSON and follow this structure:
{
"success": true,
"data": {
"code": "-- Generated SQL...",
"schema": "version: 2\nmodels:...",
"tests": ["not_null", "unique"],
"warnings": []
},
"meta": {
"requestId": "req_abc123",
"timestamp": "2024-01-15T10:30:00Z",
"tokensUsed": 1250
}
}{
"success": false,
"error": {
"code": "INVALID_SOURCE",
"message": "Source table not found: raw.stripe.payments",
"details": {
"suggestion": "Check that the source exists and you have access"
}
},
"meta": {
"requestId": "req_xyz789"
}
}| Code | HTTP Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Invalid or missing API key |
FORBIDDEN | 403 | API key doesn't have required permissions |
NOT_FOUND | 404 | Resource not found |
RATE_LIMITED | 429 | Too many requests |
INVALID_REQUEST | 400 | Malformed request body |
INVALID_SOURCE | 400 | Source table/model not found |
GENERATION_FAILED | 500 | AI generation failed |
CONNECTION_FAILED | 502 | Database connection failed |
Official client libraries are coming soon. In the meantime, use the CLI or REST API directly.