Find something... ⌘K

User flows and examples / Quotes

Price vs quote

Maxy prices a swap with two calls, the way swap APIs split them. GET /price is for showing an amount while the user browses or types. GET /quote is for the order about to be placed: it names who pays and who receives, and comes with an id and an expiry. This page is for anyone building the screen between "how much?" and "confirm".

PriceQuoteOrder
CallGET /priceGET /quotePOST /orders
SDKswap.price()swap.quote()swap.createOrder()
WhenWhile the user browses or typesWhen the user moves to confirmAfter the user signed
NeedsThe pair, an amount, your keyAlso fromAddress and toAddressThe quote's order and the signatures
GivestoAmount, formattedThe same, plus quoteId, expiresAt, issues, stepsorderId, and the escrow transaction where the route has one
IdNonequoteId, which becomes the order idorderId, the signed intent's hash
Reserves anythingNoNoThe escrow does, once it lands
ExpiryWhen to refreshWhen POST /orders stops accepting itThe intent's own deadline

Get a price

Call it as often as you like: the same question within 3 seconds is one read, and price reads have ten times the rate limit of other calls. It needs no wallet. BASE and KEY are as on Get a price.

curlTypeScriptPython
Copy
curl -sG -H "x-maxy-key: $MAXY_API_KEY" "$BASE/price" --data-urlencode "from=ETH on base" -d to=BTC -d amount=0.004 | jq '{toAmount, formatted}'

Expiry: when to refresh, for a price. When POST /orders stops accepting it, for a quote.

A price answers at any size above the route's minimum (546 sats buying BTC; below it, 422 amount_out_of_range). liquidityAvailable: false, with a message, means no price can be made for that amount now. A price also carries expiresAt: on a price it marks when to refresh, and it reserves nothing.

Get a quote

Ask once, when the user moves to confirm. A quote is valid for 60 seconds: that is how long it can be used, not how long it takes to arrive. expiresAt is in Unix seconds, and expiresAtIso is the same moment. Count down against the Date header of Maxy's answer, not the device's clock, and quote again 5 seconds before it closes. The wallet and the Bitcoin address are as on Get a quote.

curl Copy
curl -s -D headers.txt -G "$BASE/quote" -H "x-maxy-key: $MAXY_API_KEY" --data-urlencode "from=ETH on base" -d to=BTC -d amount=0.004 \ -d fromAddress="$WALLET" -d toAddress="$MY_BTC_ADDRESS" > quote.json jq '{quoteId, toAmount, expiresAt}' quote.json grep -i '^date:' headers.txt

Count down against the date header's clock, not the device's.

TypeScriptPython
Copy
const q = new URLSearchParams({ from: 'ETH on base', to: 'BTC', amount: '0.004', fromAddress: account.address, toAddress: btcAddress }); const res = await fetch(`${BASE}/quote?${q}`, { headers: { 'x-maxy-key': KEY } }); const quote = await res.json(); const skew = Date.parse(res.headers.get('date')!) - Date.now(); // the server's clock, not the device's const secondsLeft = () => Math.floor((quote.expiresAt * 1000 - (Date.now() + skew)) / 1000); console.log(quote.quoteId, quote.toAmount, secondsLeft()); // quote again when it falls under 5

On a settler route the quote's amounts are executable: toAmountMin equals toAmount; a route ending in a swap or bridge leg quotes a lower toAmountMin, the leg's slippage allowance. It also carries what the order needs: steps to sign and send, and issues for what is short (balance, allowance, orderCap). Over your key's cap the amounts still show, and steps is null. React's useQuote gives secondsLeft for you.

When it runs out

An order from a quote older than 60 seconds is refused before anything is sent: 409 quote_expired, with a fresh quote in details.freshQuote. Show the new amount and ask the user to sign again. Once signed, the order has its own deadlines: a solver must commit within 2 hours of the quote.

CodeHTTPCauseDo
quote_expired409Over 60 seconds since the quoteQuote again, sign again
quote_mismatch409The escrow would lock more than the quote and its price band allowQuote again
invalid_input400A quote without fromAddress or toAddressSend both, or use /price

Which key

Both calls take your key. A secret key works from your server. A publishable key (mxk_pk_…) works from a browser page, on the origins Maxy issued it for: it can get prices, quotes and status, and place the user's own signed order, but not list orders, register webhooks or manage keys. From a server, use the secret key: Keys and limits.

Many at once

POST /quotes/batch takes up to 20 requests. A request that names both addresses is a quote; the others are prices. Each result has its own status, so one failing does not fail the rest.

curl Copy
curl -s -X POST "$BASE/quotes/batch" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" \ -d '{"requests":[{"from":"ETH on base","to":"BTC","amount":"0.004"},{"from":"USDC on base","to":"BTC","amount":"10"}]}' \ | jq -c '.results[] | {index, status, toAmount: .quote.toAmount}'

Next, the wallet signs the quote's steps: Sign. What is inside the amount: Fees and pricing.