REST API
Endpoints, request parameters, fees and positive slippage, the quote and price responses, market data, the order and order book endpoints, the MCP server for AI agents, error codes, rate limits and how to check and send the returned transactions from your own code.
Updated · Markdown version
The Tirio API is live and public: no API key, no sign-up, rate limited per IP. It is the API the Tirio app runs on, served at
https://api.tirio.io
It returns quotes together with a ready-to-send Router.swap transaction, indicative prices, pair market data and the transactions that place and manage orders; your own wallet or backend signs and sends them. Status: public beta. There is no SLA yet, so retry on 503 and 5xx answers. New fields may still be added; GET /openapi.json always describes the current shape.
Conventions
- Chains are addressed by slug in the path.
bsc(BNB Chain) is the only chain served; any other slug answers 404notFound. - Addresses are hex; responses use EIP-55 checksums.
- The native coin (BNB) is the zero address
0x0000000000000000000000000000000000000000. - Amounts are decimal integer strings in the token's raw units (wei-style), never floats.
- Every error is a JSON body
{ "error": "<code>", "message": "<text>" }. - Rate limit: 10 requests per second per client IP with a burst of 30. Exceeding it returns 429 with a
Retry-Afterheader (seconds)./healthand/readyare not limited. - The API answers browser requests directly (CORS enabled,
Retry-Afterexposed). - Every endpoint is a
GETrequest, exceptPOST /mcp, the MCP server for AI agents described at the end of this page. - Swap transactions target the Router,
0x9B1c368F5d33a8D051587c7576b150132680ADC0, and order transactions the Orders contract,0x06360a557290f64aeC55B7a06b788eD8723e71f9, both deployed on BNB Chain only. Pin both in your code and checktx.toagainst them;GET /healthreports them per chain (router,orders), which is useful as a consistency check but not as the source of truth. - The machine-readable description is served at
GET /openapi.json(OpenAPI 3.1.1); generate clients from it or load it into your API tooling.
Fees and positive slippage
- No Tirio fee. Quotes requested from the API carry no Tirio fee. The Router's protocol fee is 0 today (
feeBpsin/healthand in every quote); the 3 bps Tirio fee is added only by the tirio.io app, as a partner fee. - Your own fee.
partnerandpartnerFeeBpsadd a partner fee of up to 1000 bps, paid topartnerin the swap transaction. The Router keepspartnerShareBpsof it (10 % today, at most 20 %). - Positive slippage. Every exact-in quote whose output token has no transfer tax settles the output through the Router with the quoted
amountOutas the expected output. If the swap delivers more, the Router keeps the excess up tofees.surplusCapBps(100, that is 1 %) ofamountOut, passes 20 % of what it keeps to yourpartnerif you set one, and sends anything beyond the cap to the recipient. If the swap delivers less, the recipient receives less, down tominOut. Exact-out quotes, quotes with a taxed output and pure wraps keep no surplus. - Changes. The Router's owner can change the protocol fee (at most 100 bps) and the shares at any time. Read
feeBpsfrom the quote instead of assuming 0.
Errors
error | HTTP status | When |
|---|---|---|
invalidRequest | 400 | A parameter is missing or malformed (bad address, non-positive amountIn, slippage out of range, deadline in the past or more than 3600 seconds ahead, q longer than 64 characters, hours not 1, 24 or 168), or an order breaks a rule of the Orders contract; message names the rule. |
unsupportedToken | 400 | The token cannot be traded through Tirio, or cannot be placed in an order because of a transfer tax; message says why. |
unpricedPair | 400 | A stop or DCA placement for a pair without an independent price reference. Limit orders for the pair still work. |
belowMinimum | 400 | A placement below the minimum order size of tokenIn (for DCA, per chunk), a minFill below it, or a book order for a token without a minimum; message names the minimum. |
notFound | 404 | Unknown chain slug, an order endpoint on a chain without orders ("orders are not available on this chain"), an unknown order id, or a pair that /candles, /trades or /pairstats knows nothing about. |
noRoute | 404 | No route for this pair and amount, the best route moves the price by 50 % or more, or every route failed in simulation. |
unavailable | 503 | Quotes are paused: the Router's fee cannot be read, pools are still loading, the RPC is unreachable or the API is behind the chain; for placements also while the Orders contract accepts no new orders ("orders are paused"). Retry later. |
rateLimited | 429 | Too many requests; wait for Retry-After. |
internal | 500 | The API hit an unexpected error while answering; retry. |
GET /health
Overall status of every chain the API serves.
{
"status": "ok",
"chains": {
"bsc": {
"ready": true,
"reason": null,
"pools": 106,
"tokens": 982,
"engineLagMs": 1949,
"engineLagBlocks": 0,
"replicaLagMs": 129,
"replicaLagBlocks": 1,
"feeBps": 0,
"exactOut": true,
"router": "0x9B1c368F5d33a8D051587c7576b150132680ADC0",
"orders": "0x06360a557290f64aeC55B7a06b788eD8723e71f9"
}
}
}status is "ok" or "degraded"; the response is 503 while degraded. Per chain:
| Field | Meaning |
|---|---|
ready, reason | Whether quotes are served, and why not (null when ready). |
pools | Pools held ready for quoting. Informational: quotes are not limited to these. |
tokens | Listed tokens. |
engineLagMs, engineLagBlocks | Age of the latest block the API has seen, and how many blocks behind the chain it is, null when unknown. |
replicaLagMs, replicaLagBlocks | Age of the pool state used for quotes, in milliseconds and in blocks behind the latest block. Absent when not available. |
feeBps | The Router's protocol fee, read from the Router: 0 today. |
exactOut | true when buy mode (amountOut) is served. |
router | The address every quote's transaction targets. |
orders | The chain's Orders contract, absent where orders are not available. |
The values above are an example; read your own.
GET /ready
204 No Content when the API can serve quotes on every chain it serves, otherwise 503 with { "error": "unavailable", "message": "<chain>: <reason>" }. Meant for load balancers and health checks.
GET /{chain}/tokens?q=
The chain's listed tokens as an array of { address, symbol, name, decimals, logoURI, tags, listed }: the native coin first, then the curated tokens, then the chain's token list (PancakeSwap's extended list on BNB Chain, verified against the chain). q (at most 64 characters) ranks exact symbol matches before symbol prefixes before tokens whose name or symbol mentions the text; at most 100 tokens are returned. If q is an address, that token is read on chain (symbol, name, decimals) and returned first with listed: false even when it is not on the list. logoURI is present when the list has a logo; tags is a subset of native, wrapped, usd and hub. decimals is null when it could not be read; the Tirio app skips such tokens.
curl "https://api.tirio.io/bsc/tokens?q=usdt"GET /{chain}/protocols
The liquidity sources the chain routes through, in configuration order, as an array of { id, name, kind, factory, pools }. id is the adapter identifier that quote hops carry in dex; name is the display name; kind is the pool family, today one of v2, v3, v4, infinity_cl, infinity_bin, maverick_v2, maverick_v1, biswap_v3, metric, algebra, stable, dodo, dodo_v1, fluid, call (venues quoted on chain, such as on-chain market makers), launchpad, solidly, liquidity_book and book (the complete, current list is the Protocol.kind enum in /openapi.json); factory is the source's main contract (its factory, or the pool manager, vault or venue for singleton sources and on-chain market makers); pools is the number of pools available for routing where the source has a count, null for factory-based sources whose pools are looked up per pair. On a chain with orders the last row is Tirio's order book, tirio_book of kind book, with the Orders contract as factory and the number of open orders as pools; it obeys includeDexes and excludeDexes like any source. The wrap/unwrap edge (wrapped_native) is not a protocol and is not listed.
curl "https://api.tirio.io/bsc/protocols"GET /{chain}/prices?tokens=
USD spot prices read from the chain's hub pools: { block, prices: { "<address>": "612.34000000" } }. Each price is the value of one whole token in the chain's USD stablecoin (USDT on BNB Chain), as a decimal string with 8 places, quoted for a small probe amount so it is the marginal price rather than the price of a large trade. tokens is a comma-separated list of at most 50 addresses; the zero address is the native coin; without tokens the listed tokens are priced. A token that has no route to the stablecoin through the hub pools is left out of prices. block is the block the pool state was read at. A price can be up to 10 seconds old.
curl "https://api.tirio.io/bsc/prices?tokens=0x0000000000000000000000000000000000000000,0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c"GET /{chain}/history?tokenIn=&tokenOut=&hours=
Recent spot price history of a pair: { tokenIn, tokenOut, hours, points: [{ t, block, price }] }. Each point is the price of one whole tokenIn in tokenOut, read from the hub pools at a past block (block, Unix time t), as a decimal string; up to 48 points. hours is the window, 1, 24 or 168 (default 24). The zero address is the native coin; tokenIn and tokenOut must differ. Results can be up to two minutes old. unavailable is returned when historical pool state cannot be read.
curl "https://api.tirio.io/bsc/history?tokenIn=0x0000000000000000000000000000000000000000&tokenOut=0x55d398326f99059fF775485246999027B3197955&hours=24"GET /{chain}/quote
Quotes a swap and returns the transaction that executes it.
Query parameters
| Parameter | Required | Meaning |
|---|---|---|
tokenIn | yes | Token you sell (zero address for the native coin). |
tokenOut | yes | Token you receive (zero address for the native coin). |
amountIn | one of | Amount sold, raw integer string, greater than zero. Exactly one of amountIn and amountOut is given. |
amountOut | one of | Exact amount to receive (buy mode). The response comes back with mode: "exactOut", amountIn as the expected input including the protocol fee, maxIn as the most the Router may pull (input plus fee plus slippage; the rest never leaves your wallet) and minOut equal to amountOut. Buy mode routes through constant product, V3-style and hook-free Uniswap V4 / PancakeSwap Infinity CL pools, needs an input without transfer taxes (the native coin included: tx.value is then maxIn and the Router refunds the part the route does not use in the same transaction), and is served once the chain's Executor supports it (/health reports exactOut). amountIn is the Router's simulated amountInUsed when the simulation ran. |
slippageBps | no | Maximum slippage in basis points, 0 to 5000. Default 50 (0.5 %). |
recipient | yes | Address that receives the output. It is written into the calldata. |
sender | no | The wallet that will send the transaction. With it the quote honours the Router's fee exemption for that address (feeExempt: true, feeBps: 0), fills tx.from, reports issues (allowance { actual, spender } and balance { actual, expected } when the wallet cannot pay, null otherwise) and, for an ERC-20 input, picks the approval path: permit (something to sign) or approval (something to approve first), see below. The quote is still returned. |
partner | no | Address that receives the partner fee in the same transaction. Required when partnerFeeBps is set. The Tirio app passes both from a white-label link (/swap?partner=&partnerFeeBps=). |
partnerFeeBps | no | Partner fee in basis points, 0 to 1000, on top of the protocol fee (0 today); paid to partner minus the Router's partnerShareBps cut (10 % today, at most 20 %). With a partner, 20 % of the positive slippage the Router keeps also goes to partner. The calldata carries partner and partnerFeeBps, and flag 4 (partner fee on the output) is set when fees.token is tokenOut. The Tirio app sends its own 3 bps fee this way, with the Tirio treasury as partner. |
feeToken | no | tokenIn or tokenOut: the side the partner fee is taken from. Without it the partner fee follows the protocol fee's side, which is tokenIn while the protocol fee is 0. A taxed output or an exact-out quote moves it to tokenIn; fees.token reports the token actually used. |
deadline | no | Unix timestamp in seconds after which the Router rejects the transaction (Expired). Default: 20 minutes (1200 seconds) from now; a deadline in the past or more than 3600 seconds ahead is rejected with invalidRequest. |
maxHops | no | Maximum swaps per path, 1 to 6. Wrapping or unwrapping the native coin counts as a swap. |
maxPaths | no | Maximum paths the order may be split across, 1 to 10. |
includeDexes | no | Comma-separated protocol ids from /protocols; only these sources are routed through. Unknown ids are rejected. Wrapping and unwrapping the native coin is always available. |
excludeDexes | no | Comma-separated protocol ids to leave out. Cannot be combined with includeDexes. |
source | no | A tag for your integration, 1 to 32 characters of letters, digits, _, . or -. It is written to the API's logs only; it never reaches the chain or the response. The Tirio app sends source=app. |
Example
curl "https://api.tirio.io/bsc/quote?tokenIn=0x0000000000000000000000000000000000000000&tokenOut=0x55d398326f99059fF775485246999027B3197955&amountIn=1000000000000000000&slippageBps=50&recipient=<your address>"This asks for 1 BNB (10^18 wei) into USDT with 0.5 % slippage.
Response
{
"mode": "exactIn or exactOut",
"sender": "address, with sender",
"feeExempt": false,
"issues": { "allowance": { "actual": "string", "spender": "address" }, "balance": { "actual": "string", "expected": "string" } },
"tokenIn": "address",
"tokenOut": "address",
"amountIn": "string",
"maxIn": "string, exactOut only",
"amountOut": "string",
"minOut": "string",
"feeBps": 0,
"fees": { "token": "address", "protocolToken": "address", "protocolBps": 0, "protocolAmount": "0", "partner": "address or null", "partnerBps": 0, "partnerAmount": "string", "surplusCapBps": 100 },
"permit": { "kind": "eip2612 or permit2", "eip712": { "types": {}, "primaryType": "string", "domain": {}, "message": {} }, "signatureOffset": 0, "spender": "address" },
"approval": { "spender": "address", "permit2": true, "required": "string", "actual": "string" },
"gasEstimate": 0,
"gasPrice": "string",
"deadline": 0,
"priceImpactBps": 0,
"amountInUsd": "string or null",
"amountOutUsd": "string or null",
"splitGainPpm": 0,
"quoteExact": true,
"simulated": true,
"taxIn": 0,
"taxOut": 0,
"taxInKnown": true,
"taxOutKnown": true,
"route": {
"paths": [
{
"sharePpm": 1000000,
"amountIn": "string",
"amountOut": "string",
"hops": [
{
"dex": "pancakeswap_v3",
"pool": "address",
"poolId": "bytes32, singleton pools only",
"feePpm": 2500,
"tokenIn": "address",
"tokenOut": "address",
"amountIn": "string",
"amountOut": "string",
"source": "local",
"exact": true
}
]
}
]
},
"tx": { "from": "address, with sender", "to": "address", "data": "0x…", "value": "string", "gas": 0 }
}The values above show types, not real numbers.
| Field | Meaning |
|---|---|
mode | exactIn when amountIn was given, exactOut when amountOut was given. |
sender, feeExempt | With a sender: the address echoed, and true when the Router exempts it from the protocol fee (feeBps is then 0). Without a sender, feeExempt is false and sender is absent. |
issues | Present with a sender: allowance { actual, spender } when the wallet's allowance for the spender the transaction relies on is short, balance { actual, expected } when its balance cannot cover the input (and, for a native input, the value), each null when there is nothing to fix. |
tokenIn, tokenOut, amountIn | Echo of the request in sell mode. In buy mode amountIn is the expected input including the fees. |
maxIn | Buy mode only: the most the Router may pull, written into the calldata (expected input plus fee plus slippage); what the route does not need never leaves the wallet. |
amountOut | Expected output after output-side fees. When simulated is true this is the simulated output. For an exact-in quote without a taxed output it is also the expected output written into the calldata, the reference for positive slippage. |
minOut | amountOut × (10000 − slippageBps) / 10000, at least 1. Encoded in the calldata; the Router reverts if the recipient receives less. |
feeBps | The Router's protocol fee in basis points, read from the Router: 0 today, and 0 for an exempt sender. |
fees | Where the fees are taken: the protocol fee on protocolToken (protocolBps, protocolAmount), the partner fee on token (partnerBps, partnerAmount net of the Router's 10 % cut, partner or null). A protocol fee above 0 moves to the output when tokenOut is a hub token without transfer tax and the quote is exact-in, and is otherwise taken from the input. surplusCapBps (100) is the share of amountOut the Router may keep when the swap delivers more than amountOut; see Fees and positive slippage above. |
permit | Present with a sender whose allowance is short but who can sign instead of approving. Sign eip712 with signTypedData (uint values are decimal strings) and write the 65-byte r ‖ s ‖ v signature into tx.data at byte signatureOffset (the bytes there are zero), then send. kind: "eip2612" signs the token's own Permit for the Router; kind: "permit2" signs a Permit2 PermitSingle (the token must already be approved to Permit2 0x000000000022D473030F116dDEE9F6B43aC78BA3). |
approval | Present with a sender who must approve first: approve spender for at least required (actual is the current allowance). permit2: true means the recommended one-time approval to Permit2, after which quotes carry a Permit2 signature; a contract wallet is asked to approve the Router directly. |
gasEstimate | Gas the route is expected to use (the simulated figure when simulated is true). |
gasPrice | Current gas price in wei, as a string. |
deadline | Unix timestamp in seconds encoded in the calldata. |
priceImpactBps | How far the order moves the pool prices against the spot rate, in basis points; null when unknown. |
amountInUsd, amountOutUsd | USD values of input and output as decimal strings; null when the token cannot be priced. |
splitGainPpm | How much more the chosen route yields than the best single path for the whole amount, in parts per million of that single-path output; 0 when splitting gained nothing or no single path exists. |
quoteExact | true when every hop was quoted exactly, false when some hops are estimates. |
simulated | true when the full transaction was simulated on chain at the latest block and its output and gas replaced the estimates. false when the simulation could not run (rare: the RPC did not answer it); the amounts are then the routed plan, so simulate the transaction yourself before sending. |
taxIn, taxOut | Detected transfer tax on the input (sell) and output (buy) token in parts per million; already applied to the quote. |
taxInKnown, taxOutKnown | false when the tax could not be measured; the actual output may then be lower. |
route.paths[] | One entry per path. sharePpm is the path's share of the input in parts per million; amountIn and amountOut are the path's amounts. |
route.paths[].hops[] | dex is the adapter name (for example pancakeswap_v3, uniswap_v2, wrapped_native for a wrap or unwrap), pool the pool address (for singleton sources such as Uniswap V4 and PancakeSwap Infinity the pool manager, with the pool's id in poolId), feePpm the pool fee in parts per million, tokenIn, tokenOut, amountIn, amountOut the hop's tokens and amounts, source either local (quoted from the pool's current state) or call (quoted on chain), exact whether the hop was quoted exactly. A hop through a limit order on the book has dex tirio_book, the Orders contract as pool and the 32-byte order id as poolId. |
tx | The transaction to send: from is the sender when one was given, to is the Router, 0x9B1c368F5d33a8D051587c7576b150132680ADC0, data the ABI-encoded swap(SwapParams, route, permit) call, value the native amount to attach (equal to amountIn, or maxIn in buy mode, for a native input, 0 otherwise), gas the gas limit to use. A pure wrap or unwrap (native against the wrapped token) requested with sender equal to recipient targets the wrapped token instead: data is deposit() with the amount as value or withdraw(amount), no fee, no approval, and the route is the single wrapped_native hop. |
GET /{chain}/price
The indicative price of a swap: the same routing, parameters and fee sides as /quote, without the simulation and without a transaction. The Tirio app calls it while you type and calls /quote when you review. Never send a transaction based on /price; ask /quote for it.
Parameters: tokenIn, tokenOut, exactly one of amountIn and amountOut, and optionally recipient, maxHops, maxPaths, includeDexes, excludeDexes, source, partner, partnerFeeBps and feeToken, all as in /quote. As there, partner is required when partnerFeeBps is set, otherwise the answer is 400 invalidRequest, although /price builds no payout. sender, slippageBps and deadline are not used.
curl "https://api.tirio.io/bsc/price?tokenIn=0x0000000000000000000000000000000000000000&tokenOut=0x55d398326f99059fF775485246999027B3197955&amountIn=1000000000000000000"{
"mode": "exactIn",
"tokenIn": "0x0000000000000000000000000000000000000000",
"tokenOut": "0x55d398326f99059fF775485246999027B3197955",
"amountIn": "1000000000000000000",
"amountOut": "string",
"feeBps": 0,
"gasEstimate": 0,
"gasPrice": "string",
"priceImpactBps": 0,
"simulated": false,
"block": 0,
"route": { "paths": [] }
}| Field | Meaning |
|---|---|
mode, tokenIn, tokenOut, amountIn | As in /quote; in buy mode amountIn is the planned input including the protocol fee. |
amountOut | The routed plan's output after output-side fees, not simulated. |
feeBps | The Router's protocol fee, as in /quote. |
gasEstimate, gasPrice | The routing model's gas estimate and the current gas price in wei. |
priceImpactBps | As in /quote; null when unknown. |
simulated | Always false. |
block | The block of the pool state the price was computed from. |
route | The paths and hops, in the same shape as /quote. |
Sending the transaction
Quotes expire; request a fresh one right before sending rather than reusing an old response. Before signing, check that tx.to is the Router address you pinned in your code and that the calldata's recipient, minOut and deadline match what you expect. This is what the Tirio app does on every quote: the Router address is built into the app, and if /health ever reports another one, the app pauses swaps instead of following it.
For an ERC-20 input, pass sender and follow the quote: with permit, sign the typed data and splice the signature into tx.data; with approval, approve the spender (Permit2 once, or the Router) and quote again; with neither, the allowance already suffices. A native input needs no approval; the amount travels in tx.value.
With viem in a browser:
import { concat, createWalletClient, custom, erc20Abi, slice } from "viem";
import { bsc } from "viem/chains";
const API = "https://api.tirio.io";
const NATIVE = "0x0000000000000000000000000000000000000000";
const ROUTER = "0x9B1c368F5d33a8D051587c7576b150132680ADC0";
const client = createWalletClient({ chain: bsc, transport: custom(window.ethereum) });
const [account] = await client.getAddresses();
const params = new URLSearchParams({
tokenIn: "0x55d398326f99059fF775485246999027B3197955",
tokenOut: NATIVE,
amountIn: "1000000000000000000",
slippageBps: "50",
recipient: account,
sender: account,
});
const response = await fetch(`${API}/bsc/quote?${params}`);
if (!response.ok) throw new Error((await response.json()).message);
const quote = await response.json();
if (quote.tx.to.toLowerCase() !== ROUTER.toLowerCase()) throw new Error("unexpected target");
if (quote.approval) {
const approvalHash = await client.writeContract({
account,
address: quote.tokenIn,
abi: erc20Abi,
functionName: "approve",
args: [quote.approval.spender, BigInt(quote.approval.required)],
});
await waitForApproval(approvalHash);
throw new Error("approved; request a fresh quote");
}
let data = quote.tx.data;
if (quote.permit) {
const signature = await client.signTypedData({ account, ...quote.permit.eip712 });
data = concat([slice(data, 0, quote.permit.signatureOffset), signature, slice(data, quote.permit.signatureOffset + 65)]);
}
const hash = await client.sendTransaction({
account,
to: quote.tx.to,
data,
value: BigInt(quote.tx.value),
gas: BigInt(quote.tx.gas),
});waitForApproval stands for waiting until the approval's receipt is mined (for example waitForTransactionReceipt on a viem public client); after an approval, quote again so the new allowance (or a Permit2 signature) is used. concat and slice are viem helpers; the typed data's uint fields are decimal strings, convert them to BigInt before signing if your library requires it. The swap's receipt status tells you whether it succeeded; a reverted swap moves no tokens and costs only gas.
Market data
/candles, /trades and /pairstats describe the pair's most traded pool and start with the same fields:
| Field | Meaning |
|---|---|
pool | Pool id: the pool address left-padded to 32 bytes, or the pool key hash of a singleton pool. |
address | The pool or pool manager contract; empty for a singleton pool known only to market data. |
protocol, dex | The protocol id as in /protocols and its display name. |
base, quote | The tokens as requested. |
since | Unix time Tirio's recording of the pool began; 0 when it is not recorded. |
Each takes base and quote token addresses; the zero address and the wrapped native coin read the same pools. Prices are quote per whole base token. Recorded data comes from the swaps Tirio records on the chain since 2026-10-01; older history comes from GeckoTerminal's public market data. A pair that neither source knows answers 404 notFound.
GET /{chain}/candles?base="e=&tf=&limit=&before=
OHLC candles, oldest first: { pool, address, protocol, dex, base, quote, since, tf, partial, candles: [{ t, o, h, l, c, v, vUsd }] }.
tfis1m,5m,15m(default),1h,4hor1d;limitkeeps the newest 1 to 1500 candles (default 500);before(Unix time) returns the older page that ends before it.- Recorded candles cover the last 24 hours for
1mand5mand the last 7 days for15mand up, aligned to UTC, and win where both sources have a candle. A recorded candle that starts beforesinceis left out. tis the opening time,vthe recorded base volume in whole tokens (0 for history) andvUsdthe USD volume ornull.partialistruewhen the history could not be read right now; only recorded candles are in the answer and a retry a few seconds later fills it.
curl "https://api.tirio.io/bsc/candles?base=0x0000000000000000000000000000000000000000"e=0x55d398326f99059fF775485246999027B3197955&tf=1h"GET /{chain}/trades?base="e=&limit=
The newest trades, newest first: { pool, address, protocol, dex, base, quote, since, trades: [{ id, t, block, tx, side, amount, price, volumeUsd }] }. Up to limit (1 to 200, default 200) swaps Tirio recorded on the pool, followed by older trades from market data when fewer than 50 are recorded. id is the transaction hash and log index, side the taker's side on the base token (buy or sell), amount whole base tokens, price the executed quote per whole base and volumeUsd the trade in USD or null.
GET /{chain}/pairstats?base="e=
The last 24 hours, from the fifteen-minute candles of /candles: { pool, address, protocol, dex, base, quote, since, complete, last, changeBps, high, low, volume, volumeUsd }. last is the spot price after the last recorded trade, changeBps compares it with the close before the window (null when unknown), volume is in whole base tokens and complete is false when neither the history nor the recording covers the whole 24 hours.
GET /{chain}/market?base="e=
Both tokens' public market data and the pair's deepest pool, from GeckoTerminal through Tirio, up to an hour old: { network, base, quote, pool }. base and quote are { address, symbol, name, decimals, priceUsd, fdvUsd, marketCapUsd, liquidityUsd, volume24hUsd, totalSupply, pools } and pool is { address, name, dex, base, quote, reserveUsd, volume24hUsd, change24hPct }; a token or pool that is not known is null, as is any figure the source does not have.
Orders
On a chain with an Orders contract (/health reports it as orders), the endpoints below read orders from the contract and build the transactions that place and manage them. Elsewhere they, and /book, answer 404 notFound with "orders are not available on this chain". The API keeps no order state: every answer is read from the chain, and only the order book can be up to 5 seconds old. The transactions are unsigned; your wallet signs and sends them to the Orders contract, 0x06360a557290f64aeC55B7a06b788eD8723e71f9 on BNB Chain. Orders are read from OrdersLens, 0x844ff0401646A42A868d7029eB5dC847796CA686. Orders cost 10 bps of what each fill receives (3 bps between stablecoins) plus any partner fee. How orders fill, what they cost and what the contract enforces is described in Orders.
The order object
/orders and /orders/{id} return orders in this shape:
{
"id": 42,
"maker": "0x81994324E1E82A8c02B2C608994Ba6AaD46a3F32",
"kind": "limit",
"status": "open",
"tokenIn": "0x55d398326f99059fF775485246999027B3197955",
"tokenOut": "0x0000000000000000000000000000000000000000",
"amountIn": "1000000000000000000000",
"remainingIn": "400000000000000000000",
"minOut": "1633000000000000000",
"maxOut": "0",
"triggerOut": "0",
"minFill": "100000000000000000000",
"chunks": 1,
"filledChunks": 0,
"interval": 0,
"nextFillAt": 1790000000,
"expiry": 1790604800,
"placedAt": 1790000000,
"paused": false,
"book": true,
"partner": null,
"partnerFeeBps": 0,
"filledIn": "600000000000000000000",
"receivedOut": "980412000000000000",
"avgPrice": "0.00163402",
"pool": null,
"deviationBps": 0
}| Field | Meaning |
|---|---|
id | Order id, counted from 1. |
maker | The wallet that placed the order. |
kind | limit, stop or dca. |
status | The contract's own status: open, filled, cancelled or expired. An open order past its expiry stays open until it is expired on chain. |
tokenIn, tokenOut | The token sold (and escrowed) and the token bought; the zero address is the native coin. |
amountIn, remainingIn | The amount placed and the amount still escrowed, in raw units. |
minOut | The net floor for the whole amountIn: the limit, the stop's worst price or the DCA price protection. It applies in proportion to every fill, to what the maker receives after the order fee and the partner fee. |
maxOut | The take-profit output of a stop, the upper bound of a DCA order (0 for none), 0 for a limit order. |
triggerOut | The stop trigger for the whole amountIn, 0 for the other kinds. |
minFill | The smallest partial fill in tokenIn; 0 fills the order whole. |
chunks, filledChunks, interval, nextFillAt | The DCA schedule: slices in total, slices filled, seconds between slices and the Unix time the next slice is due. Limit and stop orders have one chunk and no interval. |
expiry, placedAt | Unix times in seconds. |
paused | true for a paused DCA order. |
book | true when the order is listed on the order book. |
partner, partnerFeeBps | The partner paid a fee from every fill, null and 0 without one. |
filledIn, receivedOut, avgPrice | The input the fills spent, the output the maker received after fees, and their ratio in whole tokens (tokenOut per tokenIn), null before the first fill. |
pool, deviationBps | The price reference terms of a stop or DCA order: the pool the reference uses (null when the pair has Chainlink feeds) and the most, in basis points, a fill may get the maker below the reference price after fees. null and 0 for a limit order. |
minOut, maxOut and triggerOut are amounts of tokenOut for the whole amountIn, so the price they stand for is the amount divided by amountIn, adjusted for the decimals of both tokens.
GET /{chain}/orders?maker=&limit=
{ "orders": [order] }: the newest limit orders maker placed (1 to 200, default 200), newest first, closed ones included.
curl "https://api.tirio.io/bsc/orders?maker=<wallet address>"GET /{chain}/orders/{id}
One order. An id no order has answers 404 notFound, for example "order 4242 does not exist".
GET /{chain}/orders/place
Checks an order against every rule of Orders.place and returns the transaction that places it.
| Parameter | Required | Meaning |
|---|---|---|
kind | yes | limit fills at minOut or better; stop fills when the market falls to triggerOut (checked against the price reference), never below minOut, and with maxOut also takes profit at maxOut or better (a bracket on one escrow); dca buys in chunks every interval, between minOut and maxOut per chunk. |
tokenIn | yes | Token escrowed and sold; the zero address is the native coin. |
tokenOut | yes | Token bought; the zero address is the native coin. |
amountIn | yes | Input escrowed, raw units, between 1 and 2^128 − 1. |
minOut | one of | Least output for the whole amountIn after the order fee and the partner fee, enforced in proportion to every fill. Exactly one of minOut and price is given. |
price | one of | Limit price in whole tokens, tokenOut per tokenIn, as a decimal number; minOut becomes amountIn × price rounded up, net of fees like minOut. |
maxOut | no | Stop: the take-profit output for amountIn, above triggerOut. DCA: the most output for amountIn a chunk may buy at (0 for none). Must be 0 for limit orders. |
triggerOut | stop | The output for amountIn at which the stop leg fires, at or above minOut; 0 for the other kinds. |
minFill | no | Smallest partial fill in tokenIn; 0 (the default) fills the order whole; must be 0 for DCA. |
chunks | DCA | Number of chunks, at least 2 and at most amountIn; 1 (the default) for the other kinds. |
interval | DCA | Seconds between chunks, 60 to 31536000; 0 (the default) for the other kinds. |
expiry | yes | Unix time after which the order no longer fills and its remainder is refunded; more than 60 seconds and at most 365 days away. |
startNow | no | DCA: false waits one interval before the first chunk. Default true. |
book | no | Limit only: list the order on the order book, where swaps take it at its limit at once. Default false (the Tirio app turns it on by default). |
partner | no | Address paid the partner fee out of every fill; required when partnerFeeBps is set. |
partnerFeeBps | no | Partner fee on the output of every fill, 0 to 1000; the partner receives it minus the contract's protocol share (10 % at deployment, at most 20 %). |
deviationBps | no | Stop and DCA: the most a fill may get the maker below the price reference after fees, 0 to 1000. Default 500 for a stop and 300 for a DCA order. Not accepted for a limit order. |
sender | no | The maker: fills tx.from, reports a short balance and, for an ERC-20 input, picks the approval path for the Orders contract as /quote does for the Router. |
A rule that is broken answers 400 invalidRequest naming it, for example "exactly one of minOut and price is required", "a stop order needs minOut at or below triggerOut", "a DCA order needs at least 2 chunks" or "expiry must be at most 365 days away". The rules: tokenIn and tokenOut differ; amountIn between 1 and 2^128 − 1; expiry more than 60 seconds and at most 365 days away; partnerFeeBps at most 1000, with a partner; book only on a limit order; minOut positive, minOut and maxOut at most uint256.max / 10000 / amountIn, maxOut 0 or at least minOut. DCA: at least 2 chunks, an interval of 60 to 31536000 seconds, no minFill and at least one unit of amountIn per chunk. Limit and stop: one chunk and no interval. Limit: no maxOut and no triggerOut. Stop: minOut at or below triggerOut and a take-profit maxOut above triggerOut. With price, a token whose decimals cannot be read answers "the decimals of … are unknown, send minOut instead of price".
Stop and DCA orders need a pair with an independent price reference; for a pair without one the placement answers 400 unpricedPair. An order below the minimum of tokenIn (per chunk for DCA) answers 400 belowMinimum. A token with a known transfer tax, a blocked token or one whose tax cannot be measured answers 400 unsupportedToken "tokens with transfer taxes cannot be placed as orders" (the contract would refuse a taxed input or a taxed output). While the contract accepts no new orders, placements answer 503 unavailable "orders are paused"; open orders still fill and can be cancelled.
curl "https://api.tirio.io/bsc/orders/place?kind=limit&tokenIn=0x0000000000000000000000000000000000000000&tokenOut=0x55d398326f99059fF775485246999027B3197955&amountIn=1000000000000000000&price=700&expiry=<unix time>&book=true&sender=<your address>"This asks for a limit order selling 1 BNB for at least 700 USDT after fees, listed on the book.
{
"order": { "kind": "limit", "tokenIn": "address", "tokenOut": "address", "amountIn": "string", "minOut": "string", "price": "string or null", "maxOut": "string", "triggerOut": "string", "minFill": "string", "chunks": 1, "interval": 0, "expiry": 0, "startNow": true, "partner": "address or null", "partnerFeeBps": 0, "book": true, "pool": "address or null", "deviationBps": 0 },
"preview": { "oracleOut": "string or null", "marketOut": "string or null", "distanceBps": 0, "chunk": "string", "estimatedFee": "string" },
"permit": { "kind": "eip2612 or permit2", "eip712": { "types": {}, "primaryType": "string", "domain": {}, "message": {} }, "signatureOffset": 0, "spender": "address" },
"approval": { "spender": "address", "permit2": true, "required": "string", "actual": "string" },
"issues": { "balance": { "actual": "string", "expected": "string" }, "minimum": { "actual": "string", "expected": "string" } },
"tx": { "from": "address, with sender", "to": "address", "data": "0x…", "value": "string" }
}| Field | Meaning |
|---|---|
order | The Place struct written into the calldata, with minOut computed from price when the request gave one, and price as minOut per amountIn in whole tokens (null when a token's decimals are unknown). For a stop or DCA order pool and deviationBps are the price reference terms the API filled in (pool is null when the pair has Chainlink feeds); a limit order has null and 0. |
preview.oracleOut | Stop and DCA: what amountIn is worth at the price reference now; null for a limit order. |
preview.marketOut | An indicative output for amountIn at the market rate of one chunk, not simulated; null without a route. |
preview.distanceBps | How far minOut (the triggerOut of a stop) lies from marketOut, in basis points of marketOut; negative below it. |
preview.chunk | The first chunk; amountIn for limit and stop orders. |
preview.estimatedFee | The order fee plus the partner fee in tokenOut, on the larger of marketOut and the output that meets minOut. |
permit | With a sender who can sign instead of approving: sign eip712 and write the 65-byte signature into tx.data at signatureOffset, as for a quote. eip2612 signs the token's Permit for the Orders contract; permit2 signs a PermitSingle whose spender is the Orders contract (offered only to EOAs, EIP-7702 delegated accounts excluded). |
approval | With a sender who must approve first: approve spender for at least required, either Permit2 (permit2: true) or the Orders contract, then ask again. |
issues.balance | The sender holds less tokenIn than amountIn (raw units); null when enough or without a sender. |
issues.minimum | Always null: an order below the minimum answers 400 belowMinimum instead. |
tx | from (the sender, when given), to (the Orders contract), data (the ABI-encoded place(Place, permit) call, with the permit blob after the Place struct), value (amountIn for a native input, 0 otherwise). There is no gas limit: estimate it or let the wallet do it. |
Order actions
| Endpoint | Call |
|---|---|
GET /{chain}/orders/cancel?id= | cancel(id): closes an open order and refunds its remainder to the maker. |
GET /{chain}/orders/cancelAll?ids= | cancelAll(ids): comma-separated ids, at most 100, encoded in the given order. Closed orders are skipped; an id another wallet placed reverts. |
GET /{chain}/orders/pause?id= | pause(id): a paused DCA order fills no chunk until it is resumed. |
GET /{chain}/orders/resume?id= | resume(id): the DCA order fills again from its next due chunk; its expiry does not move. |
GET /{chain}/orders/update?id=&chunks=&interval=&minOut=&maxOut= | update(id, chunks, interval, minOut, maxOut) on a DCA order: chunks counts the chunks left (at least 1, at most the input that remains), interval is 60 to 31536000 seconds (a shorter one brings the next chunk forward), minOut the new floor and maxOut the new upper bound for the whole amountIn (0 or omitted for none). |
Each answers { tx: { from, to, data, value } } with the plain ABI encoding of the call and value 0; every action also takes sender. Without it the calldata is built without reading the chain. With it the orders are read first, and an order that does not exist, one the sender did not place, a closed one (cancelAll skips those, as the contract does), a non-DCA order for pause, resume or update, and update chunks above the input left are refused with 400 before any transaction is built.
There is no endpoint for claiming. When the contract could not deliver a payout, the account it is owed to calls claim(token) on the Orders contract itself; claimable(account, token) reads the balance. The Tirio app builds that call in the browser.
GET /{chain}/book?tokenIn=&tokenOut=&depth=
The limit orders listed on the order book for a pair, next to the depth of its pools. tokenIn is the base and tokenOut the quote; the native coin and its wrapped token count as one.
{
"bids": [{ "price": "612.5", "amountIn": "2450000000000000000000", "orders": 2 }],
"asks": [{ "price": "613.1", "amountIn": "1500000000000000000", "orders": 1 }],
"amm": [{ "amountIn": "163185000000000000", "amountOut": "100002000000000000000", "priceImpactBps": 0 }],
"spot": "612.84"
}asksare the orders sellingtokenIn, lowest price first, withamountInin rawtokenIn;bidsare the orders sellingtokenOut, highest price first, withamountInin rawtokenOut.- Each level groups the orders at one price: the makers' net limit in whole tokens,
tokenOutpertokenIn, net of the order fee.depthis the number of levels per side, 1 to 100 (default 20). Only orders a swap could take right now are shown: placed at least 3 seconds before the latest block, expiring at least 30 seconds after it and worth at least 1 USD. ammholds 16 indicative points from the pair's pools, not simulated: the first 8 selltokenInfortokenOut, the last 8 selltokenOutfortokenIn, each at sizes worth about 100 to 300 000 USD (0.1 to 300 whole tokens for a token without a USD price).amountInandamountOutare raw units andpriceImpactBpsis measured againstspot; a size without a route hasamountOut0 andpriceImpactBps10000.spotis the marginal pool price,tokenOutpertokenIn.
The answer can be up to 5 seconds old.
Checking an order transaction before you sign
Treat the API like any remote service and check what your wallet signs. The Tirio app does all of the following on every placement and action:
- Pin the Orders address,
0x06360a557290f64aeC55B7a06b788eD8723e71f9(BNB Chain), in your code and requiretx.toto equal it. Take it neither from the response nor from/health; use/health'sordersonly to notice a mismatch. - Decode
tx.dataasplace(Place, bytes)and compare every field of thePlacestruct with the order you asked for (kindis 0 for limit, 1 for stop, 2 for DCA), or better, encode your ownPlaceand require the calldata to be byte-for-byte that encoding with the response's permit blob. TakepoolanddeviationBpsfromorder: require both to be zero for a limit order, anddeviationBpsto be the one you asked for, at most 1000. - Require
tx.valueto beamountInfor a native input and 0 otherwise. - Accept an
approvalonly for Permit2 or the Orders contract, and check apermitlike a quote's: your chain, your token (or Permit2) as the signing domain, your account, the Orders contract as spender and an amount that covers the order. - For an action, encode the call yourself and require
tx.datato equal it, withvalue0. - Simulate the transaction with
eth_callfrom your account before sending it.
With viem, continuing the swap example above (client, account and API as defined there):
import { decodeFunctionData, encodeFunctionData, parseAbi, zeroAddress } from "viem";
const ORDERS = "0x06360a557290f64aeC55B7a06b788eD8723e71f9";
const ordersAbi = parseAbi([
"struct Place { address tokenIn; address tokenOut; uint256 amountIn; uint256 minOut; uint256 maxOut; uint256 triggerOut; uint256 minFill; uint32 chunks; uint40 interval; uint40 expiry; bool startNow; address partner; uint16 partnerFeeBps; uint8 kind; bool book; address pool; uint16 deviationBps; }",
"function place(Place p, bytes permit) payable returns (uint256 id)",
]);
const order = {
tokenIn: zeroAddress,
tokenOut: "0x55d398326f99059fF775485246999027B3197955",
amountIn: 1000000000000000000n,
minOut: 700000000000000000000n,
maxOut: 0n,
triggerOut: 0n,
minFill: 0n,
chunks: 1,
interval: 0,
expiry: Math.floor(Date.now() / 1000) + 7 * 86400,
startNow: true,
partner: zeroAddress,
partnerFeeBps: 0,
kind: 0,
book: true,
pool: zeroAddress,
deviationBps: 0,
};
const params = new URLSearchParams({
kind: "limit",
tokenIn: order.tokenIn,
tokenOut: order.tokenOut,
amountIn: order.amountIn.toString(),
minOut: order.minOut.toString(),
expiry: String(order.expiry),
book: "true",
sender: account,
});
const response = await fetch(`${API}/bsc/orders/place?${params}`);
if (!response.ok) throw new Error((await response.json()).message);
const { tx } = await response.json();
if (tx.to.toLowerCase() !== ORDERS.toLowerCase()) throw new Error("unexpected target");
if (BigInt(tx.value) !== order.amountIn) throw new Error("unexpected value");
const [, permit] = decodeFunctionData({ abi: ordersAbi, data: tx.data }).args;
if (tx.data !== encodeFunctionData({ abi: ordersAbi, functionName: "place", args: [order, permit] })) throw new Error("the placement differs from the order");
const hash = await client.sendTransaction({ account, to: ORDERS, data: tx.data, value: order.amountIn });For an ERC-20 input, follow permit or approval as for a quote before sending. The receipt's Placed(id, maker) event carries the new order's id; read the order itself with orders(id) on OrdersLens.
MCP
AI agents and assistants that speak the Model Context Protocol can use the API as an MCP server, with no key and no sign-up:
https://api.tirio.io/mcp
- Transport: Streamable HTTP. Each JSON-RPC 2.0 message is a
POSTto that URL and every answer is one JSON response. There are no sessions;GET /mcpanswers 405. - Protocol versions:
2026-07-28, and2025-11-25,2025-06-18and2025-03-26afterinitialize. Methods:initialize,ping,server/discover,tools/listandtools/call. - Server card:
https://tirio.io/.well-known/mcp/server-card.json. - The tools only read. None of them signs or sends a transaction:
get_quotereturnstxfor the user's own wallet to sign and send, exactly as/quotedoes. - The rate limit is the one above, shared with the REST endpoints; each
POSTcounts as one request.
| Tool | Arguments | Returns |
|---|---|---|
get_tokens | chain, search | { tokens }, the /tokens list for q = search |
get_price | chain, tokenIn, tokenOut, amountIn or amountOut | The /price response |
get_quote | chain, tokenIn, tokenOut, amountIn or amountOut, recipient; optional sender, slippageBps, partner, partnerFeeBps | The /quote response, with tx and, for an ERC-20 input with sender, approval or permit |
list_protocols | chain | { protocols }, the /protocols list |
get_order | chain, id | The /orders/{id} response |
list_orders | chain, maker | The /orders response |
chain defaults to bsc. Arguments mean what the query parameters of the same name mean; amounts are decimal integer strings in raw units and slippageBps, partnerFeeBps and id are JSON integers. A result carries the endpoint's JSON body in structuredContent and the same JSON as text in content. A failed call is a result with isError: true whose body is the endpoint's error, with the codes and messages listed under Errors:
{ "error": "invalidRequest", "message": "amountIn must be a positive decimal integer" }To add the server to Claude Code:
claude mcp add --transport http tirio https://api.tirio.io/mcpA tool call with curl:
curl https://api.tirio.io/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-11-25" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_price","arguments":{"tokenIn":"0x0000000000000000000000000000000000000000","tokenOut":"0x55d398326f99059fF775485246999027B3197955","amountIn":"1000000000000000000"}}}'