https://realtime.gurpreetsandhu.tech/api/v1
API Reference
The AnalyticsPro REST API lets you programmatically ingest analytics data, query KPIs, manage alerts, and generate reports. All endpoints return JSON and require a Bearer token obtained via /api/v1/auth/login.
Sanctum Tokens
Per-user API tokens with configurable scopes. Tokens do not expire unless revoked.
Rate Limited
Auth: 10 req/min · Ingest: 30 req/min · Other: 60 req/min per token.
JSON Only
All requests and responses use application/json. Always set Accept: application/json.
Authentication
After logging in, include the token in every request using the Authorization header.
/api/v1/auth/logout to revoke the current token programmatically.
Errors & Rate Limits
All errors return a consistent JSON structure. HTTP status codes follow REST conventions.
Auth Endpoints
Register
Create a new user account and immediately receive a Sanctum token. Rate limited to 10 requests/minute.
/api/v1/auth/register
Public · No token required
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | required | Full name, 2–100 chars |
| string | required | Unique email address | |
| password | string | required | Min 8 chars |
| password_confirmation | string | required | Must match password |
Login
Authenticate with email & password to receive a Bearer token. Any previous tokens remain active.
/api/v1/auth/login
Public · No token required
| Field | Type | Required | Description |
|---|---|---|---|
| string | required | Registered email address | |
| password | string | required | Account password |
Get Current User
Returns the authenticated user's profile, role, and permissions.
/api/v1/auth/me
🔒 Bearer token required
Logout
Revokes the current Bearer token. The token is immediately invalid.
/api/v1/auth/logout
🔒 Bearer token required
Analytics Endpoints
List Analytics Data
Returns paginated raw analytics records. Filterable by metric and date range. Requires view-analytics permission.
/api/v1/analytics
🔒 view-analytics
| Query Param | Type | Required | Description |
|---|---|---|---|
| metric_type | string | optional | Filter by metric: revenue, users, orders, conversion_rate, bounce_rate, session_duration, page_views |
| from | date | optional | Start date (Y-m-d) |
| to | date | optional | End date (Y-m-d) |
| per_page | integer | optional | Page size, default 30, max 100 |
Ingest Analytics Data
Push a new analytics data point. Triggers alert rule evaluation immediately. Rate limited to 30 req/min.
/api/v1/analytics
🔒 Bearer token · 30/min
| Field | Type | Required | Description |
|---|---|---|---|
| metric_type | string | required | revenue · users · orders · conversion_rate · bounce_rate · session_duration · page_views |
| value | numeric | required | Decimal metric value |
| recorded_at | date | optional | Y-m-d, defaults to today |
| category | string | optional | Revenue category label |
| source | string | optional | Traffic source label |
KPI Summary
Returns aggregated KPIs for the requested period vs previous period, with trend direction.
/api/v1/analytics/kpi?period=30
🔒 view-analytics · cached
| Query Param | Type | Description |
|---|---|---|
| period | integer | 7, 14, or 30 days. Default: 7 |
Chart Data
Returns time-series labels + data arrays for charting a single metric.
/api/v1/analytics/chart/{metric}
🔒 view-analytics
| Param | Type | Description |
|---|---|---|
| metric (path) | string | revenue · users · orders · bounce_rate · session_duration · page_views |
| period | integer | 7, 14, or 30 days |
Revenue by Category
Returns revenue percentage breakdown per category for pie/donut charts.
/api/v1/analytics/categories
Alert Endpoints
List Alerts
Returns paginated triggered alerts for the authenticated user. Filterable by status and severity.
/api/v1/alerts
🔒 manage-alerts
| Query Param | Type | Description |
|---|---|---|
| status | string | unread · read · resolved |
| severity | string | critical · warning · info |
| per_page | integer | Default 20 |
Mark Alert as Read
Changes an alert's status from unread to read. Alert remains active.
/api/v1/alerts/{id}/read
Resolve Alert
Marks an alert as resolved. Sets resolved_at timestamp and fires the alert-resolved event.
/api/v1/alerts/{id}/resolve
Alert Rule Endpoints
List Alert Rules
/api/v1/alert-rules
Create Alert Rule
Define a new threshold rule. Rules are evaluated on every data ingest.
/api/v1/alert-rules
🔒 manage-alerts
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | required | Descriptive rule name |
| metric_type | string | required | revenue · users · orders · conversion_rate · bounce_rate |
| operator | string | required | < · > · <= · >= · = |
| threshold | numeric | required | Trigger value |
| severity | string | required | critical · warning · info |
| is_active | boolean | optional | Default: true |
Delete Alert Rule
/api/v1/alert-rules/{id}
🔒 manage-alerts
Report Endpoints
List Reports
/api/v1/reports
🔒 view-reports
Create Report
Queues a new report for async generation. Initial status is draft.
/api/v1/reports
🔒 create-reports
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | required | Report display name |
| type | string | required | daily · weekly · monthly |
| scheduled_at | datetime | optional | ISO 8601, defaults to now |
Get Report
/api/v1/reports/{id}
🔒 view-reports
Delete Report
Permanently deletes a report. Requires delete-reports permission (Admin only).
/api/v1/reports/{id}
🔒 delete-reports