Skip to content

splitnow/api-quickstart-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

api-quickstart-js

JavaScript API integration template for SplitNOW, the multi-wallet instant crypto exchange. 🐙🪼

  • 0 dependencies
  • Works on frontend: React, NextJS, SvelteKit, etc
  • Works on backend: Node, Bun, etc

Overview

This repository exports three functions that wrap around the SplitNOW API to help you get up and running with creating quotes & orders quickly, no matter your use case:

Helper Function 1: createAndFetchQuote()

async function createAndFetchQuote(
  SPLITNOW_API_KEY, // string
  fromAmount, // number
  fromAssetId, // string
  fromNetworkId, // string
  toAssetId, // string
  toNetworkId // string
) // returns Promise<object>

Helper Function 2: createAndFetchOrder()

async function createAndFetchOrder(
  SPLITNOW_API_KEY, // string
  quoteId, // string
  fromAmount, // number
  fromAssetId, // string
  fromNetworkId, // string
  walletDistributions, // object[]
) // returns Promise<object>

Helper Function 3: getOrderStatus()

async function getOrderStatus(
  SPLITNOW_API_KEY, // string
  orderId, // string
) // returns Promise<object>

Quickstart

1. Get your SplitNOW API Key

  1. Create a SplitNOW account at https://splitnow.io/auth/register
  2. Head to the API keys page on your account dashboard at https://splitnow.io/account/api-keys
  3. Copy your account's API key and store it in a safe place.

Note on 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!

Note on 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.

Note on restricted regions: Our API services are not available to users in the Restricted Regions, directly or indirectly, in accordance with our Terms of Service.

2. Clone this repository

git clone https://github.com/splitnow/api-quickstart-js
cd api-quickstart-js

3. Customizing your integration

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.

Integration Step 1/3: createAndFetchQuote() - Creating and fetching a quote

  • Suppose const quoteData = await createAndFetchQuote(/* your params here */)
  • You'll want to save quoteData.quoteId because you need this vaue to create your order in the next step.
  • You'll also probably want to do something such as filter through quoteData.rates to see which exchanges are available and at what rate
  • If the exchangeRate key of a rate object in the quoteData.rates array is 0, 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!

Integration Step 2/3: createAndFetchOrder() - Creating and fetching an order

  • Suppose const orderData = await createAndFetchOrder(/* your params here */) (remember to pass in the quote ID from the previous step)
  • The orderData object contains important information you'll need for initiating the order: orderData.depositAddress & orderData.depositAmount.
  • Once you've sent the deposit, we take care of everything else automatically! just make sure you send the right amount! and also save orderData.orderId so you can check the status later

Integration Step 3/3: getOrderStatus() - Fetching an order status

  • Suppose const orderStatus = await getOrderStatus(/* your params here */) (remember to pass in the order ID from the previous step)
  • Your 6-digit order ID is returned as orderStatus.orderId
  • You'll probably want to do something with orderStatus.orderStatus such 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.orderStatusText
  • Once orderStatus.orderStatus is completed, it's all done and the wallets are funded as requested! Enjoy!

Support

License

Unlicensed (Whitelabelled)

More information: https://unlicense.org

About

JavaScript template for SplitNOW API integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published