Webhooks & Public API
Outgoing webhooks and REST API for real-time data streaming
BuddyStat provides two integration methods: outgoing webhooks for push-based event streaming and a REST API for pull-based data access.
Outgoing Webhooks
Webhooks allow BuddyStat to send real-time event data to your own servers via HTTP POST requests.
Supported Events
| Event | Description |
|---|---|
session.created | A new session begins |
goal.converted | A visitor completes a tracked goal |
alert.triggered | An alert threshold is crossed |
event.tracked | A custom event is triggered |
Security
Each webhook payload is signed with HMAC-SHA256 using your webhook's secret key. Verify the signature on your end to ensure the payload came from BuddyStat and hasn't been tampered with.
const crypto = require('crypto');
function verifyWebhook(payload, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(JSON.stringify(payload))
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}Delivery
- 10-second timeout — Your endpoint must respond within 10 seconds
- Delivery audit log — Each delivery attempt is logged with status code, response body, and timestamp
- Retry on failure — Failed deliveries are retried automatically
Managing Webhooks
- Go to Site Settings → Webhooks
- Click Add Webhook
- Enter your endpoint URL
- Select which events to receive
- Save and copy your secret key for signature verification
REST API
The public REST API v1 provides programmatic access to your analytics data.
Authentication
Use Bearer token authentication with an API key. Create API keys in Account Settings → API Keys.
Endpoints
| Endpoint | Description |
|---|---|
GET /api/v1/sites | List your sites |
GET /api/v1/sites/:siteId/stats | Dashboard overview stats |
GET /api/v1/sites/:siteId/pages | Page analytics |
GET /api/v1/sites/:siteId/revenue | Revenue metrics |
GET /api/v1/sites/:siteId/experiments | Experiment list |
GET /api/v1/sites/:siteId/sessions | Session data |
GET /api/v1/sites/:siteId/events | Event data |
GET /api/v1/sites/:siteId/events/names | Event names list |
Rate Limits
- 50 requests per minute per API key
- Rate limit headers included in responses (
X-RateLimit-Remaining,X-RateLimit-Reset)
Code Examples
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://app.buddystat.com/api/v1/sites/1/statsconst response = await fetch('https://app.buddystat.com/api/v1/sites/1/stats', {
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
const data = await response.json();import requests
response = requests.get(
'https://app.buddystat.com/api/v1/sites/1/stats',
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
data = response.json()