Access your Castlytics data programmatically. Read campaign stats, attribution results, and conversions from any application.
All requests to the Castlytics API require a secret API key. Generate one from your Settings → Developer API section.
Pass the key in the Authorization header:
Authorization: Bearer sk_live_your_api_key_here
Keep your API key secret
Never expose your secret key in client-side code or public repositories. API keys are shown once on creation and cannot be recovered.
https://castlytics.app/api/v1
All endpoints below are relative to this base URL. The API accepts and returns JSON.
| Method | Endpoint |
|---|---|
| GET | /workspace |
| GET | /campaigns |
| GET | /campaigns/:id |
| GET | /campaigns/:id/stats |
| GET | /conversions |
curl https://castlytics.app/api/v1/campaigns \ -H "Authorization: Bearer sk_live_your_api_key_here"
const res = await fetch(
'https://castlytics.app/api/v1/campaigns/CAMPAIGN_ID/stats',
{
headers: {
Authorization: 'Bearer sk_live_your_api_key_here',
},
}
);
const { data } = await res.json();
console.log(data.clicks, data.revenue, data.roas);const res = await fetch(
'https://castlytics.app/api/v1/conversions?limit=100&offset=0',
{ headers: { Authorization: 'Bearer sk_live_your_api_key_here' } }
);
const { data, total } = await res.json();
console.log(`${data.length} of ${total} conversions`);All successful responses return JSON with a data key containing the result. Errors return an error string.
// Success
{ "data": { ... } }
// List
{ "data": [...], "total": 312, "limit": 50, "offset": 0 }
// Error
{ "error": "Unauthorized" } // HTTP 401| HTTP Status | Meaning |
|---|---|
200 | Success |
401 | Missing or invalid API key |
404 | Resource not found |
400 | Bad request (validation error) |