UNPKG

sideshift-node-sdk

Version:

TypeScript Client for SideShift.ai API

46 lines (45 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PairsAPI = void 0; class PairsAPI { constructor(sideShiftHttpHandler) { this.sideShiftHttpHandler = sideShiftHttpHandler; } /** * Returns the minimum and maximum deposit amount and the rate for a pair of coins. * @see https://docs.sideshift.ai/endpoints/v2/pair * * From and to can be coin-network or if network is omitted, it will default to the mainnet. * * @param from - The coin-network to shift from. (e.g., 'btc-mainnet' or 'btc') * @param to - The coin-network to shift to. * @param amount - Without specifying an amount, the system will assume a deposit value of 500 USD. * @returns */ async getPair(from, to, amount) { return this.sideShiftHttpHandler.execute('GET', `/pair/${from}/${to}`, amount ? { amount } : {}, { auth: true, affiliateId: true, }); } /** * Returns the minimum and maximum deposit amount and the rate for every possible pair of coins * listed in the query string. * @see https://docs.sideshift.ai/endpoints/v2/pairs * * @param pairs - Each coin should be in the format 'coin-network' (e.g., [btc-mainnet,usdc-bsc,bch,eth]). * @returns Promise<ApiResponse<Pair[]>> */ async getPairs(coins) { if (!coins || coins.length === 0) { throw new Error('Coins cannot be empty. Please provide at least one coin.'); } return this.sideShiftHttpHandler.execute('GET', '/pairs', { pairs: coins.join(','), }, { auth: true, affiliateId: true, }); } } exports.PairsAPI = PairsAPI;