Complete API documentation for the Smart Doorbell Dashboard.
- Development:
http://localhost:3001/api - Production:
https://your-domain.com/api
Most endpoints require a webhook token for security:
# Set token in headers
Authorization: Bearer YOUR_WEBHOOK_TOKENConfigure the token in Settings or via environment variable WEBHOOK_TOKEN.
Primary endpoint for receiving doorbell events from Home Assistant.
application/json- JSON payloadmultipart/form-data- With image upload
| Field | Type | Description |
|---|---|---|
ai_message |
string | AI-generated visitor description |
location |
string | Doorbell location (e.g., "Front Door") |
| Field | Type | Description |
|---|---|---|
ai_title |
string | Event title/summary |
image_url |
string | Visitor image URL |
confidence_score |
number | AI confidence (0-100) |
objects_detected |
string | Comma-separated detected objects |
device_name |
string | Camera device name |
weather_temperature |
number | Temperature in °C |
weather_humidity |
number | Humidity percentage |
weather_condition |
string | Weather condition |
weather_wind_speed |
number | Wind speed |
weather_pressure |
number | Atmospheric pressure |
curl -X POST http://localhost:3001/api/webhook/doorbell \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"ai_message": "Delivery person with package at front door",
"ai_title": "Package Delivery",
"location": "Front Door",
"confidence_score": 95,
"objects_detected": "person, package, delivery_truck",
"weather_temperature": 22.5,
"weather_condition": "sunny"
}'{
"success": true,
"visitor_id": "uuid-string",
"message": "Event recorded successfully"
}Retrieve paginated visitor list with optional filtering.
| Parameter | Type | Default | Description |
|---|---|---|---|
page |
number | 1 | Page number |
limit |
number | 20 | Items per page |
search |
string | - | Search in messages and locations |
curl "http://localhost:3001/api/visitors?page=1&limit=10&search=delivery"{
"visitors": [
{
"id": 1,
"visitor_id": "uuid-string",
"timestamp": "2024-01-01T12:00:00.000Z",
"ai_message": "Delivery person with package",
"ai_title": "Package Delivery",
"location": "Front Door",
"image_url": "/uploads/image.jpg",
"confidence_score": 95,
"weather_temperature": 22.5,
"weather_condition": "sunny"
}
],
"total": 100,
"page": 1,
"limit": 10,
"hasMore": true
}Get specific visitor details.
{
"id": 1,
"visitor_id": "uuid-string",
"timestamp": "2024-01-01T12:00:00.000Z",
"ai_message": "Delivery person with package",
"location": "Front Door",
"weather_data": "{\"temperature\":22.5,\"condition\":\"sunny\"}"
}Delete a specific visitor record.
{
"success": true,
"message": "Visitor deleted successfully"
}Get dashboard statistics.
{
"today": 5,
"week": 23,
"month": 78,
"total": 234,
"peakHour": 14,
"isOnline": true
}Get database statistics and health information.
{
"totalEvents": 234,
"databaseSize": "2.5 MB",
"oldestEvent": "2024-01-01T00:00:00.000Z",
"newestEvent": "2024-01-01T23:59:59.000Z"
}Clear all events from database (destructive operation).
{
"success": true,
"deletedCount": 234,
"message": "All events cleared successfully"
}Get current webhook configuration.
{
"webhookPath": "/api/webhook/doorbell",
"hasToken": true,
"tokenLength": 32,
"allowedOrigins": ["http://localhost:8080"]
}Update webhook configuration.
{
"webhookToken": "new-secure-token",
"webhookPath": "/api/webhook/doorbell"
}Send test webhook to verify configuration.
{
"success": true,
"message": "Test webhook sent successfully"
}Basic health check endpoint.
{
"status": "ok",
"timestamp": "2024-01-01T12:00:00.000Z",
"uptime": 3600,
"environment": "development"
}Connect to WebSocket at ws://localhost:3001 for real-time updates.
{
"type": "new_visitor",
"data": {
"id": 1,
"visitor_id": "uuid-string",
"ai_message": "New visitor detected",
"location": "Front Door"
}
}{
"type": "stats_update",
"data": {
"today": 6,
"week": 24,
"month": 79,
"total": 235
}
}{
"type": "connection_status",
"data": {
"status": "connected"
}
}{
"type": "database_cleared",
"data": {
"deletedCount": 234,
"timestamp": "2024-01-01T12:00:00.000Z"
}
}All endpoints return consistent error formats:
{
"error": "Validation failed",
"message": "ai_message is required",
"code": "VALIDATION_ERROR"
}{
"error": "Unauthorized",
"message": "Invalid or missing webhook token",
"code": "AUTH_ERROR"
}{
"error": "Not Found",
"message": "Visitor not found",
"code": "NOT_FOUND"
}{
"error": "Internal Server Error",
"message": "Database connection failed",
"code": "SERVER_ERROR"
}- Webhook endpoint: 100 requests per minute per IP
- Other endpoints: 1000 requests per minute per IP
- WebSocket: 1 connection per IP
{
"temperature": 22.5,
"humidity": 65,
"condition": "sunny",
"wind_speed": 12.3,
"wind_bearing": 245,
"pressure": 1013.2,
"visibility": 10.0,
"forecast": [
{
"datetime": "2024-01-01T12:00:00+00:00",
"temperature": 24.1,
"templow": 18.2,
"condition": "partly-cloudy",
"precipitation": 0.0
}
]
}sunny,clear-night,partly-cloudy,cloudyrainy,snowy,fog,windylightning,hail,hurricane
For interactive API testing, visit /api-docs in the running application.