# Quote routes

The routes that say what an amount gets. A price is for browsing; a quote is for placing an order: an id, the steps, valid for 60 seconds: [Price vs quote](https://maxy.co/docs/price-vs-quote). Each takes a secret or a publishable key. Samples use the setup from [Get a quote](https://maxy.co/docs/buy-btc#get-a-quote); answers are real sandbox answers, trimmed.

## Name the swap

`/price`, `/quote`, `/quotes/batch`, `/prices/stream` and `/prices/stream-ticket` take the same parameters.

| Parameter | Meaning |
| --- | --- |
| `from`, `to` | The coins, in words: `ETH on base`, `USDC on arbitrum`, `BNB`, `SOL`, `BTC`, or a CAIP-19 id |
| `amount` | What the user sends, in whole coins; decimals past the coin's are dropped |
| `fromAmount` | The same in the smallest unit (wei, sats, 6-decimal units). Alias `sellAmount` |
| `receive`, `toAmount` | Buying BTC only: the BTC wanted, in whole BTC or in sats, in place of `amount`. Alias of `toAmount`: `buyAmount` |
| `fromChain`, `fromToken`, `toChain`, `toToken` | Instead of `from` and `to`: a chain id, name or CAIP-2 id, and a token address or symbol. Aliases `chainId`, `sellToken`, `buyToken` |
| `partnerFeeBps`, `partnerFeeRecipient`, `partnerFeeToken` | Your own fee on top, on `evm-btc-escrow`, `evm-btc-bridge`, two-leg `btc-evm` sales and `evm-btc-gasless`: [Partner fees](https://maxy.co/docs/partner-fees) |
| `scenario`, `simulate` | Test keys only: [Test scenarios](https://maxy.co/docs/test-scenarios) |

Give one amount: `amount`, `fromAmount`, `receive` or `toAmount`. Answers give amounts in the smallest unit, as strings; `formatted` in words.

## GET /price

What an amount gets now. No wallet, nothing reserved; the same question within 3 seconds is one read. It answers at any size above the route's minimum: the quote checks the order size.

```sh
curl -s -G -H "x-maxy-key: $MAXY_API_KEY" "$BASE/price" --data-urlencode "from=ETH on base" -d to=BTC -d amount=0.004
```

```json
{
  "route": "evm-btc-escrow",
  "liquidityAvailable": true,
  "from": { "chain": 8453, "chainName": "Base", "token": "0x0000000000000000000000000000000000000000", "symbol": "ETH", "decimals": 18, "caip2": "eip155:8453", "assetId": "eip155:8453/slip44:60" },
  "to": { "chain": "bitcoin", "chainName": "Bitcoin", "token": "BTC", "symbol": "BTC", "decimals": 8, "caip2": "bip122:000000000019d6689c085ae165831e93", "assetId": "bip122:000000000019d6689c085ae165831e93/slip44:0" },
  "fromAmount": "4000000000000000",
  "toAmount": "10800",
  "toAmountMin": "10800",
  "formatted": { "send": "0.004 ETH on Base", "receive": "0.000108 BTC", "pair": "ETH on Base → BTC" },
  "expiresAt": 1795468322,
  "expiresAtIso": "2026-11-23T21:12:02.000Z",
  "limits": { "minSats": 546 },
  "requiredConfirmations": 1,
  "sandbox": true
}
```

`toAmountMin` equals `toAmount` on a settler route (lower after a swap or bridge leg), with every cost in; [two-leg](https://maxy.co/docs/any-token-to-btc) routes add `legs`. On a buy, `requiredConfirmations` is the Bitcoin confirmations before the solver is paid: 1 below $2,000, 2 from $2,000, 3 from $20,000. When no price can be made, the answer is a `200` with `liquidityAvailable: false`, a `message` and `route: null`.

## GET /quote

The quote for an order about to be placed: who pays, who receives, valid for 60 seconds.

| Parameter | Required | Meaning |
| --- | --- | --- |
| `fromAddress` | yes | The paying wallet. Selling BTC: any Bitcoin address of the payer. Alias `taker` |
| `toAddress` | yes | Where the coins go: a `bc1q…` address when buying BTC. Alias `recipient` |
| `slippageBps` | no | The price band in basis points, 0 to 1000; default 50 ([Price band](https://maxy.co/docs/price-band)) |
| `evmAddress` | Tron and Sui | The user's EVM wallet between the two legs ([Tron and Sui](https://maxy.co/docs/tron-and-sui)) |
| `refundRecipient` | no | A contract `fromAddress` only: who the settler refunds ([Opening an escrow from a contract](https://maxy.co/docs/opening-an-escrow-from-a-contract)) |
| `shape` | no | Sandbox only: `live` gives the real intent on the Base Sepolia test settler |

```sh
curl -s -G -H "x-maxy-key: $MAXY_API_KEY" "$BASE/quote" --data-urlencode "from=ETH on base" -d to=BTC -d amount=0.004 \
  -d fromAddress="$WALLET" -d toAddress="$MY_BTC_ADDRESS"
```

```json
{
  "quoteId": "0x53414e44424f58457cd806dde2c268ed65fc50cca1b1cb876e867f5069b07af8",
  "route": "evm-btc-escrow",
  "toAmount": "10797",
  "expiresAt": 1795468344,
  "requiredConfirmations": 1,
  "order": { "route": "evm-btc-escrow", "orderId": "0x53414e44424f5845…", "chainId": 8453, "btcAddress": "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", "intent": "…", "quote": "…", "status": "…" },
  "issues": { "balance": null, "allowance": null, "orderCap": null },
  "steps": [
    { "id": "intent", "kind": "signature", "typedData": "…", "hash": "…" },
    { "id": "order", "kind": "post", "method": "POST", "path": "/orders", "body": "…" },
    { "id": "escrow", "kind": "transaction", "chainId": 8453, "transaction": null }
  ],
  "signing": { "kind": "eip712", "payloads": "…", "approval": null, "after": { "method": "POST", "path": "/orders" } },
  "sandbox": true
}
```

The price fields are there too, with `fees.partner` and `totalFromAmount` when you ask a fee. `quoteId` becomes the order id. Send `order` back unchanged to `POST /orders`. `steps` lists what the wallet does, in order: `signature`, `post` (call this API) or `transaction`. `signing` gives the first thing the wallet is asked for, in one shape on every route.

| When | The quote shows |
| --- | --- |
| Over your key's order size cap | The amounts, `issues.orderCap`, `steps: null` |
| Maxy cannot fill this size now | The amounts, `liquidityAvailable: false`, `steps: null` |
| The wallet holds too little | `issues.balance` |
| USDC needs a one-time approval | `issues.allowance` and an `approve` step |
| No provable swap leg (two legs) | `routeAvailable: false`, `steps: null` |

## POST /quotes/batch

Up to 20 prices or quotes in one call: each request is `GET /price`'s query as JSON, a quote with `fromAddress` and `toAddress`. Each answer has its own `status`.

```sh
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": "PEPE on base", "to": "BTC", "amount": "1" }] }'
```

```json
{
  "results": [
    { "index": 0, "status": 200, "requestId": "adfc71f1-d098-49d6-8bc4-a9237046b88c", "quote": { "route": "evm-btc-escrow", "fromAmount": "4000000000000000", "toAmount": "10853", "formatted": "…" } },
    { "index": 1, "status": 400, "requestId": "a0f5af3f-1c42-4246-b6b3-1de95039e9f6", "error": { "code": "invalid_input", "message": "PEPE is not a coin Maxy swaps on Base. On Base it swaps ETH, USDC, USDT. GET /pairs (swap.pairs() in the SDK) lists every pair.", "retryable": false, "docs": "https://maxy.co/docs/error-codes#invalid_input" } }
  ]
}
```

## GET /prices/stream

`GET /price` as server-sent events every few seconds: `price`, `error` and `end`. A connection lasts two minutes at most, then reconnect.

| Parameter | Required | Meaning |
| --- | --- | --- |
| `intervalSeconds` | no | 5 to 60; default 5 |
| `ticket` | no | In place of the key, from a browser: see below |

```sh
curl -sN -G -H "x-maxy-key: $MAXY_API_KEY" "$BASE/prices/stream" --data-urlencode "from=ETH on base" -d to=BTC -d amount=0.01
```

```text
retry: 5000

event: price
data: {"route":"evm-btc-escrow","liquidityAvailable":true,"fromAmount":"10000000000000000","toAmount":"27816",…}
```

## POST /prices/stream-ticket

`EventSource` cannot send a header, and a key never goes in a URL: ask a ticket from your server, then open the stream with it. A ticket opens one pair's stream for 10 minutes, and carries your key's id, never the key.

```sh
curl -s -X POST -G -H "x-maxy-key: $MAXY_API_KEY" "$BASE/prices/stream-ticket" --data-urlencode "from=ETH on base" -d to=BTC -d amount=0.01
```

```json
{
  "ticket": "mst1.eyJrIjoicCIsInQ…",
  "expiresAt": 1795137555,
  "expiresAtIso": "2026-11-20T01:19:15.000Z",
  "stream": "https://openapi.maxy.co/v1/prices/stream?from=ETH+on+base&to=BTC&amount=0.01&ticket=mst1.…",
  "sandbox": true
}
```

```js
const source = new EventSource(ticket.stream);
source.addEventListener('price', (e) => console.log(JSON.parse(e.data).formatted.receive));
```

A changed, expired or other pair's ticket answers `401 invalid_ticket`: ask a new one.

## Errors

| HTTP | `code` | When |
| --- | --- | --- |
| 400 | `invalid_input` | No amount or two, an unknown coin, or a quote without `fromAddress` and `toAddress` |
| 400 | `unsupported_route` | A pair Maxy does not swap, such as SOL to ETH |
| 422 | `amount_out_of_range` | Below the smallest order: `details.minSats` |
| 429 | `rate_limited` | Over your limit. Price reads count apart, at ten times your limit |

Errors: [Error codes](https://maxy.co/docs/error-codes).

---
Source: https://maxy.co/docs/quote-routes (Maxy Docs › API reference › Routes)
