DriverCard REST API¶
1. Scope and source status¶
Contract inspected in drivercard_rest_api.py, working tree based on 063f794294f0e05df5756def7b6aabc2367a76f2, 2026-11-04, application source version 1.1.0-beta9. Local changes are not a shipped-build guarantee. Validate the intended target build before integration. This reference describes existing behavior; it introduces no new API behavior.
The parser produces a response from supplied bytes. It does not persist an archive or import. Archive ingestion and mobile intake are separate workflows. Read operations query existing analysis data.
2. Address and formats¶
The desktop binds its own dynamically assigned loopback port. Use the base URL displayed by the running application; the bundled week view receives that actual address automatically. Driver routes accept loopback clients only and require Authorization: Bearer <session-token>. The authenticated desktop creates an in-memory credential bound to its user, licence and current archive.read permission, with a maximum lifetime of eight hours. Logout, user change and account deactivation invalidate access. Local sessions additionally reject disabled local login, account lock, required password change or password changes. Verified Microsoft/Google SSO sessions instead require an enabled provider and unchanged linked identity mapping; local password flags do not block these SSO sessions. Query parameters and asserted X-User/X-Role headers cannot authenticate a caller. There is no anonymous or unattended integration fallback; external clients require a separately approved authentication and transport integration before migration. Listener availability depends on the host/profile and enabled features; a desktop default is not a deployment guarantee. Use the approved integration entry point for the target installation.
JSON uses UTF-8. Dates are YYYY-MM-DD. Parse metadata timestamps use local datetime.now() without an explicit offset; do not assume UTC. Public /health returns only ok and service; it does not expose listener configuration, time or database readiness. Durations in normalized parse activities are seconds. Other result columns follow the corresponding repository projection.
3. Common read filters¶
date_from defaults to today minus 30 days, date_to to today. The first ten characters are parsed as a date; reversed ranges return 400. Name/card filters are last_name, first_name, card_number, driving_license_number. A nonempty value without % or _ is wrapped in %; matching is SQL LIKE, not guaranteed exact matching. time-summary also accepts grouping=day|week|month (default day). EU analysis accepts multi_manning (default false).
import_id, archive_id, limit and offset are not implemented common filters in this controller. Imports returns all repository import rows with empty returned filters, although the common date validation still runs.
4. Operations¶
| Method/path | Function and response |
|---|---|
GET /health |
HTTP process response: ok, service=drivercard_rest_api; public process liveness only, no database readiness probe |
POST /api/drivercard/parse |
Parse supplied bytes; response has ok, meta, card, activities, week_index, events, faults, vehicles_used, positions, raw |
GET /api/drivercard/imports |
Existing imports; data.type=imports |
GET /api/drivercard/time-summary |
Repository activity totals; data.type=time_summary |
GET /api/drivercard/activities |
Activity details; data.type=activities |
GET /api/drivercard/events |
Card events; data.type=events |
GET /api/drivercard/faults |
Card faults; data.type=faults |
GET /api/drivercard/vehicles-used |
Recorded vehicles; data.type=vehicles_used |
GET /api/drivercard/positions |
Recorded positions; data.type=positions |
GET /api/drivercard/day-overview |
Activity intervals grouped by day; data.type=day_overview |
GET /api/drivercard/week-overview |
Activity intervals grouped by ISO week; data.type=week_overview |
GET /api/drivercard/eu561/violations |
Technical EU 561/2006 evaluation; ok, data with filters, count, legal_notice and analysis report |
List responses use {"ok":true,"data":{"type":"activities","count":0,"filters":{},"items":[]}} (illustrative empty result; actual filters are returned). Day/week responses use the same envelope, with grouped periods, activities and totals inside items; week periods also contain days. EU analysis is a technical pre-check, not an authority or legal decision.
5. Health example¶
GET /health HTTP/1.1
Host: 127.0.0.1:49152
{"ok":true,"service":"drivercard_rest_api"}
No credentials are needed for this minimal health response.
6. Parse input and effects¶
Use multipart field file with a nonempty filename and body, or JSON:
{"file_name":"synthetic.ddd","ddd_base64":"AA=="}
This is a shape example, not a valid DDD fixture. JSON file_name defaults to drivercard.ddd. Multipart takes precedence when file is present. The handler creates and removes a temporary file and writes diagnostics. It does not return a new import/archive identity or an idempotency receipt. content_base64 and a submitted archive_id do not implement the formerly described import contract. raw contains generation and activity-day data; do not assume a response excludes every original parsed field.
7. Read example¶
GET /api/drivercard/activities?date_from=2026-10-01&date_to=2026-10-02&card_number=1000
The card filter above is a partial LIKE filter. Day/week endpoints derive views from existing intervals. Parsing bytes through this endpoint does not populate those database read endpoints.
8. Errors¶
Successful handlers return 200. Driver routes return 401/authentication_required when the Bearer header is absent, 403/access_denied for an invalid/revoked/expired or no-longer-authorized session, 403/local_access_required for non-loopback traffic and 503/authorization_unavailable if authorization cannot be checked. A valid token does not override the loopback requirement. Responses use no-store; successful results are rechecked before emission so revocation during work discards the body. Parse rejects missing filename, missing/empty content and invalid Base64 with {"ok":false,"error":"..."} and 400; parser exceptions return 500 with this error envelope. Read filter ValueError returns 400; other repository/analysis failures return 500. The upload limit is now 128 MiB; exceeding it returns 413/upload_too_large. There is no parse 409/422 contract. Standard framework routing errors can have a different body. Clients must not require a separate message property.
9. Compatibility and acceptance¶
The bundled browser week view uses an authenticated local proxy. REST credentials stay in the desktop/server process; the browser receives a separate HttpOnly, SameSite=Strict cookie after a capability exchange. Proxy POSTs require its exact origin. Health proxy routing resolves /health, and cached preload data remains subject to current authorization. Upstream redirects and environment HTTP proxies are disabled; CSP restricts scripts/connections to the same origin and prevents framing.
Preserve method/path, field names and filter semantics when integrating; anonymous callers must migrate before this source is released. Import-list statistics read the V2 activity observations while preserving activity_count/activity_from/activity_to and ordering. Check valid synthetic DDD, malformed/empty payloads, default and explicit filters, database results and timeline rendering against the intended build. Source inspection is not an executed HTTP, frozen-build or installed-service acceptance. No production data was used for this documentation review.
10. Related integration¶
Mobile archive intake is documented separately in mobile integration. This page does not define future mobile deadline/history query endpoints.