Analytics API
Real-time and historical analytics for webhook events, deliveries, and source performance.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/analytics | Get analytics overview |
| GET | /api/analytics/events-timeline | Get events timeline |
| GET | /api/analytics/stream | SSE real-time stream |
Analytics Overview
http
GET /api/analyticsQuery Parameters
| Parameter | Type | Description |
|---|---|---|
| period | string | Time period: 1h, 24h, 7d, 30d (default: 24h) |
| sourceId | string | Filter by source |
| destinationId | string | Filter by destination |
Example
bash
curl "https://api.hookbase.app/api/analytics?period=24h" \
-H "Authorization: Bearer whr_your_api_key"javascript
const response = await fetch('https://api.hookbase.app/api/analytics?period=24h', {
headers: {
'Authorization': 'Bearer whr_your_api_key'
}
});
const data = await response.json();python
import requests
response = requests.get(
'https://api.hookbase.app/api/analytics?period=24h',
headers={'Authorization': 'Bearer whr_your_api_key'}
)
data = response.json()Response
json
{
"period": "24h",
"summary": {
"totalEvents": 15230,
"totalDeliveries": 28100,
"successRate": 98.5,
"avgLatency": 245,
"duplicatesDropped": 120,
"eventsFiltered": 3400
},
"sources": [
{
"id": "src_github",
"name": "GitHub",
"eventsReceived": 8200,
"signatureValid": 8200,
"signatureInvalid": 0,
"duplicatesDropped": 85
},
{
"id": "src_stripe",
"name": "Stripe",
"eventsReceived": 7030,
"signatureValid": 7028,
"signatureInvalid": 2,
"duplicatesDropped": 35
}
],
"destinations": [
{
"id": "dst_api",
"name": "Production API",
"deliveries": 15200,
"succeeded": 15050,
"failed": 150,
"successRate": 99.0,
"avgLatency": 180,
"p50Latency": 120,
"p95Latency": 450,
"p99Latency": 890
}
],
"statusBreakdown": {
"delivered": 27700,
"failed": 200,
"pending": 50,
"retrying": 100,
"circuit_open": 50
}
}Events Timeline
http
GET /api/analytics/events-timelineReturns time-bucketed event counts for charting.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| period | string | Time period: 1h, 24h, 7d, 30d (default: 24h) |
| sourceId | string | Filter by source |
| interval | string | Bucket interval: 1m, 5m, 1h, 1d (auto-selected if omitted) |
Example
bash
curl "https://api.hookbase.app/api/analytics/events-timeline?period=24h" \
-H "Authorization: Bearer whr_your_api_key"javascript
const response = await fetch('https://api.hookbase.app/api/analytics/events-timeline?period=24h', {
headers: {
'Authorization': 'Bearer whr_your_api_key'
}
});
const data = await response.json();python
import requests
response = requests.get(
'https://api.hookbase.app/api/analytics/events-timeline?period=24h',
headers={'Authorization': 'Bearer whr_your_api_key'}
)
data = response.json()Response
json
{
"period": "24h",
"interval": "1h",
"buckets": [
{
"timestamp": "2024-01-15T00:00:00Z",
"eventsReceived": 620,
"deliveriesSucceeded": 1180,
"deliveriesFailed": 12
},
{
"timestamp": "2024-01-15T01:00:00Z",
"eventsReceived": 580,
"deliveriesSucceeded": 1100,
"deliveriesFailed": 8
}
]
}Real-Time Stream
http
GET /api/analytics/streamServer-Sent Events (SSE) stream for real-time dashboard updates.
Example
bash
curl -N "https://api.hookbase.app/api/analytics/stream" \
-H "Authorization: Bearer whr_your_api_key" \
-H "Accept: text/event-stream"javascript
const response = await fetch('https://api.hookbase.app/api/analytics/stream', {
headers: {
'Authorization': 'Bearer whr_your_api_key',
'Accept': 'text/event-stream'
}
});
// Use EventSource API for SSE:
const eventSource = new EventSource('https://api.hookbase.app/api/analytics/stream');python
import requests
response = requests.get(
'https://api.hookbase.app/api/analytics/stream',
headers={
'Authorization': 'Bearer whr_your_api_key',
'Accept': 'text/event-stream'
},
stream=True
)Events
event: stats
data: {"eventsPerMinute": 42, "deliveriesPerMinute": 78, "successRate": 99.1, "avgLatency": 180}
event: event
data: {"id": "evt_abc123", "sourceId": "src_github", "sourceName": "GitHub", "status": "delivered", "receivedAt": "2024-01-15T10:30:00Z"}
event: delivery
data: {"id": "dlv_xyz789", "eventId": "evt_abc123", "destinationName": "Production API", "status": "delivered", "latency": 180}Event Types
| Event | Description | Frequency |
|---|---|---|
stats | Aggregated metrics snapshot | Every 5 seconds |
event | Individual event received | Real-time |
delivery | Individual delivery completed | Real-time |
alert | Failure or circuit breaker alert | On occurrence |
Client Example
javascript
const eventSource = new EventSource(
'https://api.hookbase.app/api/analytics/stream',
{ headers: { 'Authorization': 'Bearer whr_your_api_key' } }
);
eventSource.addEventListener('stats', (e) => {
const stats = JSON.parse(e.data);
console.log(`Events/min: ${stats.eventsPerMinute}`);
});
eventSource.addEventListener('event', (e) => {
const event = JSON.parse(e.data);
console.log(`New event: ${event.id} from ${event.sourceName}`);
});Related
- Events API — Query individual events
- Deliveries API — Query delivery details