Get started
Quickstart
Four calls take a user from "I want XMR" to a completed swap. No key or account is needed. Every response on this page was captured from the live API when the site was built.
#Before you start
- Base URL:
https://api.wagyu.xyz. Keep it in one variable. - Call the API from your server or app, not from a web page on another site: the API only allows browser requests from
https://wagyu.xyz(CORS). - Send amounts as integer strings in atomic units.
"100000000000000000"is 0.1 ETH (18 decimals). The conversion snippet does it safely. - Send a User-Agent. Requests with Python's default
Python-urllibuser agent are refused with403before they reach the API. curl,fetchandrequestswork as they are.
#1. Pick the assets
An asset is a chainId plus a token value. The common ones come back in one call:
curl 'https://api.wagyu.xyz/v2/swaps/assets'chains lists every chain, sourceChainIds and destinationChainIds say which side each can be on, and featuredTokens gives the token value and decimals of the main asset on each chain. For anything else, search the catalog by symbol, name or address:
curl 'https://api.wagyu.xyz/v2/swaps/assets/tokens?direction=from&chainId=1&q=usdc&limit=2'const res = await fetch('https://api.wagyu.xyz/v2/swaps/assets/tokens?direction=from&chainId=1&q=usdc&limit=2'
);
const data = await res.json();import requests
res = requests.get('https://api.wagyu.xyz/v2/swaps/assets/tokens?direction=from&chainId=1&q=usdc&limit=2', timeout=30)
data = res.json(){
"tokens": [
{
"address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"symbol": "USDC",
"decimals": 6,
"chainId": 1,
"name": "USD Coin",
"logoURI": "https://cdn.jsdelivr.net/npm/cryptocurrency-icons@0.18.1/svg/color/usdc.svg",
"priceUSD": "1.0014418587"
},
{
"address": "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490",
"symbol": "3Crv",
"decimals": 18,
"chainId": 1,
"name": "DAI / USDC / USDT",
"logoURI": "https://static.debank.com/image/eth_token/logo_url/0x6c3f90f043a72fa612cbac8115ee7e52bde6e490/ae73a75547c237febeeaee87f1c9627f.png",
"priceUSD": "1.0376558348203224"
}
],
"total": 134,
"nextOffset": 2,
"catalogStale": false
}Use the token's address exactly as returned. For native coins that value is chain-specific: XMR on Monero, bitcoin on Bitcoin, the zero address on EVM chains. The full list is on Chains and tokens.
#2. Ask for a quote
Send the pair and an amount. This one quotes 0.01 BTC into XMR:
curl -X POST 'https://api.wagyu.xyz/v2/swaps/quote' \
-H 'content-type: application/json' \
-d '{
"fromChainId": 20000000000001,
"toChainId": 0,
"fromToken": "bitcoin",
"toToken": "XMR",
"fromAmount": "1000000",
"toAddress": "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"
}'const res = await fetch('https://api.wagyu.xyz/v2/swaps/quote', {
method: 'POST',
headers: {"content-type":"application/json"},
body: JSON.stringify({
"fromChainId": 20000000000001,
"toChainId": 0,
"fromToken": "bitcoin",
"toToken": "XMR",
"fromAmount": "1000000",
"toAddress": "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"
}),
});
const data = await res.json();import requests
res = requests.post('https://api.wagyu.xyz/v2/swaps/quote', json={
"fromChainId": 20000000000001,
"toChainId": 0,
"fromToken": "bitcoin",
"toToken": "XMR",
"fromAmount": "1000000",
"toAddress": "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A"
}, timeout=30)
data = res.json(){
"toAmount": "1509332010606",
"fromAmount": "1000000",
"fromAmountUsd": "490.52",
"fromSymbol": "BTC",
"toAmountUsd": "479.38",
"toSymbol": "XMR",
"feeFraction": 0.02,
"feeBreakdown": {
"platformFeeRate": 0.02,
"platformFeeXmr": "0.030802694094",
"platformFeeUsd": "9.78",
"bridgeFlatFeeXmr": "0",
"bridgeFlatFeeUsd": "0.00",
"hlSizeRoundingXmr": "0.000007823528",
"hlSizeRoundingUsd": "0.00",
"hlTakerFeeXmr": "0.0004852953",
"hlTakerFeeUsd": "0.15",
"totalFeeUsd": "9.78",
"totalCostUsd": "9.94"
},
"integratorFee": null,
"minDepositUsd": 40,
"isXmrInput": false,
"isXmrOutput": true
}What matters in the answer:
| Field | Meaning |
|---|---|
toAmount |
Estimated amount received, in atomic units of toToken (XMR has 12 decimals). |
fromAmountUsd, toAmountUsd |
Display values in USD. Never use them to settle anything. |
feeFraction |
Wagyu's fee for this route as a fraction: 0.02 is 2%. It differs by route: see fees. |
minDepositUsd |
The minimum deposit for the source chain, in USD. |
integratorFee |
Your fee if you send an integrator key, otherwise null. |
To quote an exact output instead ("I want exactly 1 XMR"), send toAmount instead of fromAmount. The response then carries the fromAmount to send. The user receives at least toAmount; the fromAmount can be slightly above the least amount that would do. An exact-output quote can also be refused with 400 invalid_request and a message saying it could not be computed in time (today mostly with Bitcoin as the source): quote by the amount you send instead.
To see the same quote in a browser first, open the pair page on wagyu.xyz, for example BTC to XMR.
#3. Create the order
When the user confirms, send the same body to POST /v2/swaps. Here toAddress is required: it is where the user receives the funds. For a native-coin source such as XMR, also send a refundAddress.
curl -X POST 'https://api.wagyu.xyz/v2/swaps' \
-H 'content-type: application/json' \
-d '{
"fromChainId": 20000000000001,
"toChainId": 0,
"fromToken": "bitcoin",
"toToken": "XMR",
"fromAmount": "1000000",
"toAddress": "<the user's Monero address>"
}'The response is the order. Save two values and show four:
| Field | What to do with it |
|---|---|
orderId |
Save it. It is public and identifies the order, but grants no access. |
sessionId |
Save it privately. It is the owner credential for every later read or action. |
depositAddress |
Show it. The user sends funds here. |
depositAmount |
Show it exactly, converted with depositTokenDecimals. |
depositTokenSymbol, depositChainId |
Show which asset and network to send. |
expiresAt |
Show the deadline. The deposit must arrive before it. |
There is no sandbox: every order you create is real. An order that is never funded simply expires.
#4. Track it until it ends
Read the order with its session:
curl 'https://api.wagyu.xyz/v2/swaps/<orderId>' \
-H 'x-session-id: <sessionId>'Render customerState, which tells you what the user should see and whether they must act. Keep polling, every 30 seconds or slower, until status is completed or refunded. failed and expired are not final: keep reading them every 10 minutes for 7 days. For instant updates, open a WebSocket as well, but keep the REST read as the source of truth.
A wrong session and a missing order both answer 404, on purpose:
{
"code": "not_found",
"error": "Not found."
}#Next steps
- Order lifecycle: every status and
customerState, and when to show which action. - Deposits and refunds: partial deposits, late deposits and refund addresses.
- API keys and fees: attribute orders to your app and earn a fee on each.
- Errors, limits, retries: what each error code means and what to do.