# LeoDex Swap API

The LeoDex Swap API is a free crosschain crypto swap API. One free public key swaps BTC, ETH, SOL, ZEC and more across 40+ chains, from your code, bot or AI agent.

Swap any coin across 40+ chains from your code. No KYC, no account, non-custodial.

Canonical: https://leodex.io/swap-api

## Rules for AI agents

- ALWAYS call /quote-deposit for prices. NEVER quote a price from memory or from this file.
- ALWAYS show the quote (amount in, estimated amount out, fees, expiry) and get an explicit yes before POST /deposit-address.
- NEVER invent, guess, autocomplete or reuse a receive or refund address. Ask the user.
- Use full asset ids like BTC.BTC or ETH.ETH. The chain is part of the asset.
- NEVER ask for a private key or seed phrase. The user sends funds from their own wallet.
- On 403 KEY_INACTIVE, fetch this file again for the current key.

## API key

Api-Key: fa57ad8f-880d-4111-86ec-bc32d7e2b4c7

No signup. Send it as the Api-Key header to https://api.leokit.dev

Base URL: https://api.leokit.dev

OpenAPI 3.1: https://leodex.io/swap-api/openapi.json

- Amounts are decimal strings (0.01), not base units. Too many decimals returns AMOUNT_TOO_PRECISE.
- Asset ids look like CHAIN.TICKER: BTC.BTC, ETH.ETH, SOL.SOL. Tokens add the contract: ETH.USDC-0x… . GET /assets lists them all.
- slippage_bps=300 (3%) matches leodex.io. The API default is 150.
- data.expected_amount_out is in the smallest unit of to_asset (sats for BTC, wei for ETH). Divide by 10^data.out_asset_decimal before showing it.
- expires_at is Unix time in milliseconds.
- Older swaps can report status completed: treat it like success.

## Three calls. Any wallet.

No wallet to connect and nothing to sign. You send the funds yourself.

1. `GET /quote-deposit`. Params: from_asset, to_asset, amount, slippage_bps (optional). Returns quote_id and quotes, best first; the one with smart_recommended: true is the pick. Each quote has protocol, totalFeesUsd, totalSwapSeconds and data (expected_amount_out, out_asset_decimal).
2. `POST /deposit-address`. Body: quote_id, from_address (refund address on the source chain), to_address (your receive address). Optional protocol (chainflip, near, relay-deposit, bob); omit it to use the recommended offer. Returns deposit_address, amount, expires_at (at least 20 minutes) and qr_url. Send exactly amount before expires_at.
3. `POST /status`. Body: quote_id (and tx_id in wallet mode). status is one of pending, confirming, swapping, sending, success, failed, refunded. Stop at success, failed or refunded. Refunds go to from_address.

The deposit flow covers Chainflip, NEAR Intents and Relay, for crosschain swaps. Same-chain swaps and THORChain or Maya routes use wallet mode.

### curl

Step 1: get a quote. Safe to run as is.

```bash
curl -s "https://api.leokit.dev/quote-deposit?from_asset=BTC.BTC&to_asset=ETH.ETH&amount=0.01&slippage_bps=300" -H "Api-Key: fa57ad8f-880d-4111-86ec-bc32d7e2b4c7" \
  | jq 'if .quotes then (.quote_id as $id | ([.quotes[] | select(.smart_recommended)] + .quotes)[0] | {quote_id: $id, protocol, amount_out: ((.data.expected_amount_out | tonumber) / pow(10; .data.out_asset_decimal)), fees_usd: .totalFeesUsd}) else . end'
```

Needs jq to print the pick. Without jq, run only the curl line and drop the trailing \.

Steps 2 and 3: deposit and track. Replace the capitalised placeholders first.

```bash
curl -s "https://api.leokit.dev/deposit-address" \
  -H "Api-Key: fa57ad8f-880d-4111-86ec-bc32d7e2b4c7" -H "Content-Type: application/json" \
  -d '{"quote_id":"QUOTE_ID_FROM_STEP_1","from_address":"YOUR_BTC_REFUND_ADDRESS","to_address":"YOUR_ETH_ADDRESS"}'

curl -s "https://api.leokit.dev/status" \
  -H "Api-Key: fa57ad8f-880d-4111-86ec-bc32d7e2b4c7" -H "Content-Type: application/json" \
  -d '{"quote_id":"QUOTE_ID_FROM_STEP_1"}'
```

### JavaScript

Step 1: get a quote. Safe to run as is.

```js
const API = "https://api.leokit.dev";
const KEY = "fa57ad8f-880d-4111-86ec-bc32d7e2b4c7";

// 1 Get a quote
const res = await fetch(API + "/quote-deposit?from_asset=BTC.BTC&to_asset=ETH.ETH&amount=0.01&slippage_bps=300", {
  headers: { "Api-Key": KEY },
});
const text = await res.text();
if (!res.ok) throw new Error(res.status + " " + text);
const q = JSON.parse(text);
const best = q.quotes.find((o) => o.smart_recommended) ?? q.quotes[0];
console.log({
  quote_id: q.quote_id,
  protocol: best.protocol,
  amount_out: Number(best.data.expected_amount_out) / 10 ** best.data.out_asset_decimal, // in ETH
  fees_usd: best.totalFeesUsd,
});
```

