Build on it
Add swaps to your site or app. You earn half of what we earn on every swap you send us.
Widget
One tag. It's an iframe from our domain, so wallets and addresses never touch your page. With your public key, it can only be framed by your own sites.
<script src="https://swaprouter.app/embed.js" async></script>
<swap-widget key="pk_…" from="base:0x8335…2913" to="monero:native" amount="100"></swap-widget>It tells your page when a swap is created and when its state changes:
const widget = document.querySelector('swap-widget');
widget.addEventListener('swap.updated', (e) => console.log(e.detail.state));Your theme
<swap-widget theme="light" accent="#ff5500" button-text="#14161a"
radius="12" font="Arial, sans-serif"></swap-widget>Choose light, dark (default) or auto. The same settings work as /embed query parameters. Use local system fonts; iframe fonts are separate from your page. No fonts are downloaded.
Tokens: background, surface, border, text, muted, accent, button-text (hex, rgb or hsl); radius (0–32 px); font (family list); scale (0.875–1.25). Invalid values are ignored.
API
For your own UI, use the SDK: quoteStream for live routes, createSwap to book, then getSwap or signed webhooks to track it.
Quote, book and track swaps from your server. Money is always an integer string in the asset's smallest unit. Full reference: OpenAPI spec.
import { SwapClient } from '@swap/sdk';
const api = new SwapClient({ baseUrl: 'https://swaprouter.app', secretKey: process.env.SWAP_SECRET_KEY });
const quote = await api.quote({ from: 'base:0x8335…2913', to: 'monero:native', amount: '100000000' });
const { secret, swap } = await api.createSwap(
{ routeId: quote.routes[0].id, recipient, refundAddress, clientReference: 'order-123' },
{ idempotencyKey: 'order-123' },
);Taking a payment? Pass exactOut: true and amount is what the recipient gets, exactly: fixed-rate, one-step routes ranked by the least to send (costIn). The widget takes mode="fixed" too.
Each route has kycRisk and privacy (0–5, what we must keep or send about the user for its providers; absent when unscored). Pass maxPrivacy: true for only routes with low KYC risk and privacy 5.
Quotes may carry prices: USD per whole unit of the two coins, in micro-USD ("1000000" is $1), only for coins with a known price. Dollar value = amount × price / 10decimals.
Use your secret key only on your server. Send the same Idempotency-Key when you retry and you get the first swap back, never a second booking.
MCP
AI agents can quote, book and track swaps through our MCP server at /mcp (Streamable HTTP, no key). Booking only returns a deposit address and QR; nothing moves until the user sends.
Live rates and limits
The rates table on the home and pair pages is the same for every visitor, people and crawlers alike, and is checked every 10 minutes. Amounts are what the user receives after the providers' fees, for the amount sent at a floating rate. Some providers publish a minimum and maximum per coin; outside them that provider simply returns no route, and the others still quote.
Webhooks
We POST swap.updated to your URL whenever a swap's state changes, signed with your webhook secret. Retries back off for about two days. Each event's id stays the same across retries.
import { verifyWebhook } from '@swap/sdk';
const ok = await verifyWebhook(webhookSecret, req.headers.get('Swap-Signature') ?? '', rawBody);Keys
Make them on your partner account: a public key for the widget, a secret key for your server and a webhook secret, each shown once.
Providers
All providers are on by default. Turn any off on your partner account. Requests with your keys, your embed or MCP calls made with your key never ask them, and booking refuses a route through them. Quotes then list them in disabledProviders. With every provider off, quotes answer 409 no_providers_enabled.