Backpack Exchange SDK
English | 简体中文 | 繁體中文 | 日本語 | 한국어 | Español | Português
A complete Python SDK for the Backpack Exchange API. Supports all 70 API endpoints including REST and WebSocket.
Project Docs
Features
- Authentication Client: Full access to authenticated endpoints (orders, capital, history, RFQ, strategies)
- Public Client: Access public market data, system status, and trade data
- WebSocket Client: Real-time streaming for market data and account updates
- Complete Coverage: All 70 API endpoints implemented
- Type Hints: Full type annotations for better IDE support
- Enums: Comprehensive enums for type-safe API calls
Installation
pip install backpack-exchange-sdk
Or install from source:
git clone https://github.com/solomeowl/backpack_exchange_sdk.git
cd backpack_exchange_sdk
pip install .
Quick Start
Public Client
from backpack_exchange_sdk import PublicClient
client = PublicClient()
# Get all markets
markets = client.get_markets()
# Get ticker
ticker = client.get_ticker("SOL_USDC")
# Get order book depth
depth = client.get_depth("SOL_USDC")
Authentication Client
from backpack_exchange_sdk import AuthenticationClient
client = AuthenticationClient("<API_KEY>", "<SECRET_KEY>")
# Get account balances
balances = client.get_balances()
# Place an order
order = client.execute_order(
orderType="Limit",
side="Bid",
symbol="SOL_USDC",
price="100",
quantity="1"
)
# Get order history
history = client.get_order_history(symbol="SOL_USDC")
Using Enums
from backpack_exchange_sdk import AuthenticationClient
from backpack_exchange_sdk.enums import OrderType, Side, TimeInForce
client = AuthenticationClient("<API_KEY>", "<SECRET_KEY>")
order = client.execute_order(
orderType=OrderType.LIMIT.value,
side=Side.BID.value,
symbol="SOL_USDC",
price="100",
quantity="1",
timeInForce=TimeInForce.GTC.value
)
API Reference
Public Client Methods
| Category | Method | Description |
|---|---|---|
| System | get_status() |
Get system status |
send_ping() |
Ping the server | |
get_system_time() |
Get server time | |
get_wallets() |
Get supported wallets | |
| Assets | get_assets() |
Get all assets |
get_collateral() |
Get collateral info | |
| Markets | get_markets() |
Get all markets |
get_market(symbol) |
Get specific market | |
get_ticker(symbol) |
Get ticker | |
get_tickers() |
Get all tickers | |
get_depth(symbol) |
Get order book | |
get_klines(symbol, interval, startTime) |
Get candlesticks | |
get_mark_price(symbol) |
Get mark price | |
get_open_interest(symbol) |
Get open interest | |
get_funding_interval_rates(symbol) |
Get funding rates | |
| Trades | get_recent_trades(symbol) |
Get recent trades |
get_historical_trades(symbol, limit, offset) |
Get trade history | |
| Borrow/Lend | get_borrow_lend_markets() |
Get lending markets |
get_borrow_lend_market_history(interval) |
Get lending history | |
| Prediction | get_prediction_markets() |
Get prediction markets |
get_prediction_tags() |
Get prediction tags |
Authentication Client Methods
| Category | Method | Description |
|---|---|---|
| Account | get_account() |
Get account settings |
update_account(...) |
Update account settings | |
get_max_borrow_quantity(symbol) |
Get max borrow amount | |
get_max_order_quantity(symbol, side) |
Get max order size | |
get_max_withdrawal_quantity(symbol) |
Get max withdrawal | |
| Capital | get_balances() |
Get balances |
get_collateral() |
Get collateral | |
get_deposits() |
Get deposit history | |
get_deposit_address(blockchain) |
Get deposit address | |
get_withdrawals() |
Get withdrawal history | |
request_withdrawal(...) |
Request withdrawal | |
convert_dust(symbol) |
Convert dust to USDC | |
get_withdrawal_delay() |
Get withdrawal delay | |
create_withdrawal_delay(hours, token) |
Create withdrawal delay | |
update_withdrawal_delay(hours, token) |
Update withdrawal delay | |
| Orders | execute_order(...) |
Place single order |
execute_batch_orders(orders) |
Place batch orders | |
get_users_open_orders(symbol) |
Get user's open orders | |
get_open_orders(symbol) |
Get open orders | |
cancel_open_order(symbol, orderId) |
Cancel single order | |
cancel_open_orders(symbol) |
Cancel all orders | |
| History | get_order_history(symbol) |
Get order history |
get_fill_history(symbol) |
Get fill history | |
get_borrow_history() |
Get borrow history | |
get_interest_history() |
Get interest history | |
get_borrow_position_history() |
Get borrow positions | |
get_funding_payments() |
Get funding payments | |
get_settlement_history() |
Get settlements | |
get_dust_history() |
Get dust conversions | |
get_position_history() |
Get position history | |
get_strategy_history() |
Get strategy history | |
get_rfq_history() |
Get RFQ history | |
get_quote_history() |
Get quote history | |
get_rfq_fill_history() |
Get RFQ fills | |
get_quote_fill_history() |
Get quote fills | |
| Borrow/Lend | get_borrow_lend_positions() |
Get positions |
execute_borrow_lend(quantity, side, symbol) |
Borrow or lend | |
get_estimated_liquidation_price(borrow) |
Get liquidation price | |
| Positions | get_open_positions() |
Get open positions |
| RFQ | submit_rfq(symbol, side, quantity) |
Submit RFQ |
submit_quote(rfqId, price) |
Submit quote | |
accept_quote(rfqId, quoteId) |
Accept quote | |
refresh_rfq(rfqId) |
Refresh RFQ | |
cancel_rfq(rfqId) |
Cancel RFQ | |
| Strategy | create_strategy(...) |
Create strategy |
get_strategy(symbol, strategyId) |
Get strategy | |
get_open_strategies() |
Get open strategies | |
cancel_strategy(symbol, strategyId) |
Cancel strategy | |
cancel_all_strategies(symbol) |
Cancel all strategies |
WebSocket Client
from backpack_exchange_sdk import WebSocketClient
# Public streams (no auth required)
ws = WebSocketClient()
# Private streams (auth required)
ws = WebSocketClient(api_key="<API_KEY>", secret_key="<SECRET_KEY>")
# Subscribe to streams
def on_message(data):
print(data)
ws.subscribe(
streams=["bookTicker.SOL_USDC"],
callback=on_message
)
# Private stream example
ws.subscribe(
streams=["account.orderUpdate"],
callback=on_message,
is_private=True
)
Available Enums
from backpack_exchange_sdk.enums import (
# Order related
OrderType, # Limit, Market
Side, # Bid, Ask
TimeInForce, # GTC, IOC, FOK
SelfTradePrevention,
TriggerBy,
# Market related
MarketType, # Spot, Perp
FillType,
KlineInterval,
# Status related
OrderStatus,
DepositStatus,
WithdrawalStatus,
# And more...
)
Examples
See the examples directory for complete usage examples:
example_public.py- Public API examplesexample_authenticated.py- Authenticated API examplesexample_websocket.py- WebSocket streaming examples
Documentation
For detailed API documentation, visit the Backpack Exchange API Docs.
Changelog
v1.1.0
- Added 21 new API endpoints (RFQ, Strategy, Prediction Markets, etc.)
- Added 25+ new enum types
- Refactored SDK architecture using mixins
- 100% API coverage (70 endpoints)
- Full type hints support
v1.0.x
- Initial release with basic API support
Support
If this SDK has been helpful, please consider:
- Using my referral link to register: Register on Backpack Exchange
- Giving this repo a star on GitHub
License
MIT License
Metadata
Release files for backpack-exchange-sdk 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| backpack_exchange_sdk-1.1.4.tar.gz | 36.0 kB | Without provenance | Details for backpack_exchange_sdk-1.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| backpack_exchange_sdk-1.1.4-py3-none-any.whl | Python 3 | none | any | Details for backpack_exchange_sdk-1.1.4-py3-none-any.whl |
Total release size: 79.8 kB
Release files / backpack_exchange_sdk-1.1.4.tar.gz
| Download URL | backpack_exchange_sdk-1.1.4.tar.gz |
|---|---|
| Size | 36.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a848630afec1d50b0f51b7f66d7f06a799b3d962ee2295adfc1bc125f48cb8f3
|
|
BLAKE2b-256 checksum How to use checksums |
d5dbd3f29ecd4d15dc27db503a68874888390a4bde9d181708a347cd69a54eaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / backpack_exchange_sdk-1.1.4-py3-none-any.whl
| Download URL | backpack_exchange_sdk-1.1.4-py3-none-any.whl |
|---|---|
| Size | 43.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb2f9dd9ea4709e7333b66f58ad1ac7bc9c13aa65e6f7c707d911f58cf5abac2
|
|
BLAKE2b-256 checksum How to use checksums |
be1c865b095e5326bc891818a8f9a40e72d8c1c8284a8cf92248b01d6b64b789
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for backpack-exchange-sdk 1.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.