Retrieve pool bid and ask
GET /public/v1/evm/{chain_id}/{pool_address}/bid_ask
Returns the pool's adjusted bid and ask with per-bin depth. These are not the raw provider quote: they already include the pool's spread and fees. See Liquidity and bins for pool pricing.
This is a public endpoint. A Trading API key is optional; sending one raises your rate limit:
Authorization: Bearer <your_trading_api_key>
A key you send must be valid: an unknown key returns 401. Leave the header out if you don't have one.
The pool_address is the unique identifier used throughout the API.
To quote many pools at once, use Retrieve batch bid and ask (up to 100 per request).
Path parameters
chain_id1. Must be one of the chains returned by GET /public/v1/chains.pool_addressGET /public/v1/evm/{chain_id}/metadata. Case-insensitive.Query parameters
All optional.
depthtruefalse returns "depth": null and skips the one-sided check (see Unavailable prices). Must be exactly true or false.Request
curl "https://api.metric.xyz/public/v1/evm/1/0xF85AfbADeCC7F23Dd173ed706f07d9C7e2473e24/bid_ask"
Response
200 OK. Depth is trimmed to two levels per side here.
{
"pair": "WETH/USDC",
"poolAddress": "0xF85AfbADeCC7F23Dd173ed706f07d9C7e2473e24",
"priceProviderStatus": "healthy",
"bidAdj": "49940417631045696435290",
"askAdj": "49945012360825322506424",
"totalToken0Available": "24503618827789131821",
"totalToken1Available": "49785157539",
"serverTs": 1790508850,
"depth": {
"bids": [
{
"binIdx": -1,
"price": "49937913286041055521250",
"cumulativeVolume": "7430706558",
"cumulativeInputVolume": "2744786401520641763",
"priceImpactE6": "51"
},
{
"binIdx": -2,
"price": "49932918995283375647711",
"cumulativeVolume": "21731301391",
"cumulativeInputVolume": "8027598362225637937",
"priceImpactE6": "151"
}
],
"asks": [
{
"binIdx": -1,
"price": "49947502535663908680680",
"cumulativeVolume": "2727338310371559766",
"cumulativeInputVolume": "7384519505",
"priceImpactE6": "49"
},
{
"binIdx": 0,
"price": "49952497285917475071548",
"cumulativeVolume": "8169278436813730931",
"cumulativeInputVolume": "22120177339",
"priceImpactE6": "149"
}
]
}
}Here bidAdj / 2^64 = 2707.28 and askAdj / 2^64 = 2707.52 USDC per WETH. The first bid level fills 2.74 WETH in for 7,430.71 USDC out.
Response fields
pairtoken0Symbol/token1Symbol (same as /metadata).poolAddresspriceProviderStatushealthy, feed_down, pool_refused, pool_paused, internal_error or unknown. Check this before using any price (see Unavailable prices below).bidAdjbidAdj / 2^64.askAdjtotalToken0AvailabletotalToken1AvailableserverTsdepthbids (you sell token0) and asks (you buy token0). null when depth=false.All prices and amounts are decimal strings. Parse them as BigInt, not Number.
Depth levels
Each entry in bids[] / asks[] is one pool bin, ordered outward from the current price.
binIdxpricebidAdj).cumulativeVolumecumulativeInputVolumepriceImpactE6price from bidAdj (bids) or askAdj (asks), in millionths, unsigned. 49 ≈ 0.005%. This is the marginal price at the bin's far edge, not the average price of an order that reaches it. For that, see Estimate a fill from depth.bidsasksThe last level's cumulativeVolume approaches the side's total: totalToken1Available for bids, totalToken0Available for asks, unless a guard cuts that side short.
How the list ends:
- Bins past the pool's liquidity repeat the previous cumulative values and add no volume. Ignore them.
- A guard such as StopLoss can stop a side early, at the first bin the pool won't fully fill. If the pool still fills part of that bin, the side ends with one extra level for it: its cumulative values include only the part that fills, and its
priceis where that partial fill stops, not the bin's far edge. If nothing in that bin fills, the side ends at the previous level.
Estimating a fill
Use depth to estimate what an order fills for: walk a side's levels, crossing each bin whole until the order runs out, and price the bin it ends in. The bin's proportional share, floor(binOut × remaining / binIn), gives a rough estimate. Token rounding can put the actual fill on either side of that estimate. The pool moves its price linearly inside a bin, so on wide bins an order that ends inside one fills up to half that bin's remaining width better: about 3% in a 6.25% bin. Find best route can price shortlisted paths from the underlying pool snapshots.
For the full walk, a worked example and how to estimate a fill inside a bin, see Estimate a fill from depth.
Unavailable prices
When the pool can't be quoted, the endpoint still returns 200 with sentinel values:
{
"priceProviderStatus": "feed_down",
"bidAdj": "0",
"askAdj": "340282366920938463463374607431768211455",
"depth": { "bids": [], "asks": [] }
}bidAdj = 0, askAdj = 2^128 − 1 and empty depth mean the pool is not quotable. priceProviderStatus says why:
healthyfeed_downpool_refusedpool_pausedinternal_errorunknownTreat any priceProviderStatus other than healthy as "do not trade".
One side can be closed while the status stays healthy. For some pools the pool refuses trades in one direction only; that side then gets its sentinel (bidAdj = "0" or askAdj = "340282366920938463463374607431768211455") while the other side keeps a real price. Check each side's value, not only the status. This check only runs when depth=true: with depth=false, a side the pool refuses can still show a real price next to healthy, so request depth if you rely on it.
Before you trade
A healthy quote is not a promise that your swap goes through. The endpoint reads the price when you call it (serverTs), and the pool checks feed freshness again in the block your swap executes in. If the feed goes stale in between, the swap reverts with PriceProviderFailed wrapping the provider's FeedStalled().
- 1.Pick pools with Metadata. Its
priceProviderStatusis the most recent reading: every pool is read about every 30 seconds, and freshdepth=truereads from this endpoint update it in between, so a quoted pool usually shows its feed going down within a block. Recovery from a down feed usually shows through the 30-second read. Use it to skip pools that are down, not to decide whether to trade. - 2.Check this endpoint right before you send the swap, with
depth=true(or the batch endpoint for many pools). Trade only whenpriceProviderStatusishealthyand the side you trade has a real price, not the sentinel. - 3.On Ethereum, send the swap through participating builders. Ethereum pools use conditional updates: the maker's latest price lands onchain only in a participating builder's block that also contains a trade against the pool. This endpoint quotes against that latest streamed price, so
healthymeans the pool fills if your swap lands in such a block. Between trades the onchain price is usually stale, so a swap sent through the public mempool or included by another builder usually reverts. For the same reason, reading the pool's price onchain at the latest block is not a useful pre-check on Ethereum. Integrations built on Titan's propAMM taker interface reach participating builders.
Errors
400Invalid pool address formatpool_address is not a valid address. An address without the 0x prefix returns pool_address is not a valid EVM address.400Failed to deserialize query string: …depth is not true or false. This body is plain text, not JSON.401Invalid API keyAuthorization header was sent with an unknown or revoked key.404Unknown chainId: <id>404Pair metadata not found for <pool>200; its depth levels show zero cumulativeVolume.429Retry-After.500Internal server error503Service temporarily unavailableNew API keys work within seconds of being issued.
Last updated 29 days ago
Relatick