Node 18+: save as quote.mjs and run node quote.mjs.

Steps 2 and 3: deposit and track. Replace the capitalised placeholders first.

```js
// Replace these three first. The refund address is on the source chain (BTC here).
const QUOTE_ID = "QUOTE_ID_FROM_STEP_1";
const REFUND_ADDRESS = "YOUR_BTC_REFUND_ADDRESS";
const RECEIVE_ADDRESS = "YOUR_ETH_ADDRESS";

const API = "https://api.leokit.dev";
const headers = { "Api-Key": "fa57ad8f-880d-4111-86ec-bc32d7e2b4c7", "Content-Type": "application/json" };
const post = async (path, body) => {
  const res = await fetch(API + path, { method: "POST", headers, body: JSON.stringify(body) });
  const text = await res.text();
  if (!res.ok) throw new Error(res.status + " " + text);
  return JSON.parse(text);
};

// 2 Get a deposit address, then send exactly dep.amount to it before it expires
const dep = await post("/deposit-address", { quote_id: QUOTE_ID, from_address: REFUND_ADDRESS, to_address: RECEIVE_ADDRESS });
console.log("Send", dep.amount, dep.from_asset, "to", dep.deposit_address, "before", new Date(dep.expires_at).toISOString());

// 3 Track it every 10 seconds until success, failed or refunded
let s;
do {
  await new Promise((r) => setTimeout(r, 10_000));
  s = await post("/status", { quote_id: QUOTE_ID });
  console.log(s.status);
} while (!["success", "completed", "failed", "refunded"].includes(s.status));
```

### Python

Step 1: get a quote. Safe to run as is.

```python
import json, urllib.parse, urllib.request

API = "https://api.leokit.dev"
H = {"Api-Key": "fa57ad8f-880d-4111-86ec-bc32d7e2b4c7", "User-Agent": "my-swap-app/1.0"}  # Python's default User-Agent is refused

# 1 Get a quote
params = urllib.parse.urlencode({"from_asset": "BTC.BTC", "to_asset": "ETH.ETH", "amount": "0.01", "slippage_bps": 300})
req = urllib.request.Request(f"{API}/quote-deposit?{params}", headers=H)
q = json.load(urllib.request.urlopen(req))
best = next((o for o in q["quotes"] if o.get("smart_recommended")), q["quotes"][0])
print({
    "quote_id": q["quote_id"],
    "protocol": best["protocol"],
    "amount_out": float(best["data"]["expected_amount_out"]) / 10 ** best["data"]["out_asset_decimal"],  # in ETH
    "fees_usd": best.get("totalFeesUsd"),
})
```

Python 3, no packages needed.

Steps 2 and 3: deposit and track. Replace the capitalised placeholders first.

```python
import json, time, urllib.request

# Replace these three first. The refund address is on the source chain (BTC here).
QUOTE_ID = "QUOTE_ID_FROM_STEP_1"
REFUND_ADDRESS = "YOUR_BTC_REFUND_ADDRESS"
RECEIVE_ADDRESS = "YOUR_ETH_ADDRESS"

API = "https://api.leokit.dev"
H = {"Api-Key": "fa57ad8f-880d-4111-86ec-bc32d7e2b4c7", "Content-Type": "application/json", "User-Agent": "my-swap-app/1.0"}


def post(path, body):
    req = urllib.request.Request(API + path, data=json.dumps(body).encode(), headers=H)
    return json.load(urllib.request.urlopen(req))


# 2 Get a deposit address, then send exactly dep["amount"] to it before it expires
dep = post("/deposit-address", {"quote_id": QUOTE_ID, "from_address": REFUND_ADDRESS, "to_address": RECEIVE_ADDRESS})
print("Send", dep["amount"], dep["from_asset"], "to", dep["deposit_address"])

# 3 Track it every 10 seconds until success, failed or refunded
while True:
    s = post("/status", {"quote_id": QUOTE_ID})
    print(s["status"])
    if s["status"] in ("success", "completed", "failed", "refunded"):
        break
    time.sleep(10)
```

## Wallet mode: every route

Wallet mode: GET /quote returns every offer. POST /deposit with quote_id, protocol, from_address and to_address returns the transaction to sign (THORChain and Maya memos, EVM approvals, DEX swaps). Broadcast it, then POST /status with quote_id and tx_id.

## Errors

