API Connections
Push data to Solinth using our REST API.
10 min readUpdated December 2024
REST API Overview
The Solinth REST API allows you to push events and metrics from your application in real-time. All API requests require authentication via API key.
Base URL
https://api.solinth.com/v1Authentication
Include your API key in the Authorization header:
Authorization: Bearer sk_live_xxxxxxxxxxxxxKeep Your API Key Secure
Never expose your API key in client-side code. Always make API calls from your server or use environment variables.
Endpoints
Track Event
Send a single event to Solinth.
POST /events
const response = await fetch('https://api.solinth.com/v1/events', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + process.env.SOLINTH_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
event: 'purchase',
timestamp: new Date().toISOString(), // Optional, defaults to now
properties: {
amount: 99.00,
currency: 'USD',
customer_id: 'cust_123',
product: 'Pro Plan'
}
})
});
const data = await response.json();
// { success: true, event_id: 'evt_abc123' }Batch Events
Send multiple events in a single request (up to 1000 events).
POST /events/batch
const response = await fetch('https://api.solinth.com/v1/events/batch', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + process.env.SOLINTH_API_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify({
events: [
{ event: 'pageview', properties: { page: '/home' } },
{ event: 'pageview', properties: { page: '/pricing' } },
{ event: 'signup', properties: { plan: 'free' } }
]
})
});
const data = await response.json();
// { success: true, processed: 3 }Query Metrics
Retrieve aggregated metrics from your data.
GET /metrics
const response = await fetch(
'https://api.solinth.com/v1/metrics?' + new URLSearchParams({
event: 'purchase',
metric: 'sum',
property: 'amount',
from: '2024-01-01',
to: '2024-01-31'
}),
{
headers: {
'Authorization': 'Bearer ' + process.env.SOLINTH_API_KEY
}
}
);
const data = await response.json();
// { value: 12500.00, count: 150 }Rate Limits
API rate limits depend on your plan:
- Free: 100 requests/minute
- Pro: 1,000 requests/minute
- Enterprise: 10,000 requests/minute
Rate Limit Headers
Check the
X-RateLimit-Remaining and X-RateLimit-Reset headers to monitor your usage.Error Handling
The API returns standard HTTP status codes:
200- Success400- Bad request (invalid data)401- Unauthorized (invalid API key)429- Rate limit exceeded500- Server error
Error Response
{
"error": {
"code": "INVALID_EVENT",
"message": "Event name is required"
}
}