The WebSocket endpointDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/GustavoNightmare/InformacionMuseo/llms.txt
Use this file to discover all available pages before exploring further.
ws://localhost:8010/ws/qr-stream provides a persistent, low-latency channel for streaming JPEG frames from a camera and receiving species information the moment a QR code is recognised. Unlike the HTTP frame endpoints, the connection stays open across multiple frames — the server simply discards frames where no QR is detected and closes cleanly after the first successful detection.
WS /ws/qr-stream
Protocol: WebSocket (RFC 6455)Authentication:
?key=<TTS_API_KEY> query parameter — validated immediately after the connection is accepted, before any frame processing begins.
Connection URL
Query Parameters
Your
TTS_API_KEY. Checked before the first frame is processed. An invalid or missing key triggers an error message followed by a close with code 1008 (Policy Violation).Narration style for the
text field in the qr_found message. One of ficha, narrativo, corto. Defaults to ficha. An invalid value triggers an error message and close 1011.Frame Format
After the connection is established, the client sends binary messages containing raw JPEG bytes. Each message must be a single complete JPEG image — partial or multi-frame messages are not supported. The server runs the same four-stage QR detection pipeline used by the HTTP endpoints:- Color — detection on original BGR frame
- Grayscale — single-channel conversion
- Otsu threshold — binarisation
- 2× upscale — cubic interpolation on grayscale
Every frame received via the WebSocket is saved to
DEBUG_FRAMES_DIR with a timestamped filename (e.g. incoming_ws_1712345678.jpg). The last received frame is also always accessible at /debug/last-frame. Clear or rotate DEBUG_FRAMES_DIR periodically in production to avoid unbounded disk usage.Server → Client Messages
The server only ever sends JSON text messages. There are two possible message types.error
Sent when authentication fails or an unhandled exception occurs during frame processing. The connection is closed by the server immediately after sending this message.
| Close Code | Meaning |
|---|---|
1008 | Policy violation — authentication failure |
1011 | Internal error — unexpected exception during processing |
qr_found
Sent once when a valid QR code is successfully detected and the species payload is resolved. After sending this message the server closes the connection cleanly with code 1000.
Always
"qr_found".Always
true in this message type.Raw QR code value decoded from the frame.
Canonical species ID resolved from the QR index.
Narration text for the species in the requested
style.Full set of cleaned species fields:
species_id, qr_id, common_name, scientific_name, description, habitat, diet, curiosities.Detection strategy that succeeded:
color, grayscale, threshold_otsu, or upscaled_gray.The WebSocket connection closes after the first successful QR detection. To scan a second exhibit, the client must open a new connection. This is by design — it prevents stale frame data from triggering duplicate detections after an exhibit has already been identified.
Connection Lifecycle
JavaScript Client Example
Error Reference
| Close Code | type | detail | Cause |
|---|---|---|---|
1008 | error | "unauthorized" | key param missing or does not match TTS_API_KEY |
1011 | error | "invalid_style" | style param not one of ficha, narrativo, corto |
1011 | error | "species_audio_not_found" | QR detected but not in _qr_index.json |
1011 | error | "species_meta_not_found" | Index entry exists but meta.json is missing |
1011 | error | exception message | Unexpected server-side error during frame processing |
1000 | (no message after qr_found) | — | Server closes cleanly after the first successful QR detection |