SPB Git forge

spb/market-atlas

Public
12commits 1branches 0releases
1.1 MBsize
maindefault branch
10 days agolast push
TypeScript 96.7% SQL 1.6% CSS 0.8% JavaScript 0.5%
4.6 KB · 49 lines markdown
Rendered Raw Blame History
1# Market Atlas API v123Base: `https://www.market-atlas.co/v1` (same origin as the web app; in development `http://127.0.0.1:8391/v1`).4Envelope: `{ "data": …, "meta": { "request_id", "timestamp", … } }`; errors: `{ "error": { "code", "message" } }`.5Public rate limit on /v1 only: 20 requests/s per IP (burst 300), `429` + `retry-after`. Admin routes need `x-ma-admin-token`.67Quote object (`publicQuote`): `instrument_id, symbol, name, asset_class, exchange_id, country, price, open, high, low, previous_close,8change, change_percent, volume, bid, ask, currency, source_count, dispersion_bps, confidence, freshness_ms, data_status, market_state,9rights_status, withheld, updated_at, source_timestamp, session_high, session_low`.10`data_status` ∈ `REALTIME | DELAYED | END_OF_DAY | AT_CLOSE | STALE | WITHHELD` — never present STALE/AT_CLOSE as live.11Quotes also carry `observation_count`, `proxy_count`, `validator_count`, `comparability` (LIVE/FIX/EOD); provenance contributions carry12`observation_type`, `delta_bps`, `reason` ∈ stale | not_comparable | temporal_mismatch | validation_only | validator_disagrees | outlier.1314| Method & path | Purpose |15|---|---|16| `GET /health` | liveness (db, connectors healthy, quotes cached) |17| `GET /status` | public status components (website, api, stream, ingestion, source groups) |18| `GET /stats` | homepage telemetry — real counters only |19| `GET /metrics` | Prometheus exposition |20| `GET /instruments?asset_class&exchange&country&q&quoted=1&sort&limit&offset` | instrument list with quotes |21| `GET /instruments/:idOrSymbol` | instrument + company + exchange status + quote + aliases + sources + related (`NASDAQ:AAPL` form accepted) |22| `GET /quotes/:idOrSymbol` · `GET /quotes?ids=a,b` | canonical quotes |23| `GET /quotes/:id/provenance` | **Why this price?** — contributions, weights, inclusion reasons, method, versions |24| `GET /history/:id?resolution=1m|5m|15m|1h|1d&from&to&limit` | bars (`p` = producer: `consensus` or a historical connector id) |25| `GET /events?type&instrument&country&asset_class&severity&since&before&limit` · `GET /events/:id` | canonical market events |26| `GET /filings?form&cik&q&limit&offset` | regulatory filings |27| `GET /search?q` | hybrid search (exact/prefix/alias/name), grouped by asset class / exchange / country |28| `GET /markets` | global overview: indices, crypto, forex, rates, commodities, equities, gainers/losers, exchanges with status, breadth |29| `GET /breadth?scope=world|US|xnas` | advancers/decliners/median return |30| `GET /changes?window=1m|5m|15m|1h|1d` | what changed: movers > 1 %, events by type, filings |31| `GET /exchanges` · `GET /exchanges/:id` | venues, status/next transition, holidays, breadth, movers, events |32| `GET /countries` · `GET /countries/:code` | country atlas page data |33| `GET /compare?ids=a,b,c&resolution=1d&limit` | normalized series, return/vol/drawdown, correlations |34| `GET /sources` · `GET /connectors` · `GET /data-health` | source directory (with `role` contributor/validator and `likely_shared_upstream_with`), public connector table, data-health dashboard |35| `GET /coverage?asset_class&tier&limit` · `GET /coverage/:id` | Source Coverage Engine: redundancy histogram (≥5/≥3/≥2/1 families), weighted score, tier attainment, expansion queue, inferred shared upstreams; per-instrument coverage |36| `GET /admin/lineage` | all statistically compared source pairs with similarity |37| `GET /stream` (WebSocket) · `GET /sse?channels=` | live stream — see below |38| `GET /admin/overview|connectors|connectors/:id|schema-changes|divergence|storage|raw?ref=` · `POST /admin/connectors/:id/pause|resume|restart|test` · `POST /admin/connectors/:id/schema-changes/:changeId/ack` · `POST /admin/discovery {url}` | admin console |3940## Stream protocol4142Client → server: `{"action":"subscribe","channels":["quotes:AAPL","quotes:crypto_btc_usd","quotes:*","quotes:class:CRYPTO","events:*","events:US","events:type:TRADING_HALT","market:xnas","tape"]}`,43`{"action":"unsubscribe",…}`, `{"action":"ping","id":1}`.4445Server → client: `hello`, `subscriptions`, `heartbeat` (25 s), `pong`, `error`, and batches at ≤ 10 Hz per client:46`{"type":"batch","seq":12,"ts":…,"messages":[{"type":"quote","instrument_id","symbol","price","change","change_pct","bid","ask","volume","currency","timestamp","received","confidence","sources","status"}, {"type":"event","event":{…}}, {"type":"market_state","exchangeId","state","at"}]}`.47`quotes:*` is throttled to one quote per instrument per 500 ms; explicit `quotes:<id>` subscriptions receive every recomputation.48`seq` is per client; a gap means the client missed batches (backpressure drops oldest). Withheld (non-redistributable) values are never streamed.49