|
| 1 | +# Raindex Market Data API |
| 2 | + |
| 3 | +Public market data service backed by the Raindex Rust SDK and its persistent |
| 4 | +local indexer. It does not require API keys. |
| 5 | + |
| 6 | +## Run locally |
| 7 | + |
| 8 | +```sh |
| 9 | +cargo run -p raindex_rest_api |
| 10 | +``` |
| 11 | + |
| 12 | +The first startup creates `.raindex/market-data.sqlite`, synchronizes the |
| 13 | +configured orderbook, and warms the market cache before accepting requests. |
| 14 | +Swagger UI is served at `http://127.0.0.1:8000/swagger/`. |
| 15 | + |
| 16 | +## Routes |
| 17 | + |
| 18 | +- `GET /tickers` — CoinGecko 24-hour ticker data for every listed registry |
| 19 | + market. |
| 20 | +- `GET /orderbook?ticker_id=...&depth=100` — executable bids and asks for one |
| 21 | + market. |
| 22 | +- `GET /v1/markets` — complete registry-driven market overview for the Raindex |
| 23 | + UI. |
| 24 | +- `GET /v1/markets?ticker_id=...` — one market with statistics, trades, and its |
| 25 | + executable book. |
| 26 | +- `GET /health` and `GET /health/detailed` — service and local-indexer health. |
| 27 | + |
| 28 | +## Configuration |
| 29 | + |
| 30 | +All settings are optional environment variables: |
| 31 | + |
| 32 | +| Variable | Default | |
| 33 | +| -------------------------------------- | ---------------------------------------- | |
| 34 | +| `RAINDEX_REGISTRY_URL` | Pinned `rain.strategies` registry commit | |
| 35 | +| `RAINDEX_LOCAL_DB_PATH` | `.raindex/market-data.sqlite` | |
| 36 | +| `RAINDEX_CACHE_TTL_SECONDS` | `60` | |
| 37 | +| `RAINDEX_RATE_LIMIT_GLOBAL_RPM` | `6000` | |
| 38 | +| `RAINDEX_RATE_LIMIT_PER_IP_RPM` | `120` | |
| 39 | +| `RAINDEX_SNAPSHOT_RECENT_TRADES_LIMIT` | `1000` | |
| 40 | +| `RAINDEX_TRUSTED_PROXY_IP_HEADER` | unset; direct socket IP is used | |
| 41 | + |
| 42 | +The all-market overview is refreshed in the background. Executable orderbooks |
| 43 | +are cached per ticker so an orderbook request quotes only the requested market. |
| 44 | +Orderbooks use a fixed 1000-level SDK snapshot. A `depth` of `0` returns that |
| 45 | +entire snapshot; positive values return at most that many levels split evenly |
| 46 | +between bids and asks. CoinGecko's optional historical-trades endpoint is |
| 47 | +intentionally deferred until the SDK can serve arbitrary indexed time ranges |
| 48 | +without truncating to a cached 24-hour window. |
| 49 | + |
| 50 | +Set `RAINDEX_TRUSTED_PROXY_IP_HEADER` only when a trusted ingress overwrites |
| 51 | +that header before forwarding requests. Client-provided forwarding headers are |
| 52 | +ignored by default so public rate limits cannot be bypassed by spoofing them. |
0 commit comments