This directory contains examples for using the HLV-RAPS REST API.
rest_api_demo.cpp: C++ demo server that shows how to integrate the REST API into your applicationapi_client.py: Python client example for querying the APICMakeLists.txt: Build configuration for the C++ demo
cd examples/api_client
cmake -S . -B build
cmake --build build./build/rest_api_demoThe server will start on 0.0.0.0:8080 and provide mock telemetry data.
# Install Python 3 (if not already installed)
# No additional dependencies required - uses only standard library
# Query the API
python3 api_client.py localhost 8080# Health check
curl http://localhost:8080/health
# Get current state
curl http://localhost:8080/api/state
# Get PDT predictions
curl http://localhost:8080/api/pdt
# Get DSM safety status
curl http://localhost:8080/api/dsm
# Get supervisor state
curl http://localhost:8080/api/supervisor
# Get rollback status
curl http://localhost:8080/api/rollback
# Get ITL entries
curl http://localhost:8080/api/itlTo integrate the REST API into your RAPS application:
-
Include the headers:
#include "raps/api/rest_api_server.hpp"
-
Create a snapshot provider:
auto snapshot_provider = []() -> raps::api::SystemSnapshot { raps::api::SystemSnapshot snapshot{}; // Fill in snapshot data from your actual system state // (PDT, DSM, Supervisor, Rollback, ITL, etc.) return snapshot; };
-
Start the API server:
raps::api::RestApiServer api_server; api_server.set_snapshot_provider(snapshot_provider); if (api_server.start(8080, "0.0.0.0")) { std::cout << "API server started\n"; } // Server runs in background thread // ... // Stop on shutdown api_server.stop();
-
Important: The snapshot provider callback runs with mutex protection and should:
- Be fast (avoid blocking the API requests)
- Return consistent snapshots (all data from the same moment)
- Access shared state with proper synchronization
See ../../docs/REST_API.md for complete API documentation.
Important: This API is designed for observability in a trusted LAN environment:
- ✓ Read-only (no control surfaces)
- ✓ Lightweight (no heavy dependencies)
- ✓ Thread-safe (mutex-protected)
- ✗ No authentication
- ✗ No encryption (HTTP, not HTTPS)
For production flight systems:
- Deploy on an isolated network segment
- Use firewall rules to restrict access
- Consider adding TLS/authentication if needed for your environment
- Monitor API access via network logs