API Reference
Integrate theBizness.ai analytics programmatically with our REST API. Track events, manage revenue data, and query analytics.
Base URL
thebizness.ai/api
Authentication
Bearer Token
Rate Limit
1000/hour
Authentication
API requests require authentication using Bearer tokens
Getting Your API Key
- 1. Go to your theBizness.ai Dashboard
- 2. Navigate to Settings → API Keys
- 3. Click "Generate New API Key"
- 4. Copy and securely store your key
Using Your API Key
// Using Bearer token authentication
const response = await fetch('https://thebizness.ai/api/events', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-api-key-here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
website_id: 'your-website-id',
event_name: 'custom_event',
properties: {
value: 99.99,
category: 'purchase'
}
})
});
✅ Security Best Practices
- • Store API keys in environment variables
- • Never commit keys to version control
- • Rotate keys regularly
- • Use different keys for development/production
📊 Rate Limits
- • 1000 requests per hour per API key
- • Batch endpoints have higher limits
- • Contact us for higher limits
- • Rate limit headers included in responses
API Endpoints Overview
All available endpoints organized by category
Events
POST
/api/events
POST
/api/events/batch
Revenue
POST
/api/revenue
Analytics
GET
/api/analytics
Websites
GET
/api/websites/{id}
PUT
/api/websites/{id}
Conversion Events
GET
/api/websites/{id}/conversion-events
POST
/api/websites/{id}/conversion-events
Endpoint Details & Examples
Event Tracking
Track custom events and user interactions
// Track custom events
POST https://thebizness.ai/api/events
{
"website_id": "your-website-id",
"event_name": "button_click",
"visitor_id": "optional-visitor-id",
"properties": {
"button_text": "Sign Up",
"page_url": "https://yourdomain.com/pricing",
"value": 29.99
},
"timestamp": "2024-01-15T10:30:00Z"
}
// Response
{
"success": true,
"event_id": "evt_1234567890",
"timestamp": "2024-01-15T10:30:00Z"
}
Event Properties
- •
event_name
- Required. Name of the event - •
visitor_id
- Optional. Unique visitor identifier - •
properties
- Optional. Custom event data - •
timestamp
- Optional. Event timestamp (ISO 8601)
Batch Event Tracking
Send multiple events in a single request for better performance
// Send multiple events in batch
POST https://thebizness.ai/api/events/batch
{
"website_id": "your-website-id",
"events": [
{
"event_name": "page_view",
"properties": {
"page_url": "https://yourdomain.com/home",
"page_title": "Homepage"
},
"timestamp": "2024-01-15T10:30:00Z"
},
{
"event_name": "button_click",
"properties": {
"button_text": "Learn More",
"section": "hero"
},
"timestamp": "2024-01-15T10:30:15Z"
}
]
}
// Response
{
"success": true,
"processed": 2,
"failed": 0,
"event_ids": ["evt_123", "evt_124"]
}
Error Handling
Understanding API error responses and status codes
HTTP Status Codes
200 OK
Success400 Bad Request
Invalid request401 Unauthorized
Invalid API key429 Too Many Requests
Rate limitedError Response Format
{ "success": false, "error": { "code": "INVALID_REQUEST", "message": "Missing required field: website_id", "details": { "field": "website_id", "expected": "string" } } }
Best Practices
- • Always check the
success
field in responses - • Implement proper error handling for all status codes
- • Use exponential backoff for rate limited requests
- • Log API errors for debugging and monitoring