THORSwap SwapKit
Ask or search…
⌃K
Links
Comment on page

@swapkit/api

Simple SwapKit API wrapper with typings helpers to keep fetches organized

Installation

pnpm
yarn
npm
pnpm add @swapkit/api
yarn add @swapkit/api
npm add @swapkit/api

Usage

Methods are wrapped in simple SwapKitApi object. Any types referenced in methods table are exported from @swapkit/api package as well
import { SwapKitApi, type CachedPricesResponse } from '@swapkit/api'
​
const cachedPrices = await SwapKitApi.getCachedPrices({
tokens: [{ identifier: 'BTC.BTC' }]
});
​
// Typings can be taken from directly from package
const btcPrice: CachedPricesResponse[number] = cachedPrices.find(
({ identifier }) => identifier === 'BTC.BTC'
);

Methods

Method
Type References
getCachedPrices
({
tokens: { identifier: string }[];
metadata?: "true" | "false" | undefined;
lookup?: "true" | "false" | undefined;
sparkline?: "true" | "false" | undefined;
}) => Promise<CachedPricesResponse[]>
getQuote
({
affiliateBasisPoints?: string | undefined;
buyAsset: string;
recipientAddress?: string | undefined;
sellAmount: string;
sellAsset: string;
senderAddress?: string | undefined;
slippage: string;
}) => Promise<QuoteResponse>
getGasRates
() => Promise<GasRatesResponse>
getTxnDetails
(txHash: string) => Promise<TxnResponse>;
getTokenlistProviders
() => Promise<TokenlistProvidersResponse>;
getTokenList
(tokenlist: string) => Promise<TODO>;
getThornameAddresses
(address: string) => Promise<ThornameResponse>;
getThornameRegisteredChains
(address: string) => Promise<string[]>;
getThornameRlookup
(address: string, chain: string) => Promise<unknown>;
​