Skip to content

Market data ​

Reading the book, fills, and pair catalog. Public — no session token required.

What's available ​

RPCReturnsUse it for
MarketDataService.ListPairsCatalog of pairs + per-spot metadata.Boot — discover what's tradeable.
MarketDataService.GetBookOne-shot L2 or L3 snapshot.Cold-start reconciliation, periodic resync.
MarketDataService.SubscribeStream of L1/L2/L3 book updates + status events for one or more pairs.Continuous order-book, depth charts, status alerts.
MarketDataService.SubscribeFillsStream of executed trades. Optional per-pair filter.Trade tape, volume metrics.
MarketDataService.SubscribeExternalFillsStream of trades observed on external DEX aggregators (Jupiter, OKX, DFlow, Titan), normalized onto one pair.Cross-venue trade tape, external flow analytics.
MarketDataService.SubscribeExternalQuotesStream of per-venue bid/ask for one pair, polled from each aggregator's quote API.Reference-price comparison, spread monitoring.
MarketDataService.SubscribeMarketSnapshotsConsolidated cross-market snapshot stream — top-of-book per pair in a single feed.Dashboards, watchlists, anything that wants every pair at once without N independent Subscribe streams.

A single Subscribe call returns a multiplexed stream — every pair you subscribed to plus cross-cutting StatusEvents arrive on the same channel.

Pick your level ​

Subscriptions take a FeedLevel:

LevelPayloadUse for
FeedLevel::L1spot.FeedLevel.L1"l1"Best bid + best askTickers, mark prices, sanity checks.
FeedLevel::L2spot.FeedLevel.L2"l2"Aggregated depth, snapshot + deltasDepth charts, mid calculation, taker sizing.
FeedLevel::L3spot.FeedLevel.L3"l3"Per-maker order listMaker analytics. Does not include oracle-offset orders (those are virtual).

Most integrations want L2.

Snapshot then stream ​

The canonical pattern for a UI:

rust
use futures_util::StreamExt;
use flint_sdk::spot::{FeedLevel, Pair};

let pair = Pair::new("SOL", "USDC");

// 1. Cold-start snapshot.
let snapshot = client.order_book(&pair, FeedLevel::L2).await?;
let mut book = build_local_book(snapshot);

// 2. Subscribe to deltas. `watch_order_book` returns a `Subscription`
//    that reconnects and replays the request automatically.
let mut events = client.watch_order_book([pair], FeedLevel::L2)?;

while let Some(ev) = events.next().await {
    let ev = ev?;
    apply_event(&mut book, ev);
}
ts
import { Client } from "@superis-labs/flint/spot";

const client = Client.mainnet();
const pair = "SOL/USDC";

// Cold-start snapshot.
const snapshot = await client.orderBook(pair, { level: "l2" });
const book = buildLocalBook(snapshot);

// Subscribe to deltas with auto-reconnect. The subscription connects on the
// first iteration and reconnects with backoff.
const subscription = client.watchOrderBook([pair], { level: "l2" });
subscription.onStateChange(async (state) => {
  if (state === "connected") {
    // On every (re)connect, resync: the server restarts the L2 stream from a
    // fresh snapshot and you may have missed deltas in flight.
    rebuildLocalBook(book, await client.orderBook(pair, { level: "l2" }));
  }
});
(async () => {
  for await (const event of subscription) {
    applyEvent(book, event);
  }
})();
// later: await subscription.close();
python
from flint import spot

client = spot.Client.mainnet()
pair = "SOL/USDC"

# 1. Cold-start snapshot.
snapshot = await client.order_book(pair, level=spot.FeedLevel.L2)
book = build_local_book(snapshot)

# 2. Subscribe to deltas. `watch_order_book` returns a `Subscription`
#    that reconnects and replays the request automatically.
events = client.watch_order_book([pair], level=spot.FeedLevel.L2)

async for ev in events:
    apply_event(book, ev)

Subscription reconnects and replays the request; call resubscribe() for another consumer of the same stream.Subscription reconnects with backoff; onStateChange reports connecting, connected, reconnecting, and closed.Subscription reconnects with backoff and replays the request; state and reconnects report its progress, and await events.close() stops it. Holding the book in your store and calling GetBook on reconnect keeps the local copy consistent.

Fills ​

Separate stream so book consumers don't pay to deserialize fills. Filter by pair (empty = all pairs). Fills are public trade-tape events; they do not include maker_id. Use MakerService.SubscribeBalance (or MakerService.SubscribeFills for maker-attributed fills) when you need inventory changes scoped to the authenticated maker.

rust
use futures_util::StreamExt;

let mut fills = client.watch_fills(["SOL/USDC"])?;

