Skip to main content

Backpack API SDK tool

Project description

Downloads

Backpack SDK

This Backpack SDK is a continuously updated and supported Python toolkit that provides comprehensive access to all Backpack endpoints, including custom artificial endpoints for enhanced functionality. This SDK ensures developers have the most current tools for seamless integration with Backpack services.

Installation

bpx-py is stable on python >= 3.8

pip install bpx-py

Usage

Make an account and generate API keys on Backpack

Account example

from bpx.account import Account

public_key = "<KEY>"
secret_key = "<KEY>"
account = Account(public_key, 
        secret_key,
        window=6000, # default value is 5000
        proxy={"http":"132.142.132.12:3128"}) # you can use any requests proxy supported by requests
deposit_address_sol = account.get_deposit_address("Solana")
account_fills = account.get_fill_history_query("SOL_USDC", 
                                               limit=10,
                                               window=10000) # window only for this order
print(deposit_address_sol)
print(account_fills)

bpx-py supports async code:

from bpx.async_.account import Account
import asyncio

async def main():
    public_key = "<KEY>"
    secret_key = "<KEY>"
    account = Account(public_key, secret_key, proxy="http://your_proxy-address:1234")
    deposit_address_sol = await account.get_deposit_address("Solana")
    await asyncio.sleep(1)
    account_fills = await account.get_fill_history_query("SOL_USDC", 
                                               limit=10,
                                               window=10000)
    print(deposit_address_sol)
    print(account_fills)

asyncio.run(main())

Public

Backpack has public endpoints that don't need API keys:

from bpx.public import Public

public = Public() 
server_time = public.get_time()
markets = public.get_markets()
print(server_time)
print(markets)

Async code:

from bpx.async_.public import Public
import asyncio

async def main():
    public = Public()
    assets = await public.get_assets()
    await asyncio.sleep(1)
    klines = await public.get_klines("SOL_USDC", "1d")
    print(assets)
    print(klines)
    
asyncio.run(main())

Useful sources

Discord channel to get help

Backpack API DOCS

PYPI

Backpack help center

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bpx_py-1.1.5.tar.gz (12.4 kB view hashes)

Uploaded Source

Built Distribution

bpx_py-1.1.5-py3-none-any.whl (15.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page