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 export route provides a single endpoint that streams detection records as a UTF-8 CSV file. Filters can be combined to narrow the export to a specific time window, proximity zone, or Raspberry Pi node. The filename in the Content-Disposition header is generated automatically based on the filters you apply.
The Content-Disposition header is exposed by the CORS middleware, so browser-based downloads work without additional configuration.

GET /api/v1/export/detections/csv

Download detection records as a CSV file. Results are ordered by descending timestamp (most recent first). Query parameters Time filters — at most one time-filter group should be supplied. When multiple are provided, the server applies them in the priority order listed below.
start_date
string
Start of the export window as YYYY-MM-DD, e.g. 2026-01-01. Must be used together with end_date. The export window for end_date is extended to 23:59:59 of that day so the entire day is included.
end_date
string
End of the export window as YYYY-MM-DD, e.g. 2026-01-31. Must be used together with start_date.
last_minutes
number
Export detections from the last N minutes. Takes priority over last_hours and last_days when start_date/end_date are not supplied.
last_hours
number
Export detections from the last N hours. Takes priority over last_days.
last_days
number
Export detections from the last N days.
Additional filters
zone
string
Filter to a single proximity zone: near, medium, or far. Invalid zone values are silently ignored and the filter is not applied.
device_id
string
Filter to detections submitted by a specific Raspberry Pi node.
Time filter priority When no time filter is supplied the export defaults to the last 24 hours. The selection logic is:
  1. start_date + end_date (specific calendar range)
  2. last_minutes
  3. last_hours
  4. last_days
  5. Default: last 24 hours
Response Returns a text/csv file download. The Content-Disposition header is set to attachment; filename=<generated_name>.csv. CSV columns
ColumnDescription
IDInteger primary key of the detection record
Device HashHashed BLE MAC address
RSSI (dBm)Signal strength as a signed integer
ZoneProximity zone: near, medium, or far
TimestampFull ISO 8601 timestamp
Device ID (IoT)Identifier of the Raspberry Pi that recorded the detection
DateDate portion of the timestamp in YYYY-MM-DD format
TimeTime portion of the timestamp in HH:MM:SS format
Filename generation The filename is constructed from the active filter combination:
Filters appliedExample filename
start_date + end_datedetections_2026-01-01_to_2026-01-31.csv
last_minutes=30detections_last_30min.csv
last_hours=6detections_last_6h.csv
last_days=7detections_last_7d.csv
No time filterdetections_last_24h.csv
Any filter + zone=neardetections_last_24h_zone_near.csv
Add --output detections.csv to the curl command to save the file directly instead of printing the CSV to stdout.
Examples
# Export the last 24 hours (default)
curl "http://localhost:8000/api/v1/export/detections/csv" \
  --output detections_last_24h.csv
# Export a specific date range
curl "http://localhost:8000/api/v1/export/detections/csv?start_date=2026-05-01&end_date=2026-05-15" \
  --output detections_may.csv
# Export the last 30 minutes, near zone only
curl "http://localhost:8000/api/v1/export/detections/csv?last_minutes=30&zone=near" \
  --output detections_last_30min_zone_near.csv
# Export the last 7 days from a specific device
curl "http://localhost:8000/api/v1/export/detections/csv?last_days=7&device_id=pi-entrance-01" \
  --output detections_last_7d.csv
Sample CSV output
ID,Device Hash,RSSI (dBm),Zone,Timestamp,Device ID (IoT),Date,Time
1042,a3f1c2b4d5e6f7a8b9c0d1e2f3a4b5c6,-65,near,2026-05-15T10:30:00+02:00,pi-entrance-01,2026-05-15,10:30:00
1041,b4e2d3c5f6a7b8c9d0e1f2a3b4c5d6e7,-78,medium,2026-05-15T10:29:45+02:00,pi-entrance-01,2026-05-15,10:29:45
1040,c5f3e4d6a7b8c9d0e1f2a3b4c5d6e7f8,-91,far,2026-05-15T10:29:30+02:00,pi-floor2-01,2026-05-15,10:29:30

Build docs developers (and LLMs) love