while let Some(fill) = fills.next().await {
    let fill = fill?;
    println!("{:?} {} @ {}", fill.side, fill.size, fill.price);
}
python
fills = client.watch_fills(["SOL/USDC"])

async for fill in fills:
    print(f"{fill.side} {fill.size} @ {fill.price}")

External fills ​

Trades executed through external Solana DEX aggregators (Jupiter, OKX, DFlow, Titan), normalized onto a Flint pair. One pair per subscription — price is quote per base, size is in base units, and source names the aggregator the swap routed through. The server taps a shared upstream feed only while at least one subscriber is connected.

rust
use futures_util::StreamExt;

let mut fills = client.watch_external_fills("SOL/USDC")?;

while let Some(fill) = fills.next().await {
    let fill = fill?;
    println!("[{}] {:?} {} @ {}", fill.source, fill.side, fill.size, fill.price);
}
ts
for await (const fill of client.watchExternalFills("SOL/USDC")) {
  console.log(`[${fill.source}] ${fill.side} ${fill.size} @ ${fill.price}`);
}
python
fills = client.watch_external_fills("SOL/USDC")

async for fill in fills:
    print(f"[{fill.source}] {fill.side} {fill.size} @ {fill.price}")

External quotes ​

Per-venue bid/ask for one pair, obtained by polling each aggregator's quote API at a fixed notional. Both sides are quoted at the same base size (bid.size == ask.size); ask_route/bid_route carry the underlying AMM labels each leg routes through. Only pairs quoted in the global (USD) numeraire are supported.

These quotes are estimates, not high-fidelity prices

Each value is a periodic poll of an external aggregator's quote API at a fixed notional — not a live, executable book. It can be stale between polls, is specific to that one notional size, and excludes slippage, gas, and price impact you'd actually incur. Treat it as a rough reference for comparison and monitoring, not as a firm price to trade or settle against.

rust
use futures_util::StreamExt;

let mut quotes = client.watch_external_quotes("SOL/USDC")?;

while let Some(q) = quotes.next().await {
    let q = q?;
    if let (Some(bid), Some(ask)) = (q.bid, q.ask) {
        println!("{}: {} / {}", q.venue, bid.price, ask.price);
    }
}
ts
for await (const q of client.watchExternalQuotes("SOL/USDC")) {
  console.log(`${q.venue}: ${q.bid?.price} / ${q.ask?.price}`);
}
python
quotes = client.watch_external_quotes("SOL/USDC")

async for q in quotes:
    if q.bid is not None and q.ask is not None:
        print(f"{q.venue}: {q.bid.price} / {q.ask.price}")

Discovering pairs at boot ​

rust
for m in client.markets().await? {
    println!("{}/{}: spot {} → {}", m.base_name, m.quote_name, m.base_spot_id, m.quote_spot_id);
}
python
for m in await client.markets():
    print(f"{m.name}: spot {m.base_spot_id} → {m.quote_spot_id}")

Client::markets() parses ListPairs into Vec<Market>spot.Client.markets() parses ListPairs into list[spot.Market] you can pass into the quoting layer.

Health events ​

Subscribe multiplexes StatusEvents onto the same stream. Treat them as advisory — the SDK doesn't gate calls on them. Common values:

StateWhat it meansWhat to do
HealthState::Healthyspot.HealthState.HEALTHY"healthy"Book is fresh.Quote and trade normally.
HealthState::Degradedspot.HealthState.DEGRADED"degraded"Book may be stale.Widen quotes; consider pausing taker flow.
HealthState::Haltedspot.HealthState.HALTED"halted"Don't act on this data.Pause submissions until the state is healthy again.

The status can be global (no pair) or scoped to one pair.

Rate limits ​

MarketDataService is public, so it's rate limited per client IP. Its unary RPCs (GetBook, ListPairs) draw from a 50 requests/sec token bucket; over-budget calls return RESOURCE_EXHAUSTED (gRPC status 8). The bucket starts full — so a burst of up to 50 is fine — and refills continuously, so back off and retry rather than hammering.

The streaming RPCs (Subscribe, SubscribeFills, SubscribeExternalFills, SubscribeExternalQuotes, SubscribeMarketSnapshots) don't touch that bucket: each holds one of your 100 concurrent connection slots for its lifetime instead of billing per event. For high-throughput consumers, prefer a single long-lived stream over polling GetBook.

See API → Rate limits for the full limit table across services.

Backoff ​

OperationSuggested cadence
ListPairsOnce at boot, then on schema changes.
GetBook (single pair)Once at boot, then on stream reconnect.
Subscribe (any level)Long-lived. Don't tear down + reopen on every event.
SubscribeFillsLong-lived.
SubscribeExternalFills / SubscribeExternalQuotesLong-lived, one pair each.

Polling GetBook >1 Hz means you should be on Subscribe instead.

Built on Solana