Skip to content

Analytics API

Real-time and historical analytics for webhook events, deliveries, and source performance.

Endpoints

MethodPathDescription
GET/api/analyticsGet analytics overview
GET/api/analytics/events-timelineGet events timeline
GET/api/analytics/streamSSE real-time stream

Analytics Overview

http
GET /api/analytics

Query Parameters

ParameterTypeDescription
periodstringTime period: 1h, 24h, 7d, 30d (default: 24h)
sourceIdstringFilter by source
destinationIdstringFilter 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-timeline

Returns time-bucketed event counts for charting.

Query Parameters

ParameterTypeDescription
periodstringTime period: 1h, 24h, 7d, 30d (default: 24h)
sourceIdstringFilter by source
intervalstringBucket 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/stream

Server-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

EventDescriptionFrequency
statsAggregated metrics snapshotEvery 5 seconds
eventIndividual event receivedReal-time
deliveryIndividual delivery completedReal-time
alertFailure or circuit breaker alertOn 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}`);
});

Released under the MIT License.