# Quickstart

> Quote, create and track a Wagyu swap in four HTTP calls, with real requests and responses from the live API.

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](https://docs.wagyu.xyz/money-and-settlement.md#convert-between-display-and-atomic-amounts) does it safely.
- **Send a User-Agent.** Requests with Python's default `Python-urllib` user agent are refused with `403` before they reach the API. curl, `fetch` and `requests` work as they are.

## 1. Pick the assets

An asset is a `chainId` plus a token value. The common ones come back in one call:

```bash
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 -->
```bash
curl 'https://api.wagyu.xyz/v2/swaps/assets/tokens?direction=from&chainId=1&q=usdc&limit=2'
```

<!-- JavaScript -->
```javascript
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();
```

<!-- Python -->
```python
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()
```

<!-- Response · 200 · captured 4 Dec 2026, 19:24 UTC -->
```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](https://docs.wagyu.xyz/chains.md).

## 2. Ask for a quote

Send the pair and an amount. This one quotes 0.01 BTC into XMR:

<!-- curl -->
```bash
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"
  }'
```

<!-- JavaScript -->
```javascript
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();
```

<!-- Python -->
```python
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()
```

<!-- Response · 200 · captured 4 Dec 2026, 19:24 UTC -->
```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](https://docs.wagyu.xyz/money-and-settlement.md#fees). |
| `minDepositUsd` | The minimum deposit for the source chain, in USD. |
| `integratorFee` | Your fee if you send an [integrator key](https://docs.wagyu.xyz/authentication.md), 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.

> **Check the minimum yourself:** A quote under the minimum is **not** refused: it comes back as `200` with an ordinary, non-zero `toAmount` and nothing that marks it as too small. Compare `fromAmountUsd` with `minDepositUsd` before you let the user continue. (A dust amount, far below any minimum, fails with `no_route` instead.) Current minimums per chain are on [Chains and tokens](https://docs.wagyu.xyz/chains.md).

To see the same quote in a browser first, open the pair page on wagyu.xyz, for example [BTC to XMR](https://wagyu.xyz/swap/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`.

<!-- Creates a real order -->
```bash
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. |

> **Never retry this call automatically:** `POST /v2/swaps` has no idempotency key. If it times out, the first request may have created an order, and a second one creates another. Do not resend it on your own. With an [integrator key](https://docs.wagyu.xyz/authentication.md) you can supply your own `sessionId` at creation, then list that session's orders with `GET /v2/orders` to see whether the first request went through.

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:

```bash
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](https://docs.wagyu.xyz/order-lifecycle.md#statuses): keep reading them every 10 minutes for 7 days. For instant updates, open a [WebSocket](https://docs.wagyu.xyz/live-updates.md) as well, but keep the REST read as the source of truth.

A wrong session and a missing order both answer `404`, on purpose:

<!-- GET /v2/swaps/docs-example-0000 · 404 -->
```json
{
  "code": "not_found",
  "error": "Not found."
}
```

## Next steps

- [Order lifecycle](https://docs.wagyu.xyz/order-lifecycle.md): every status and `customerState`, and when to show which action.
- [Deposits and refunds](https://docs.wagyu.xyz/deposits.md): partial deposits, late deposits and refund addresses.
- [API keys and fees](https://docs.wagyu.xyz/authentication.md): attribute orders to your app and earn a fee on each.
- [Errors, limits, retries](https://docs.wagyu.xyz/actions-and-retries.md): what each error code means and what to do.

---
Source: https://docs.wagyu.xyz/getting-started · Built from the live Wagyu API on 2026-12-04.
