Rust services for running an enhanced API layer in front of the Lighter exchange APIs. The stack ingests market data, stores local history, serves REST endpoints, provides WebSocket fan-out and replay, exports data-lake files, and includes optional user auth, API keys, rate limits, billing hooks, metrics, and dashboards.
This repository is meant for operators who want to run their own backend on their own hardware. It does not include a frontend, hosted account system, private deployment history, or operator-specific infrastructure.
api: Axum REST API on port8080ws-proxy: WebSocket stream and replay service on port8081ingestion: Lighter REST/WebSocket ingestion into Postgres and Redisdata-lake: optional Parquet export service backed by S3-compatible storagestorage,common, andlighter-clientlibrary crates- PostgreSQL migrations, Docker Compose, Prometheus, Grafana, load tests, and CI
Requirements: Docker, Docker Compose, Rust 1.91 if building locally, and jq for the smoke script.
cp .env.example .env
docker compose up -d --build
bash scripts/smoke_test.sh --no-teardownCreate an API key manually:
curl -X POST http://localhost:8080/api/v1/keys \
-H "X-Admin-Secret: replace_with_64_hex_chars_from_openssl_rand" \
-H "Content-Type: application/json" \
-d '{"name":"local-dev","tier":"free"}'Use the key:
curl http://localhost:8080/api/v1/orderbook/0 \
-H "X-Api-Key: hlt_your_key_here"Grafana is available at http://localhost:3000 in the default Compose stack. Prometheus is available at http://localhost:9090.
All application settings use the HML_* environment variable prefix. The runtime interface is intentionally stable for this release:
- API keys keep the
hlt_prefix. - REST endpoints remain under
/api/v1. - WebSocket endpoints remain
/wsand/ws/replay. - Stripe billing is optional. If Stripe settings are omitted, billing endpoints are unavailable and core API service continues to run.
/metricsrequiresX-Admin-SecretwhenHML_API__ADMIN_SECRETis configured. Without an admin secret, metrics are disabled.
See docs/SELF_HOSTING.md and deploy/SECRETS.md before deploying publicly.
cargo fmt --all -- --check
cargo check --workspace --locked
cargo clippy --workspace --locked -- -D warnings
cargo test --workspace --lockedLoad testing uses k6:
k6 run -e API_URL=http://localhost:8080 -e ADMIN_SECRET="$HML_API__ADMIN_SECRET" tests/load/api_baseline.jsMIT