🧰Bitflow SDK

An overview of the Bitflow SDK, including installation, configuration, and usage in your project.

Bitflow SDK

Bitflow SDK is a powerful and easy-to-use library for interacting with the Bitflow Protocol. It provides a set of tools to seamlessly integrate Bitflow functionality into your applications.

All Bitflow API endpoints are publicly accessible without an API key. Unauthenticated requests are subject to a default rate limit of 500 requests per minute per IP.

If your integration requires higher limits, see the Rate Limit Request section to email [email protected] with a pre-filled form. You can also reach the team on Discordarrow-up-right.

Table of Contents

Installation

Install the Bitflow SDK using npm:

Usage

Here's a step-by-step guide to implement the Bitflow SDK in your project:

  1. Import the SDK:

  1. Initialize the SDK:

If no parameters are provided, the SDK will use the environment variables. See the Environment Variables section for more details.

  1. Use the SDK methods to interact with the Bitflow Protocol. See the Available Functions section for more details.

Environment Variables

If no options are provided when initializing the SDK, it will use the environment variables.

Create a .env file in your project root with the following variables:

Available Functions

Get Available Tokens

Retrieve a list of all available tokens:

Get Possible Swaps

Get all possible swap options for a given token:

Get All Possible Token Y

Retrieve all possible tokens that can be swapped for a given token:

Get All Possible Token Y Routes

Get all possible routes for swapping between two tokens:

Getting Quote for Route

Get the quotes for a swap between two tokens:

Getting Swap Parameters

Get the necessary parameters for signing a swap transaction:

Executing Swap (uses @stacks/connect)

This function uses the @stacks/connect library to execute a swap transaction:

Types

The SDK exports several TypeScript types that you can use in your application:

  • BitflowSDKConfig: Represents the configuration object for the Bitflow SDK.

  • Token: Represents a token with its properties.

  • SwapOptions: Represents possible swap options for a token.

  • PostConditionType: Represents the type of a post-condition used in transactions.

  • SelectedSwapRoute: Represents a selected swap route with its details.

  • RouteQuote: Represents the quote for a swap route.

  • QuoteResult: Represents the result of a quote request, including the best RouteQuote and all possible routes.

  • SwapExecutionData: Represents the data needed to execute a swap.

  • SwapDataParamsAndPostConditions: Represents the parameters and post-conditions needed to execute/sign a swap transaction.

Troubleshooting

If you encounter any issues while using the Bitflow SDK, please check the following:

  1. Ensure all environment variables are correctly set in your .env file.

  2. Make sure you have the latest version of the SDK installed.

  3. Check that you're using a valid Stacks address for the senderAddress parameter.

Rate Limit Request

If your integration needs more than 500 requests per minute per IP, click the link below to open a pre-filled email in your mail client:

Request higher rate limitsenvelope

If the link doesn't open your mail client, email [email protected] with the subject API Rate Limit Increase Request and include the following:

  • Project / Application name β€” e.g. MyDeFi App

  • Brief description β€” What your app does and how it uses the Bitflow API

  • Website / repo (if public) β€” URL or N/A

  • APIs you need higher limits for β€” Core API, Keeper API, Stacks Node (or all)

  • Expected request volume β€” e.g. ~2,000 requests/minute during peak hours

  • Use case β€” e.g. Server-side data aggregation, real-time price feeds for N users

  • Contact name

  • Discord handle (optional)

We aim to respond within 2 business days. For urgent requests, reach out on Discordarrow-up-right.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Last updated