Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AngelAmoSanchez/TFG-RaspberryPi-BLE/llms.txt

Use this file to discover all available pages before exploring further.

The RaspberryPi BLE People Counter backend exposes a versioned REST API built with FastAPI. All data routes are mounted under /api/v1, and two unversioned utility endpoints (/ and /health) are available at the root of the server. The API is served by a single FastAPI application instance that also manages a PostgreSQL database connection and an optional MQTT subscriber on startup.

Base URL

http://<host>:<port>/api/v1
By default the server binds to 0.0.0.0:8000, so on a local machine the base URL is:
http://localhost:8000/api/v1
The API version string is v1, sourced from the api_version field in src/config.py. All five route prefixes below are mounted relative to this base:
PrefixDescription
/detectionsSubmit and query raw BLE detection records
/statisticsAggregated people-count statistics
/devicesRegister and manage Raspberry Pi sensor nodes
/exportDownload detection data as CSV
/settingsConfigure RSSI zone classification thresholds

Root endpoint

GET / returns basic application metadata. It does not require authentication and is useful for confirming the server is reachable. Response
app
string
Application name. Defaults to "TFG Bluetooth Detection Backend".
version
string
API version string, e.g. "v1".
environment
string
Deployment environment derived from the ENVIRONMENT environment variable, e.g. "development" or "production".
status
string
Always "running" when the server is accepting requests.
curl http://localhost:8000/
{
  "app": "TFG Bluetooth Detection Backend",
  "version": "v1",
  "environment": "development",
  "status": "running"
}

Health check endpoint

GET /health returns the current health status of the server, including the number of active WebSocket connections. This endpoint is suitable for use with container orchestration liveness probes. Response
status
string
Always "healthy" while the server is running.
timestamp
string
ISO 8601 timestamp of the server’s current time in the Europe/Madrid timezone.
websocket_connections
number
Count of currently open WebSocket connections managed by ws_manager.
curl http://localhost:8000/health
{
  "status": "healthy",
  "timestamp": "2026-05-15T12:34:56.789000+02:00",
  "websocket_connections": 2
}

Authentication

The API does not enforce authentication by default. An optional API_KEY can be set via the API_KEY environment variable (see src/config.py). When configured, clients should pass the key in a request header. The SECRET_KEY environment variable is used internally for session signing and is separate from API_KEY.
In the current codebase, API key validation is not applied at the router level. If your deployment requires it, add a dependency that checks the X-API-Key header against settings.api_key in src/config.py.
CORS is pre-configured to allow requests from http://localhost:3000, http://localhost:5173, http://127.0.0.1:5173, and https://*.vercel.app. The Content-Disposition header is exposed so that CSV downloads work correctly in browsers.

Endpoint pages

Build docs developers (and LLMs) love