REST API Documentation
Server-side API for retrieving analytics data, managing websites, and building custom integrations with SiteTooling.space.
Base URL
https://api.sitetooling.space/v1All API endpoints are prefixed with this base URL. The current API version is v1.
Authentication
The REST API uses Bearer token authentication. Include your secret API key in the Authorization header:
Authorization: Bearer st_secret_your_api_key_hereKeep Your API Key Secret
Never expose your secret API key in client-side code. Use it only for server-side requests.
Analytics Data
Get Analytics Data
GET/analyticsRetrieve aggregated analytics data for your website.
Parameters
| Parameter | Type | Description |
|---|---|---|
| token | string | Your website tracking token (required) |
| period | string | Time period: 7d, 30d, 90d, 365d (default: 30d) |
| metrics | string | Comma-separated list of metrics to include |
Example Request
curl -X GET "https://api.sitetooling.space/v1/analytics?token=st_live_123&period=7d" \
-H "Authorization: Bearer st_secret_your_api_key" \
-H "Content-Type: application/json"Example Response
{
"success": true,
"data": {
"summary": {
"page_views": 1250,
"unique_visitors": 892,
"avg_session_duration": 142,
"bounce_rate": 0.42
},
"top_pages": [
{
"path": "/",
"views": 456,
"unique_visitors": 324
}
],
"referrers": [
{
"source": "google.com",
"visitors": 234
}
]
},
"meta": {
"period": "7d",
"timestamp": "2024-01-15T10:30:00Z"
}
}Real-time Analytics
GET/analytics/realtimeGet real-time visitor activity and current active users.
Example Response
{
"success": true,
"data": {
"active_visitors": 23,
"current_pages": [
{
"path": "/",
"visitors": 8
},
{
"path": "/docs",
"visitors": 5
}
],
"recent_events": [
{
"recent_events": [
{
"type": "page_view",
"path": "/pricing",
"timestamp": "2024-01-15T10:29:45Z",
"country": "US"
}
]
}
}Website Management
List Websites
GET/websitesGet a list of all websites registered under your account.
Example Response
{
"success": true,
"data": [
{
"id": "web_123456789",
"domain": "example.com",
"token": "st_live_abcdef123456",
"created_at": "2024-01-01T00:00:00Z",
"status": "active"
}
],
"meta": {
"total": 1,
"page": 1
}
}Register New Website
POST/websitesRegister a new website to start tracking analytics.
Request Body
{
"domain": "example.com",
"email": "admin@example.com"
}Example Response
{
"success": true,
"data": {
"id": "web_123456789",
"domain": "example.com",
"token": "st_live_abcdef123456",
"status": "active"
}
}Data Export
Export Analytics Data
GET/exportExport your analytics data in CSV or JSON format. Limited to 10 requests per hour.
Parameters
| Parameter | Type | Description |
|---|---|---|
| token | string | Website tracking token (required) |
| format | string | Export format: csv, json (default: json) |
| start_date | string | Start date (YYYY-MM-DD format) |
| end_date | string | End date (YYYY-MM-DD format) |
Example Request
curl -X GET "https://api.sitetooling.space/v1/export?token=st_live_123&format=csv&start_date=2024-01-01&end_date=2024-01-31" \
-H "Authorization: Bearer st_secret_your_api_key"Error Codes
The API uses conventional HTTP response codes and returns detailed error information.
200400401403404429500SDK Examples
JavaScript (Node.js)
const response = await fetch('https://api.sitetooling.space/v1/analytics?token=st_live_123', {
method: 'GET',
headers: {
'Authorization': 'Bearer st_secret_your_key',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);Python
import requests
url = "https://api.sitetooling.space/v1/analytics"
headers = {
"Authorization": "Bearer st_secret_your_key",
"Content-Type": "application/json"
}
params = {"token": "st_live_123"}
response = requests.get(url, headers=headers, params=params)
data = response.json()
print(data)PHP
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "https://api.sitetooling.space/v1/analytics?token=st_live_123",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer st_secret_your_key",
"Content-Type: application/json"
]
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);cURL
curl -X GET \
"https://api.sitetooling.space/v1/analytics?token=st_live_123" \
-H "Authorization: Bearer st_secret_your_key" \
-H "Content-Type: application/json"