Access to quote stream in production is gated: request an API key with quote stream access, or have an existing key upgraded.
Quote Stream
Quote stream returns a live bid and ask for any pair of token mints, across direct and one-hop routes. New quotes stream out as the underlying liquidity moves, so you read prices as they change without polling. DFlow builds each quote by pricing a $10 USDC equivalent round-trip trade through the best path, so the bid and ask are the rates its two legs would execute at. For the full message format and parameters, see the Quote Stream API.1
Set up
Import a WebSocket client, read the endpoint from the environment, and pick the pair to watch.
Imports and config
Imports and config
2
Connect and subscribe
Open the connection to
/quote-stream and send a subscribe op once it is open. The API key header is only needed in production.Connect and subscribe
Connect and subscribe
3
Read updates
Each message is a batch covering one slot. Read the
updates array, and handle the per-pair e field for pairs with no route.Handle messages
Handle messages
Related Resources
Stream Order Book Depth
Read ten levels of depth per side.
Quote Stream API
Messages, fields, and the all-markets subscription.