POST /api/admin-stats
POST /api/admin-stats
Get dashboard statistics for the zpreorder admin interface.
Request
Method
POST
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {ADMIN_API_TOKEN} |
| Content-Type | application/json |
Body
Empty object or no body required.
{}
Response
Success (200)
{
"success": true,
"stats": {
"notify": {
"total": 15,
"byStatus": {
"pending": 10,
"notified": 3,
"unsubscribed": 2
},
"byProduct": {
"oxi-one-mk2": 8,
"n32b-slim": 5,
"module-x": 2
}
},
"reservations": {
"total": 12,
"byStatus": {
"pending": 5,
"confirmed": 4,
"fulfilled": 2,
"cancelled": 1
},
"byProduct": {
"oxi-one-mk2": 6,
"n32b-slim": 4,
"module-x": 2
}
}
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
stats.notify.total | number | Total notify subscriptions |
stats.notify.byStatus | object | Subscription count by status |
stats.notify.byProduct | object | Subscription count by product slug |
stats.reservations.total | number | Total reservations |
stats.reservations.byStatus | object | Reservation count by status |
stats.reservations.byProduct | object | Reservation count by product slug |
Unauthorized (401)
{
"success": false,
"error": "Unauthorized"
}
Server Error (500)
{
"success": false,
"error": "Internal server error"
}
Example
cURL
curl -X POST https://takazudomodular.com/api/admin-stats \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json"
JavaScript (fetch)
const response = await fetch('/api/admin-stats', {
method: 'POST',
headers: {
'Authorization': `Bearer ${ADMIN_API_TOKEN}`,
'Content-Type': 'application/json',
},
});
const data = await response.json();
if (data.success) {
console.log('Notify stats:', data.stats.notify);
console.log('Reservation stats:', data.stats.reservations);
}
Implementation Details
Source File
netlify/functions/admin-stats.ts
Behavior
- Validates Bearer token authentication
- Fetches all notify subscriptions from Netlify Blobs
- Fetches all reservations from Netlify Blobs
- Aggregates counts by status and product
- Returns combined statistics
Related
- POST /api/admin-notify-list - List notify subscriptions
- POST /api/admin-reservations-list - List reservations