THORChain Swap SDKs
Official client libraries for THORChain Swap (https://swap.thorchain.org). Two kinds, because there are two kinds of integration:
- Building swaps —
@tcswap/sdkon npm: quotes and routing across THORChain and Maya, wallet connection, and transaction building. It is the SDK this interface is itself built on. - Reading public data — the Python and Go clients here: thin, dependency-free wrappers over the canonical core MCP tools and this site's support endpoints. No credential of any kind.
TypeScript / JavaScript
- Package:
@tcswap/sdk(npm) — https://www.npmjs.com/package/@tcswap/sdk - Install:
npm install @tcswap/sdk - Source: https://github.com/thorchain/TCSwap/tree/main/packages/sdk
- Status: Published on npm. The full swap SDK — quotes and routing across THORChain and Maya, wallet connection, and transaction building — and the SDK this interface is itself built on.
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
- Package:
thorchain-swap(PyPI) - Install:
pip install "git+https://github.com/thorchain/swap.thorchain#subdirectory=sdk/python" - Source: https://github.com/thorchain/swap.thorchain/tree/main/sdk/python
- Status: Source published in this repository. Read-only quote, pool, and network-summary helpers call the canonical THORChain MCP server at https://mcp.thorchain.org/mcp; support requests use this site's REST API. No API key, token, or sign-in. Supports JSON and SSE responses. Install directly from git —
pip install "git+https://github.com/thorchain/swap.thorchain#subdirectory=sdk/python"— until the PyPI release is cut.
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:
github.com/thorchain/swap.thorchain/sdk/go(Go modules) - Install:
go get github.com/thorchain/swap.thorchain/sdk/go - Source: https://github.com/thorchain/swap.thorchain/tree/main/sdk/go
- Status: Source published in this repository and importable directly as a Go module. Read-only quote, pool, and network-summary helpers call the canonical THORChain MCP server at https://mcp.thorchain.org/mcp; support requests use this site's REST API. Supports JSON and SSE responses.
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