tRPC Market Data Stream API
tRPC Endpoints
tRPC Market Data Stream API
Admin controls for the Cloudflare market-data-stream Worker. Browser stream tickets are minted directly by the Worker.
POST
tRPC Market Data Stream API
The
The request accepts a structured public target, not arbitrary topic keys or
provider identifiers:
Browsers then connect to the returned Worker base URL:
Example body:
Public ticket requests fail closed with
Collection feeds use:
Initial browser wiring maps canonical asset metadata to topics:
marketDataStream.* namespace is intentionally small. Public browser pages
connect to apps/market-data-stream directly and call its public
POST /v1/tickets endpoint to mint short-lived scoped stream tokens. Platform
API stays out of the realtime hot path and only proxies privileged admin/status
operations to the Worker.
- Base endpoint:
POST /v1/trpc - Namespace:
marketDataStream.* - Admin auth: platform-api admin bearer token
- Worker auth: platform-api admin procedures call the Worker with
x-market-data-stream-internal-token
Public Worker Ticket Route
Browser clients call the Worker directly:- Equity asset detail:
{ kind: "asset", assetClass: "equity", symbol, collectionFeeds } - Crypto asset detail:
{ kind: "asset", assetClass: "crypto", symbol, collectionFeeds } - Stocks/watchlist collection:
{ kind: "collection", assetClass: "equity", collection, symbols } - Crypto collection:
{ kind: "collection", assetClass: "crypto", collection: "crypto", symbols }
GET /v1/assets/:assetClass/:symbol/:feedKind/:resolution/snapshotGET /v1/assets/:assetClass/:symbol/:feedKind/:resolution/wsGET /v1/collections/:namespace/:name/snapshotGET /v1/collections/:namespace/:name/ws
?token=.... Resume windows use
?afterSequence=<last-seen-sequence>.
The public asset registry is seeded through the Worker internal route:
403 public_asset_not_allowed until the
requested symbols are present in this Worker-side registry.
Admin Procedures
-
marketDataStream.adminStatus- Purpose: fetch provider status, capability registry, subscription counts, reconnect state, per-topic client counts, replay windows, and last event timestamps from the Worker
- Auth: admin bearer token
-
marketDataStream.adminConnectProvider- Purpose: manually connect Massive stocks or manually poll CoinGecko quotes
- Auth: admin bearer token
- Input:
{ provider: "massive" | "coingecko" }
-
marketDataStream.adminDisconnectProvider- Purpose: manually disconnect the Massive stock WebSocket. CoinGecko polling has no persistent socket, so disconnect returns a no-op reason.
- Auth: admin bearer token
- Input:
{ provider: "massive" | "coingecko" }
Topic Contract
Asset feeds use:- canonical equity or fund underlyings such as TSLA:
asset:equity:TSLA:ohlcv:1s, providermassive - canonical crypto underlyings with
metadata.coingeckoId, such as AAVE:asset:crypto:AAVE:quote:tick, providercoingecko - stocks page collection:
collection:stocks:default - crypto page collection:
collection:crypto:default - dashboard watchlist collection:
collection:watchlist:default
Runtime Configuration
Platform API reads:MARKET_DATA_STREAM_BASE_URL: public Worker URL used for admin proxy callsMARKET_DATA_STREAM_INTERNAL_BASE_URL: optional internal Worker URL for platform-api-to-Worker calls; defaults to the public base URLMARKET_DATA_STREAM_INTERNAL_TOKEN: shared internal token for Worker/internal/*routes
apps/webapp-v2 reads:
VITE_MARKET_DATA_STREAM_URL: public Worker URL used by anonymous and authenticated browser clients forPOST /v1/tickets, snapshots, and WebSockets
MARKET_DATA_STREAM_PROVIDER_CONNECT_ENABLED=false in staging
until Massive redistribution entitlement is confirmed. CoinGecko polling is
also default-disabled with MARKET_DATA_STREAM_COINGECKO_POLL_ENABLED=false
and can be manually burn-in tested through the admin poll path.