THORChain Swap SDKs

Official client libraries for THORChain Swap (https://swap.thorchain.org). Two kinds, because there are two kinds of integration:

TypeScript / JavaScript

import { USwapApi, createUSwap } from '@tcswap/sdk'

// Quotes and routes across every supported provider.
// Amounts here are decimal strings, not 1e8 base units.
const { routes } = await USwapApi.getSwapQuote({
  sellAsset: 'BTC.BTC',
  buyAsset: 'ETH.ETH',
  sellAmount: '0.1',
  destinationAddress: '0x...'
})

// Connect a wallet and sign locally; the SDK never holds keys for you.
const uswap = createUSwap()

Python

from thorchain_swap import ThorchainSwapClient

client = ThorchainSwapClient()

quote = client.get_swap_quote(
    from_asset="BTC.BTC",
    to_asset="ETH.ETH",
    amount="100000000",  # 1 BTC, in 1e8 base units
)

print(quote["expected_amount_out"])

Go

package main

import (
	"context"
	"fmt"

	thorchainswap "github.com/thorchain/swap.thorchain/sdk/go"
)

func main() {
	client := thorchainswap.NewClient()

	quote, err := client.GetSwapQuote(context.Background(), thorchainswap.SwapQuoteRequest{
		FromAsset: "BTC.BTC",
		ToAsset:   "ETH.ETH",
		Amount:    "100000000",
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(quote["expected_amount_out"])
}

Which one

@tcswap/sdk talks to the swap aggregator (https://api.thorchain.org/v1), which is x-api-key gated, and takes amounts as decimal strings. The Python and Go clients call the canonical core MCP endpoint for protocol data and this site for REST support endpoints. They need no key. Their quote helpers accept base-unit amount strings and convert them to the core MCP integer input. Helper method names remain stable, but pool and network payloads follow core schemas; see each SDK README for migration details. Pick the first to build a swap flow, the second to read quotes, pools, and network state.

None of them hold keys, sign transactions, or submit swaps on a user's behalf: the user always signs in their own wallet or sends funds themselves through the memoless flow.

Related

This page as markdown: /developers/sdks.md