splitnow
v1.0.1
Published
TypeScript SDK (API wrapper) for SplitNOW, the multi-wallet instant crypto exchange. 🪼
Readme
SplitNOW TypeScript SDK
TypeScript SDK (API wrapper) for SplitNOW, the multi-wallet instant crypto exchange. 🪼
- 0 dependencies
- Works on frontend: React, NextJS, SvelteKit, etc
- Works on backend: Node, Deno, Bun, etc
Install
# Node.js
npm i splitnow
# Bun
bun i splitnowUsage Example
You'll need to create a SplitNOW API key if you don't have one already:
- Create a SplitNOW account at https://splitnow.io/auth/register
- Head to the API keys page on your account dashboard at https://splitnow.io/account/api-keys
- Copy your account's API key and store it in a safe place.
This example demonstrates splitting 10 SOL evenly across 2 wallets through Binance & Bybit:
// First, import the `SplitNOW` SDK into your file:
import { SplitNOW } from 'splitnow'
// Next, initialize the `SplitNOW` SDK with your API key:
const splitnow = new SplitNOW({
apiKey: 'replace_me', // Get a free API key at: https://splitnow.io/auth/register
})
// Step 1/3: Creating and fetching a quote
const quote = await splitnow.createAndFetchQuote({
fromAmount: 10,
fromAssetId: 'sol',
fromNetworkId: 'solana',
toAssetId: 'sol',
toNetworkId: 'solana',
})
const rates = quote.rates // (Optional) You can filter through this array to see which exchanges are available and at what rate
// Step 2/3: Creating and fetching an order
const order = await splitnow.createAndFetchOrder({
quoteId: quote.quoteId, // Quote ID from previous step
fromAmount: 10, // Amount to split
fromAssetId: 'sol', // Input asset ID
fromNetworkId: 'solana', // Input network ID
walletDistributions: [
{
toAddress: '7ingPqZUYmuso5HakTLgoXjMpETpbZYzxeQBJChGrQn5',
toPctBips: 5000,
toAssetId: 'sol',
toNetworkId: 'solana',
toExchangerId: 'binance',
},
{
toAddress: '92CzWZt7fD5ffhwkRNBKHxqHahVTPeWedd5UYmdmHjMw',
toPctBips: 5000,
toAssetId: 'sol',
toNetworkId: 'solana',
toExchangerId: 'bybit',
},
],
})
const depositAddress = order.depositAddress // The unique deposit address of the order
const depositAmount = order.depositAmount // The deposit amount to send to start the order
// Step 3/3: Fetching an order status
const orderStatus = await splitnow.getOrderStatus({
orderId: order.orderId, // Order ID from previous step
})Understanding The 3-Step Flow
To ensure a seamless SplitNOW API integration for your use case, you must first understand the 3-step flow when using the SplitNOW API.
Below is a short explainer of each step so that you can best fit each step into your own software & workflows.
Step 1/3: SplitNOW.createAndFetchQuote() - Creating and fetching a quote
const quote = await splitnow.createAndFetchQuote(/* your params */)- Save
quote.quoteIdbecause you need this value to create your order in the next step. - You'll also probably want to do something such as filter through
quote.ratesto see which exchanges are available and at what rate. - If the
exchangeRatekey of a rate object in thequote.ratesarray is0, the pair might not be supported on that exchange. - You can pick any exchange no matter what, though. Our systems fall back to the next best rate if your selection is unavailable!
Step 2/3: SplitNOW.createAndFetchOrder() - Creating and fetching an order
const order = await splitnow.createAndFetchOrder(/* your params */)- Remember to pass in the
quoteIdfrom the previous step! - The
orderobject contains important information you'll need for initiating the order:order.depositAddress&order.depositAmount. - Once you've sent the deposit, we take care of everything else automatically!
- Save
order.orderIdso you can check the status of your order anytime.
Step 3/3: SplitNOW.getOrderStatus() - Fetching an order status
const orderStatus = await splitnow.getOrderStatus(/* your params */)- Remember to pass in the
orderIdfrom the previous step! - Your 6-digit order ID is returned as
orderStatus.orderId. - You'll probably want to do something with
orderStatus.orderStatussuch as update your app's client or trigger a notification once the order status changes. - If you want a human-readable order status such as for your UI, use
orderStatus.orderStatusTextororderStatus.orderStatusShort. - Once
orderStatus.orderStatusiscompleted, it's all done and the wallets are funded as requested! Enjoy!
Full Reference
This TypeScript SDK includes 10 functions that wrap around the SplitNOW API to help you get up and running with creating quotes & orders quickly, no matter your use case:
getHealth
async getHealth(): Promise<boolean>- Checks whether the SplitNOW API is healthy.
- Returns: A
Promisethat resolves to aboolean.
API Reference: GET /health/
getAssets
async getAssets(): Promise<Asset[]>- Gets a list of available asset IDs and network IDs.
- Returns: A
Promisethat resolves to aAsset[]array.
💡 Pro Tip: When creating quotes & orders, the id key of each Asset can be used for fromAssetId & toAssetId.
💡 Pro Tip: When creating quotes & orders, the networkId key of a corresponding Asset can be used for fromNetworkId & toNetworkId.
API Reference: GET /assets/
getAssetPrices
async getAssetPrices(): Promise<object>- Gets the current USD price of each available asset by ID.
- Returns: A
Promisethat resolves to anobjectwhere each key is an asset ID (string) and each value is its price (number).
API Reference: GET /assets/prices/
getAssetDepositLimits
async getAssetDepositLimits(): Promise<AssetDepositLimit[]>- Gets the minimum and maximum deposit (if any) for each available asset.
- Returns: A
Promisethat resolves to aAssetDepositLimit[]array.
API Reference: GET /assets/limits/
getExchangers
async getExchangers(): Promise<Exchanger[]>- Get a list of available exchanger IDs.
- Returns: A
Promisethat resolves to aExchanger[]array.
💡 Pro Tip: When creating quotes & orders, the id key of each Exchanger can be used for toExchangerId.
API Reference: GET /exchangers/
createAndFetchQuote
async createAndFetchQuote({
fromAmount: number,
fromAssetId: string,
fromNetworkId: string,
toAssetId: string,
toNetworkId: string
}): Promise<QuoteData>- Creates and fetch a quote.
- Parameters:
fromAmount: A numerical amount of tokens to split.fromAssetId: The input asset ID returned fromgetAssets.fromNetworkId: A corresponding input network ID returned fromgetAssets.fromAssetId: The output asset ID returned fromgetAssets.fromNetworkId: A corresponding output network ID returned fromgetAssets.
- Returns: A
Promisethat resolves to aQuoteData.
API Reference: POST /quotes/, GET /quotes/{id}
createAndFetchOrder
async createAndFetchOrder({
quoteId: string,
fromAmount: number,
fromAssetId: string,
fromNetworkId: string,
walletDistributions: WalletDistribution[]
}): Promise<OrderData>- Creates and fetches an order.
- Parameters:
quoteId: A quote ID returned fromcreateAndFetchQuote.fromAmount: A numerical amount of tokens to split.fromAssetId: The input asset ID returned fromgetAssets.fromNetworkId: A corresponding input network ID returned fromgetAssets.walletDistributions:AWalletDistribution[]array containing recipient wallets and distribution preferences.
- Returns: A
Promisethat resolves to aOrderData.
API Reference: POST /orders/, GET /orders/{id}
getQuote
async getQuote({
quoteId: string
}): Promise<Quote>- Fetches a quote by its ID.
- Parameters:
quoteId: The quote ID to fetch.
- Returns: A
Promisethat resolves to aQuote.
API Reference: GET /quotes/{id}
getOrder
async getOrder({
orderId: string
}): Promise<Order>- Fetches an order by its ID.
- Parameters:
orderId: The order ID to fetch.
- Returns: A
Promisethat resolves to aOrder.
API Reference: GET /orders/{id}
getOrderStatus
async getOrderStatus({
orderId: string
}): Promise<OrderStatusData>- Fetches the status of an order by its ID.
- Parameters:
orderId: The order ID to fetch.
- Returns: A
Promisethat resolves to aOrderStatusData.
API Reference: GET /orders/{id}
Rate Limits
The default rate-limit of each API key is 60 requests per minute.
Don't hesitate to contact SplitNOW if you need more. We scale to meet any demand instantly!
Security
Never expose your SplitNOW API key to clients! If you think your API key may have been accidentally leaked, please contact support right away so that we can get you set up with a fresh one.
Compliance & Restricted Regions
Our API services are not available to users in the Restricted Regions, directly or indirectly, in accordance with our Terms of Service.
Support
- Official API docs: https://splitnow.io/api/docs
- Free 24/7 email support: [email protected]
- Free community support: SplitNOW API Developers Chat
License
Unlicensed (Whitelabelled)
More information: https://unlicense.org
© 2025 SplitOTC, Ltd.
