Skip to content

singlesly/bingx-api

Repository files navigation

Bingx API NodeJS Client

This library implements Bingx API for nodejs applications

CodeQL Release ESLint

Getting started

  • Install via npm
npm i bingx-api -S
  • Initialize Client
import { ApiAccount, BingxApiClient } from 'bingx-api';
const account = new ApiAccount('xxx', 'xxx');

const client = new BingxApiClient();
  • Make any requests from api to bingx
const userBalance = await client
                  .getAccountService()
                  .getPerpetualSwapAccountAssetInformation();
  • Works with sockets
const account = new ApiAccount('xxx', 'xxx');
stream = new BingxAccountSocketStream(account);

stream.heartbeat$.subscribe((v) => {})

stream.listenKeyExpired$.subscribe((v) => {})

stream.accountBalanceAndPositionPush$.subscribe((v) => {})

stream.accountOrderUpdatePushEvent$.subscribe((v) => {})
stream = new BingxMarketSocketStream(account);

stream.subscribe('BTC-USDT@trade');

stream.latestTradeDetail$.subscribe((v) => {})

Features supports

  • Account Interface
    • Get Perpetual Swap Account Asset Information
    • Perpetual Swap Positions
    • Get Account Profit and Loss Fund Flow
    • Export fund flow
    • User fee rate
  • Trade Interface
    • Trade order test
    • Trade order
    • Bulk order
    • One-Click Close All Positions
    • Cancel an Order
    • Cancel a Batch of Orders
    • Cancel All Orders
    • Query all current pending orders
    • Query Order
    • Query Margin Mode
    • Switch Margin Mode
    • Query Leverage
    • Switch Leverage
    • User's Force Orders
    • User's History Orders
    • Adjust isolated margin
    • Query historical transaction orders
  • Listen Key
    • Generate Listen Key
    • Extend Listen Key Validity period
    • Delete Listen Key
  • Socket API
    • Market Data
      • Subscribe Market Depth Data
      • Subscribe the Latest Trade Detail
      • Subscribe K-Line Data
    • Account Data
      • Listen Key expired push
      • Account balance and position update push
      • Order update push
      • Configuration updates such as leverage and margin mode