npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bpx-api-client

v0.1.2

Published

Backpack Exchange API Client Library for TypeScript

Downloads

122

Readme

BPX API Client

A TypeScript client library for the Backpack Exchange API, written by 0xprobe.

Changelog

[0.1.2] - 2025-07-15

  • Supports new API endpoints
  • Enhanced test code and added additional test cases for new endpoints
  • Updated bpxSigner to support array type body for executing multiple orders
  • Minor bug fixes and code refactoring

[0.1.1] - 2025-04-09

  • Added export for common.types

[0.1.0] - 2025-04-08

  • First official release of the project

Installation

npm install bpx-api-client

Quick Start

1. Initialize the client

import { BpxApiClient } from 'bpx-api-client';

// Initialize the client
const client = new BpxApiClient({
  apiKey: 'your-api-key',
  apiSecret: 'your-api-secret',
  debug: false // if true, prints debug information with console.log()
});

2. HTTP API

HTTP APIs are categorized according to the API specification and are called in the below format.

// Basic format
client.categoryName.endpointName(params);

// Example: executing an order
client.order.executeOrder(payload);

Here are some examples of HTTP API calls:

// Get market information
const marketsResponse = await client.markets.getMarket('SOL_USDC');
console.log(marketsResponse.data);

// Execute an order
const payload = {
  symbol: 'SOL_USDC',
  side: Side.Bid,
  orderType: OrderType.Limit,
  quantity: '0.07',
  price: '85',
  timeInForce: TimeInForce.GTC
};
const orderResponse = await client.order.executeOrder(payload);
console.log(orderResponse.data);

// Get account information
const accountResponse = await client.account.getAccount();
console.log(accountResponse.data);

All HTTP requests, responses, and parameters are defined as types within the library, enabling strict type checking. Type definitions strictly follow the official OpenAPI specification: blob:https://docs.backpack.exchange/bc5f44ac-fc90-480b-877f-df1bdb15c3a2

// Example with type annotations
const response: ApiResponse<Market> = await client.markets.getMarket('SOL_USDC');

const payload: OrderExecutePayload = {
  symbol: 'SOL_USDC',
  side: Side.Bid,
  orderType: OrderType.Limit,
  quantity: '0.07',
  price: '85',
  timeInForce: TimeInForce.GTC
};

const orderResponse: ApiResponse<OpenOrder> = await client.order.executeOrder(payload);

HTTP API Response Format

All HTTP API responses follow the ApiResponse interface:

export interface ApiResponse<T> {
  statusCode: number;                              // HTTP status code
  data: T | Record<string, never>;                 // Success : actual data, Failure : empty object
  error: ApiErrorResponse | Record<string, never>; // Success : empty object, Failure : error details
}

export interface ApiErrorResponse {
  code: string;
  message: string;
}

Success Response Example

{
  statusCode: 200,
  data: {
    baseSymbol: 'SOL',
    createdAt: '2025-01-21T06:34:54.691858',
    filters: { price: [Object], quantity: [Object] },
    fundingInterval: 28800000,
    imfFunction: null,
    marketType: 'SPOT',
    mmfFunction: null,
    openInterestLimit: '0',
    orderBookState: 'Open',
    quoteSymbol: 'USDC',
    symbol: 'SOL_USDC'
  },
  error: {}
}

Error Response Example

{
  statusCode: 400,
  data: {},
  error: { code: 'INVALID_CLIENT_REQUEST', message: 'Market not found' }
}

3. WebSocket API

// Open WebSocket connection
await client.streams.open();

// Add message handler (action when received message from server)
client.streams.addMessageHandler((message) => {
  console.log(JSON.stringify(message, null, 2));
});

// Subscribe to book ticker
client.streams.bookTicker(SubscriptionType.SUBSCRIBE, 'SOL_USDC');

// Subscribe to order updates
client.streams.orderUpdate(SubscriptionType.SUBSCRIBE, 'BTC_USDC');

// Close WebSocket connection
await client.streams.close();

4. Authentication

All authentication and signing processes are handled inside the BpxApiClient when using private endpoints. You only need to provide your apiKey and apiSecret when initializing the client.

Features

  • TypeScript Support: Complete type definitions for all API requests and responses
  • REST API Client: Access to all Backpack Exchange endpoints (public and private)
  • WebSocket Client: Real-time data streaming for market data and account updates
  • Authentication: Secure API key and secret handling
  • Error Handling: Comprehensive error handling with detailed error messages

API Documentation

HTTP API

The client provides access to all Backpack Exchange REST API endpoints:

  1. Public endpoints
  • assets
  • borrow lend markets
  • markets
  • system
  • trades
  1. Private endpoints
  • account
  • borrow lend
  • capital
  • futures
  • history
  • order
  • Request For Quote

WebSocket API

Real-time data streaming for:

  • Order update, Position update, RFQ update
  • Book ticker, Depth, K-line, Liquidation, Mark price, Ticker, Open interest, Trade