> For the complete documentation index, see [llms.txt](https://docs.on.nexus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.on.nexus/dotswap/developers/l1-swap-and-liquidity-apis/swap-v3/runes.md).

# RUNES

## dotswap V3 Transaction request flow

<figure><img src="https://images.swap.dotwallet.com/web_restrict/ds_api/swap-flowchart.png" alt=""><figcaption></figcaption></figure>

## dotswap V3 Swap interface

## POST /dotswap/api/swap/quote

> aggregate and calculate Swap quotes

```json
{"openapi":"3.0.1","info":{"title":"backend interface","version":"1.0.0"},"servers":[{"url":"https://api-testnet4.dotswap.app","description":"Swap test"},{"url":"https://api.dotswap.app","description":"Swap production"}],"security":[],"paths":{"/dotswap/api/swap/quote":{"post":{"summary":"aggregate and calculate Swap quotes","deprecated":false,"description":"","tags":[],"parameters":[{"name":"Authorization","in":"header","description":"","required":true,"schema":{"type":"string"}},{"name":"User-Id","in":"header","description":"","required":true,"schema":{"type":"string"}},{"name":"User-Agent","in":"header","description":"","required":true,"schema":{"type":"string"}},{"name":"Content-Type","in":"header","description":"","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"from_token":{"type":"object","properties":{"coin_type":{"type":"string"},"tick":{"type":"string"},"token_id":{"type":"string"},"amount":{"type":"string","description":"When not needed, pass 0；"}},"required":["coin_type","tick"]},"to_token":{"type":"object","properties":{"coin_type":{"type":"string"},"tick":{"type":"string"},"token_id":{"type":"string"},"amount":{"type":"string","description":"When not needed, pass 0；"}},"required":["coin_type","tick"]},"fee_rate":{"type":"integer","title":"network fee","description":"with a minimum of 1, used to filter pools with no available UTXOs."}},"required":["from_token","to_token","fee_rate"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"msg":{"type":"string"},"data":{"type":"object","properties":{"quote_id":{"type":"string","title":"Quote ID","description":"used for creating PSBT"},"from_amount":{"type":"string"},"to_amount":{"type":"string"},"swap_method":{"type":"string"},"pool_infos":{"type":"array","items":{"type":"object","properties":{"service_fee":{"type":"number"},"name":{"type":"string"},"third_party_id":{"type":"integer"},"third_party_address":{"type":"string"},"pool_id":{"type":"integer"},"third_pool_id":{"type":"integer"},"pool_url":{"type":"string"},"icon":{"type":"string"},"from_tick":{"type":"object","properties":{"coin_type":{"type":"string"},"tick":{"type":"string"},"token_id":{"type":"string"}},"required":["coin_type","tick","token_id"]},"to_tick":{"type":"object","properties":{"coin_type":{"type":"string"},"tick":{"type":"string"},"token_id":{"type":"string"}},"required":["coin_type","tick","token_id"]},"from_tick_address":{"type":"string"},"to_tick_address":{"type":"string"},"from_balance":{"type":"string"},"to_balance":{"type":"string"},"from_margin":{"type":"string"},"to_margin":{"type":"string"},"from_to_fee_ratio":{"type":"string"},"to_from_fee_ratio":{"type":"string"},"dex_margin_percent":{"type":"string"},"pool_type":{"type":"string"},"sqrt_price":{"type":"string"},"liquidity":{"type":"null"},"ServiceFeeRatio":{"type":"number"},"deltaAmount":{"type":"string"}}},"description":"There are different scenarios based on the swap_method, which is used to display the swap path."}},"required":["quote_id","from_amount","to_amount","swap_method","pool_infos"]},"req_id":{"type":"string"}},"required":["code","msg","data","req_id"]}}},"headers":{}}}}}}}
```

> Use this interface to obtain the available swap amount.
>
> For example, if you want to check how much `YKO•KKK•KKK•KKK•KKK` you can get for `0.1 BTC`, then set `from_token` to `btc` and `to_token` to `runes`. Input the value of `from_token.amount`, and the interface will return `to_amount`, which represents the amount of `YKO•KKK•KKK•KKK•KKK`.

{% hint style="info" %}
1、Please save the `quote_id` field from the current interface for use in subsequent requests.

2、Note that the `quote_id` is valid for 35 seconds. Please use it within the valid time; otherwise, you need to request a new one.
{% endhint %}

## POST /dotswap/api/swap/create\_psbt

> Aggregate and create Swap PSBT

```json
{"openapi":"3.0.1","info":{"title":"backend interface","version":"1.0.0"},"servers":[{"url":"https://api-testnet4.dotswap.app","description":"Swap test"},{"url":"https://api.dotswap.app","description":"Swap production"}],"security":[],"paths":{"/dotswap/api/swap/create_psbt":{"post":{"summary":"Aggregate and create Swap PSBT","deprecated":false,"description":"","tags":[],"parameters":[{"name":"Authorization","in":"header","description":"","required":true,"schema":{"type":"string"}},{"name":"User-Id","in":"header","description":"","required":true,"schema":{"type":"string"}},{"name":"User-Agent","in":"header","description":"","required":true,"schema":{"type":"string"}},{"name":"Content-Type","in":"header","description":"","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"quote_id":{"type":"string","title":"Quote ID","description":"obtained from the calculation interface"},"fee_rate":{"type":"integer","title":"network fee","description":"with a minimum of 1, used for transaction construction."},"btc_address":{"type":"string"},"ord_address":{"type":"string"},"pubkey":{"type":"string"},"slippage":{"type":"integer"},"use_bitcoin_channel":{"type":"boolean"},"inscription":{"type":"array","items":{"type":"string","description":"Inscription ID，如90a78777e3635f392ca460e4422c9d92d20704d363a8ddbe09934f063a75a829i0"},"title":"array of inscription IDs","description":"required only for BRC20."}},"required":["btc_address","ord_address","pubkey","slippage","use_bitcoin_channel","inscription","quote_id","fee_rate"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"msg":{"type":"string"},"data":{"type":"object","properties":{"request_id":{"type":"string","title":"Request ID","description":"used for order submission"},"psbts":{"type":"array","items":{"type":"string"},"description":"PSBT to be signed"}},"required":["request_id","psbts"]},"req_id":{"type":"string"}},"required":["code","msg","data","req_id"]}}},"headers":{}}}}}}}
```

> 1、The `quote_id` in this interface is the return value obtained from the quotation interface.
>
> 2、Please set `use_bitcoin_channel` to `false` by default, and set `inscription` to an empty array `[]`.

{% hint style="info" %}
Note: The current interface returns a `psbts` array. If the `psbts` array contains more than 0 items, you need to use `signPsbts` for signing. Otherwise, use `signPsbt`.
{% endhint %}

## POST /dotswap/api/swap/submit\_psbt

> Aggregate and create a Swap order

```json
{"openapi":"3.0.1","info":{"title":"backend interface","version":"1.0.0"},"servers":[{"url":"https://api-testnet4.dotswap.app","description":"Swap test"},{"url":"https://api.dotswap.app","description":"Swap production"}],"security":[],"paths":{"/dotswap/api/swap/submit_psbt":{"post":{"summary":"Aggregate and create a Swap order","deprecated":false,"description":"","tags":[],"parameters":[{"name":"Authorization","in":"header","description":"","required":true,"schema":{"type":"string"}},{"name":"User-Id","in":"header","description":"","required":true,"schema":{"type":"string"}},{"name":"User-Agent","in":"header","description":"","required":true,"schema":{"type":"string"}},{"name":"Content-Type","in":"header","description":"","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"request_id":{"type":"string","title":"Request ID","description":"obtained from the PSBT creation"},"psbts":{"type":"array","items":{"type":"string"},"title":"Signed PSBT"},"psbt_is_base64":{"type":"boolean","title":"PSBT serialization type","description":"false:hex true:base64"}},"required":["psbts","request_id"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"msg":{"type":"string"},"data":{"type":"object","properties":{"order_id":{"type":"string"},"tx_id":{"type":"string"}},"required":["order_id","tx_id"]},"req_id":{"type":"string"}},"required":["code","msg","data","req_id"]}}},"headers":{}}}}}}}
```

> 1. The `request_id` is obtained from the `create_psbt` response.
> 2. Please set `psbt_is_base64` according to your signing result; by default, it is usually `false`.
