# Chain and token routes

The four reads that say what Maxy swaps and whether an address can be paid. Use them to fill a coin picker, to add Maxy's pairs to a router, and to check an address before you quote. Each takes a secret or a publishable key, changes nothing, and is safe to cache. The samples use `BASE` and `MAXY_API_KEY` from [Get a price](https://maxy.co/docs/buy-btc#get-a-price); the answers are real sandbox answers, trimmed.

## GET /chains

The chains Maxy swaps on: Bitcoin, each EVM chain with its settler contract, and Solana. No parameters.

```sh
curl -s -H "x-maxy-key: $MAXY_API_KEY" "$BASE/chains"
```

```json
{
  "chains": [
    { "chain": "bitcoin", "name": "Bitcoin", "type": "bitcoin", "nativeSymbol": "BTC", "settler": null, "explorer": "https://mempool.space", "caip2": "bip122:000000000019d6689c085ae165831e93" },
    { "chain": 8453, "name": "Base", "type": "evm", "nativeSymbol": "ETH", "settler": "0xeC5a05b28dd848F628e19CB26Df32f053e64ab86", "explorer": "https://basescan.org", "caip2": "eip155:8453" },
    "…"
  ],
  "sandbox": true
}
```

`chain` is a number for an EVM chain, or `bitcoin` or `solana`. `settler` is null where there is none: Solana settles through Maxy's program. Ethereum, Optimism and Polygon come last with `legOnly: true`: a two-leg route's swap or bridge leg runs there, and its escrow opens on Base (`settlesOn: 8453`).

## GET /tokens

The tokens on one chain, or on every chain without `chain`.

| Parameter | Required | Meaning |
| --- | --- | --- |
| `chain` | no | A chain name, id or CAIP-2 id: `base`, `8453`, `eip155:8453`, `bitcoin`, `solana` |
| `search` | no | With `chain`: any token on that EVM chain, by symbol, name or address, found as the Maxy app's token picker finds it. `decimals` is read from the token on its chain. Each result carries `name`, `logoURI` and `routes` (`buyBtc`, `sellBtc`) |
| `limit` | no | With `search`: at most this many, 1 to 50 (20) |

```sh
curl -s -H "x-maxy-key: $MAXY_API_KEY" "$BASE/tokens?chain=base"
```

```json
{
  "tokens": [
    { "chain": 8453, "chainName": "Base", "symbol": "ETH", "address": "0x0000000000000000000000000000000000000000", "decimals": 18, "assetId": "eip155:8453/slip44:60" },
    { "chain": 8453, "chainName": "Base", "symbol": "USDC", "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "decimals": 6, "assetId": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" },
    "…"
  ],
  "sandbox": true
}
```

The zero address is the chain's own coin. The list holds only tokens in a pair, each with its decimals; `?all=true` adds the others Maxy knows, which go in two legs as any other token. Read `decimals` from here rather than assuming 6: USDC and USDT on BNB Chain have 18.

## GET /pairs

Every pair, with its route, settler, smallest order and Bitcoin confirmations. No parameters. `GET /pairs` is built fresh on every request, in about 40 ms. The response may be cached for up to 60 seconds (`Cache-Control: private, max-age=60`); the SDK re-reads it every 60 seconds. Read it again whenever you need the latest list. Each pair carries `orderSize`: `minSats` or `minUsd` (the smallest order) and `maxUsd`, your key's order size cap in dollars (null with no cap); `orderSizeNote` says the same in words. `anyToken` and `anyTokenNote` describe the two-leg routes that take any token on a chain (below).

```sh
curl -s -H "x-maxy-key: $MAXY_API_KEY" "$BASE/pairs"
```

```json
{
  "pairs": [
    "…",
    {
      "from": { "chain": 8453, "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "symbol": "USDC", "decimals": 6, "chainName": "Base" },
      "to": { "chain": "bitcoin", "token": "BTC", "symbol": "BTC", "decimals": 8, "chainName": "Bitcoin" },
      "label": "USDC on Base → BTC",
      "fromAssetId": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "toAssetId": "bip122:000000000019d6689c085ae165831e93/slip44:0",
      "route": "evm-btc-gasless",
      "settler": "0xeC5a05b28dd848F628e19CB26Df32f053e64ab86",
      "minSats": 546,
      "requiredConfirmations": 1,
      "confirmationsBySize": true
    }
  ],
  "sandbox": true
}
```

| Field | Meaning |
| --- | --- |
| `route` | Decides what the user signs and sends: [Chains and tokens](https://maxy.co/docs/chains-and-tokens#routes) |
| `minSats`, `minUsd` | The smallest order, in sats where it is fixed in sats, in dollars where the solver prices it |
| `requiredConfirmations` | Bitcoin confirmations the settler needs, at the least |
| `confirmationsBySize` | `true` when larger orders need more: the quote states the number |

`coinToCoin` lists the routes with no BTC in them, one entry per direction: `cross-evm`, `chain-swap` and `sol-swap`, each with `from`, `to`, an `example` and its `carrier` ([Solana and Sui swaps](https://maxy.co/docs/solana-and-sui-swaps)). `anyToken` lists the two-leg routes that take any token on a chain, one entry per chain and direction: `route` (`evm-btc-bridge` buying, `btc-evm` selling), `label`, `chain`, `caip2`, `legs: 2`, `settlesOn` or `payoutChain`, and `search`, the token search for that chain. [Any token to BTC](https://maxy.co/docs/any-token-to-btc)

## GET /addresses/validate

Whether an address is well formed for a chain, and whether an order would pay it. Ask before you quote, and show `reason` next to the address field.

| Parameter | Required | Meaning |
| --- | --- | --- |
| `chain` | yes | A chain name, id or CAIP-2 id |
| `address` | yes | The address to check |

```sh
curl -s -G -H "x-maxy-key: $MAXY_API_KEY" "$BASE/addresses/validate" \
  -d chain=bitcoin -d address=bc1p5d7rjq7g6rdk2yhzks9smlaqtedr4dekq08ge8ztwac72sfr9rusxg3297
```

```json
{
  "address": "bc1p5d7rjq7g6rdk2yhzks9smlaqtedr4dekq08ge8ztwac72sfr9rusxg3297",
  "chain": "bitcoin",
  "valid": true,
  "type": "p2tr",
  "network": "mainnet",
  "payable": false,
  "reason": "Receive BTC on a native SegWit address (bc1q...). Taproot and legacy addresses are not paid by this route.",
  "sandbox": true
}
```

An address that is not valid is still a `200`, with `valid: false` and a `reason`. `type` is `p2wpkh`, `p2wsh`, `p2tr`, `p2pkh` or `p2sh` on Bitcoin, `evm` or `solana` elsewhere. `payable` is `true` for a native SegWit (`bc1q…`) mainnet address on Bitcoin, and for a valid address that is not a burn address on EVM chains and Solana.

## Errors

| HTTP | `code` | When |
| --- | --- | --- |
| 400 | `invalid_input` | `/addresses/validate` without `chain` or `address`, or a chain Maxy does not know |
| 400 | `unsupported_chain` | `GET /tokens` with a chain id Maxy does not swap on, such as `chain=137` |
| 401 | `auth_required`, `invalid_api_key` | No key, or a key Maxy did not issue |
| 403 | `key_revoked`, `origin_not_allowed` | A revoked key; a publishable key from another origin |
| 429 | `rate_limited` | Over your limit: wait `Retry-After` seconds |

Every code: [Error codes](https://maxy.co/docs/error-codes). To price a pair: [Quote routes](https://maxy.co/docs/quote-routes).

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