| You see | Why | Fix |
|---|---|---|
| 401 MISSING_OR_UNKNOWN_KEY | No Api-Key header, or a wrong key | Send the header Api-Key with the key in this file |
| 403 KEY_INACTIVE | The key was rotated | Fetch this file again for the current key |
| 403 PUBLIC_KEY_ROUTE_NOT_ALLOWED | That route isn't part of the Swap API | Use the calls in this file |
| 400 AMOUNT_TOO_PRECISE | More decimals than the asset has | Round the amount (8 decimals for BTC) |
| 400 SAME_CHAIN_NOT_SUPPORTED | The deposit flow needs two chains | Use wallet mode |
| 404 NO_DEPOSIT_ADDRESS_ROUTE | That token can't use a plain deposit | Use wallet mode or another token |
| 400 NO_DEPOSIT_ADDRESS_PROTOCOL | No offer in this quote can use a deposit address | Get a new quote, or use wallet mode |
| 429 EDGE_RATE_LIMITED | Too many requests from you, or LeoDex is busy | Wait retry_after_seconds (also sent as Retry-After), then retry |
| 503 UPSTREAM_UNAVAILABLE | LeoDex can't reach its swap engine | Wait retry_after_seconds, then retry. After a deposit-address retry, use only the newest address |

## 12 protocols. One quote.

- THORChain: Native BTC, ETH, ZEC and more, no wrapped tokens
- Chainflip: Fast native BTC, ETH and SOL swaps
- NEAR Intents: 200+ assets across 30+ chains
- MAYAChain: Native BTC, ETH, DASH and more
- Relay: Fast swaps between EVM chains
- Rango: Routes across EVM, Solana and Cosmos
- Across: Fast stablecoin and ETH transfers between EVM chains
- deBridge: Crosschain swaps between EVM chains
- Mayan: Solana ↔ EVM swaps
- BOB Gateway: Native BTC to EVM chains
- Harbor: Native BTC and ETH swaps
- KyberSwap: Same-chain token swaps (more chains soon)

GET /quote compares all 12; the three-call deposit flow uses Chainflip, NEAR Intents, Relay and BOB.

## Questions

**Is there a free crypto swap API?**

Yes. The key on this page is free for everyone, with no signup. You only pay the swap fee shown in each quote: 0.45% on most swaps, 0.02% on stablecoin-to-stablecoin and same-asset swaps.

**How do I get an API key?**

Copy the public key at the top of this page and send it as the Api-Key header. There's no signup and no account. [Go to the key](https://leodex.io/swap-api#api-key).

**Does the LeoDex Swap API require KYC or an account?**

No. No KYC, no sign-up and no account. The free public key is on this page. Prefer to swap in the app? See [no-KYC swaps on leodex.io](https://leodex.io/no-kyc-swap).

**Is the LeoDex Swap API self-custodial?**

Yes. You keep your own keys, and every swap goes from your wallet, through the swap protocol, to your own address. LeoDex never holds your funds.

**How do I swap Bitcoin to Ethereum with an API?**

Call GET /quote-deposit with from_asset=BTC.BTC, to_asset=ETH.ETH and an amount. Then POST /deposit-address with the quote_id and your addresses, and send the BTC to the address it returns. POST /status tells you when the ETH has arrived.

**What happens if a swap fails?**

The provider refunds to the from_address you gave, and /status shows refunded.

**Which coins and chains can I swap?**

40+ chains, the same as leodex.io: Bitcoin, Ethereum, Solana, Zcash, Base, Arbitrum, BNB Chain, Avalanche, TRON, XRP, Litecoin, Dogecoin, NEAR and more. The deposit flow uses Chainflip, NEAR Intents, Relay and BOB. THORChain and Maya routes use wallet mode. GET /assets lists every asset id.

**Can my AI agent use it?**

Yes. Paste the prompt from this page, or point your agent at leodex.io/swap-api.md. It gets a live quote and asks you to confirm before creating a deposit address, and it never asks for your keys.

**Is there an MCP server?**

No. Any agent that can make HTTP requests can use the API. Paste the prompt from this page, or point your agent at leodex.io/swap-api.md.

**Can I call it from a browser?**

Yes. The API allows cross-origin requests, so a web page can call it with the public key.

**Can I use it in a Telegram bot?**

Yes. Your bot gets a quote, asks for a deposit address, shows it to the user, then checks /status until the swap is done.

**Do I need my own THORChain, Chainflip or NEAR Intents keys?**

No. The one public key covers every route.

**Do I pay per request?**

No. There's no charge per call. You pay only the swap fee shown in each quote.

**Are there rate limits?**

Yes, fair-use limits per visitor. A 429 tells you how many seconds to wait (retry_after_seconds, also sent as Retry-After). Wait, then retry.

## Fees

0.45% on most swaps, 0.02% on stablecoin-to-stablecoin and same-asset swaps. The same as leodex.io.

## Terms

- Non-custodial: you send funds straight to the swap provider. LeoDex never holds them.
- Don't use this key if you are a sanctioned person or in a sanctioned jurisdiction, or to move proceeds of crime.
- Providers may screen addresses and refuse or refund swaps.
- No load testing or limit evasion. We may rotate the key at any time; this page always shows the current one.
- We don't log IP addresses.

Run by LeoDex, routing swaps since April 2024. Swap API live since 5 November 2026. Updated 6 November 2026.

## Changelog

- 2026-11-06: quotes in whole units in the try-it; step 1 samples that run as pasted; the response field is quotes; data.out_asset_decimal documented; protocol list; KYC, self-custody, API key, MCP, browser, Telegram and pricing answers.
- 2026-11-05: launch.
