Skip to main content
TetraFi’s price feed pushes live indicative pricing over WebSocket, with depth snapshots wire-encoded as protobuf to keep messages small and latency low. By the end of this page you’ll have a client connected, decoding, and printing live market state.
Outcome: a working WebSocket consumer decoding live depth snapshots.Time: 10-15 minutes.Before you start: Python 3.10+, uv or pip, and a TetraFi API key.

1. Generate the Schema Bindings

Depth snapshots travel as Protocol Buffers, so the first step is turning the schema into a Python module you can decode with.

The Wire Schema

Create tetrafi.proto:
What each PriceUpdate carries:

Compile to Python

Pull in the protobuf toolchain and compile:
The compiler emits tetrafi_pb2.py; importing it gives you the decoder classes used below.

2. Open the Stream

All streaming runs over TetraFi’s WebSocket endpoint:

What Goes on the URL

Topic-based JSON subscriptions (prices:{srcChain}:{input}:{dstChain}:{output}:{tier} - see the Reference) are always on. The protobuf depth-snapshot mode below ships per environment - it’s a deployment switch, so confirm with your TetraFi contact that it’s enabled where you’re integrating before wiring up a decoder. The network parameter accepts a chain id or an active chain name and selects the source side of each corridor: same-chain pairs and cross-chain corridors originating on that network both stream.

First Connection

3. Turn Bytes into Prices

A snapshot spans many pairs at once; picking out yours is a matter of matching the base and quote address bytes.

Look Up Asset Addresses

(You can skip this if you already track addresses.) Resolve symbols through the tradable-pair list:

Unpack the Depth Arrays

bids and asks arrive flattened - price, size, price, size - so re-pair them before use:

How to Read a Level

Both sides arrive pre-sorted from your perspective: the top bid is the highest, the top ask the lowest, and every level pairs a price with the base-token size available there. So bids = [2411.20, 2.4, 2410.55, 5.1] decodes to:

4. End to End

Everything wired together - resolve the pair, open the stream, print live pricing:
Nothing on this stream is executable. Streamed depth is for monitoring, sizing, and pre-trade analysis - when you’re ready to trade, the RFQ API turns intent into a firm commitment.

Keep Going

RFQ API Quickstart

Turn what you’re streaming into settled trades.

Price Feed Reference

Topic grammar, stream families, and expiry behavior.