Code Monkey home page Code Monkey logo

bitbnspy's Introduction

Bitbns Python API

This project is designed to assist you make your own projects that interact with the Bitbns API. This project seeks to have complete API coverage and WebSockets.

Use Python 3.7+

Installation

pip3 install bitbnspy

Getting Started

Now we support public and private endpoints. One does not have to provide API Keys in case they just want to use our public endpoints.
In case one wants to use both public and private endpoints, they can do so by following the instatiation method for private endpoints.

Instantiation for Public Endpoints

from bitbnspy import bitbns
bitbnsObj = bitbns.publicEndpoints()
print(bitbnsObj.fetchTickers())

Instantiation for Private Endpoints

from bitbnspy import bitbns
key = 'yourKey'
secretKey = 'yourSecretKey'
bitbnsObj = bitbns(key, secretKey)
print(bitbnsObj.getSellOrderBook('XRPUSDT'))

API Access

PERMISSIONS Read Write
List Open Orders
List Open Stop Limit
Api Usages Status
Current Coin Balance
Deposit History
Withdrawal History
Order Status
Buy Stop Loss Order
Sell Stop Loss Order
Buy Order
Sell Order
Get Coin Address
Cancel Order
Cancel Stop Loss Order
Platform Status
Ticker API
Buy OrderBook
Sell OrderBook

Minimum Volume supported by exchange

Minimum volume amount per order:

  • USDT market = 0.1 USDT
  • INR market = 10 INR

Public Endpoints

Getting details of tickers

bitbnsObj.fetchTickers()
View Response
{
 data: {
    'BTC': {
       'highest_buy_bid': 3804776.47, 
       'lowest_sell_bid': 3809634.1, 
       'last_traded_price': 3809634.1, 
       'yes_price': 3817924.68, 
       'volume': {
           'max': '3860000.00', 
           'min': '3728401.38', 
           'volume': 29.22102567
          }
       }, 
    'XRP': {
    .
    .
    .
    }
  },
 'error': None, 
 'status': 1,
}


Explanation of fields: status -> 1 if data is returned successfully error -> describes the error faced while retrieving data if any

Getting order book

Depth of the order book can be specified. Default depth is 20.
bitbnsObj.fetchOrderBook('BTC', 'INR', depth = 10)
View Response
{
 'data': {
    'asks': [
             [3839997.47, 0.14315922],
             [3840000, 0.00104478],
             .
             .
          ]
    'bids': [
             [3836673.24, 0.0002062],
             [3836673.23, 0.23805619],
             .
             .
          ]
    'timestamp': 1630664703000
    },
 'error': None,
 'status': 1
}


Explanation of fields: status -> 1 if data is returned successfully error -> describes the error faced while retrieving data if any timestamp -> The timestamp when screenshot of order book was taken

Getting recent trades

Limit (nos of trades to be returned) can also be specified. Default limit is 100
bitbnsObj.fetchTrades('BTC', 'INR', limit = 10)
View Response
{
 'data': [
          {
             'base_volume': 0.00106565,
             'price': '3837783.20',
             'quote_volume': 4099.96,
             'timestamp': 1630664966000,
             'tradeId': '2468049',
             'type': 'buy'
          },
          {
             .
             .
             .
          }
        ],
 'error': None,
 'status': 1
}


Explanation of fields: status -> 1 if data is returned successfully error -> describes the error faced while retrieving data if any

fetch OHLCV data

This endpoint is paginated. Increase page no., to get older data.
bitbnsObj.fetchOHLCV('BTC', 'INR', page = 1)
View Response
{
  'data':[
    {
      'close': 3727748.31,
      'high': 3727748.31,
      'low': 3724656.82,
      'open': 3727748.31,
      'timestamp': '2021-09-01T11:25:04.000Z',
      'vol': 1.07505351
    },
    {
      'close': 3727748.31,
      'high': 3749981.02,
      'low': 3720000,
      'open': 3720000,
      'timestamp': '2021-09-01T11:20:04.000Z',
      'vol': 0.04898758
    },
    .
    .
    .
  ]
  'error': None,
  'status': 1
}


Explanation of fields: status -> 1 if data is returned successfully error -> describes the error faced while retrieving data if any

Private Endpoints

Getting Platform Status

bitbnsObj.platformStatus();
View Response
    {
  data: {
    BTC: {
      status: 1
    },
    ETH: {
      status: 1
    },
    XRP: {
      status: 1
    }
  },
  status: 1,
  error: null
}

Explanation of fields: status -> whether the coin is live on platform

Getting latest price of a symbol

Inputting Invalid crypto name would return "undefined" as the price.
bitbnsObj.getTickerApi('BTC')
View Response
    {
  "data": {
    "BTC": {
      "highest_buy_bid": 484159.43,
      "lowest_sell_bid": 494800,
      "last_traded_price": 494805.29
    }
  },
  "status": 1,
  "error": null
}

Explanation of fields: highest_buy_bid -> top entry of buy order book lowest_sell_bid -> top entry of sell order book last_traded_price -> price at which the last trade had happened

Getting latest price of few symbols

bitbnsObj.getTickerApi('BTC,ETH')
View Response
    {
  "data": {
    "BTC": {
      "highest_buy_bid": 484159.43,
      "lowest_sell_bid": 494800,
      "last_traded_price": 494805.29
    },
    "ETH": {
      "highest_buy_bid": 13205.01,
      "lowest_sell_bid": 13440,
      "last_traded_price": 13450
    }
  },
  "status": 1,
  "error": null
}

Explanation of fields: highest_buy_bid -> top entry of buy order book lowest_sell_bid -> top entry of sell order book last_traded_price -> price at which the last trade had happened

Getting latest price of all symbols

bitbnsObj.getTickerApi('')
View Response
  {
  "data": {
    "BTC": {
      "highest_buy_bid": 480059.8,
      "lowest_sell_bid": 489000,
      "last_traded_price": 480059.8
    },
    "XRP": {
      "highest_buy_bid": 20,
      "lowest_sell_bid": 20.16,
      "last_traded_price": 20.16
    },
    "NEO": {
      "highest_buy_bid": 1301,
      "lowest_sell_bid": 1349.99,
      "last_traded_price": 1331.92
    },
    "GAS": {
      "highest_buy_bid": 406.96,
      "lowest_sell_bid": 418.46,
      "last_traded_price": 418.46
    },
    "ETH": {
      "highest_buy_bid": 13350,
      "lowest_sell_bid": 13660.5,
      "last_traded_price": 13350
    },
    "XLM": {
      "highest_buy_bid": 14.75,
      "lowest_sell_bid": 14.77,
      "last_traded_price": 14.77
    },
    "RPX": {
      "highest_buy_bid": 0.77,
      "lowest_sell_bid": 0.82,
      "last_traded_price": 0.8
    },
    "DBC": {
      "highest_buy_bid": 0.73,
      "lowest_sell_bid": 0.77,
      "last_traded_price": 0.72
    },
    "LTC": {
      "highest_buy_bid": 3680,
      "lowest_sell_bid": 3800,
      "last_traded_price": 3800
    },
    "XMR": {
      "highest_buy_bid": 7555,
      "lowest_sell_bid": 8000,
      "last_traded_price": 7600
    },
    "DASH": {
      "highest_buy_bid": 13500,
      "lowest_sell_bid": 14500,
      "last_traded_price": 13500
    },
    "DOGE": {
      "highest_buy_bid": 0.47,
      "lowest_sell_bid": 0.49,
      "last_traded_price": 0.49
    },
    "BCH": {
      "highest_buy_bid": 33600,
      "lowest_sell_bid": 34997,
      "last_traded_price": 34998
    },
    "SC": {
      "highest_buy_bid": 0.38,
      "lowest_sell_bid": 0.42,
      "last_traded_price": 0.42
    },
    "TRX": {
      "highest_buy_bid": 1.35,
      "lowest_sell_bid": 1.36,
      "last_traded_price": 1.35
    },
    "ETN": {
      "highest_buy_bid": 0.38,
      "lowest_sell_bid": 0.39,
      "last_traded_price": 0.39
    },
    "ONT": {
      "highest_buy_bid": 126.01,
      "lowest_sell_bid": 136.1,
      "last_traded_price": 136.82
    },
    "ZIL": {
      "highest_buy_bid": 2.37,
      "lowest_sell_bid": 2.5,
      "last_traded_price": 2.51
    },
    "EOS": {
      "highest_buy_bid": 365.51,
      "lowest_sell_bid": 375.1,
      "last_traded_price": 385
    },
    "POLY": {
      "highest_buy_bid": 10.01,
      "lowest_sell_bid": 10.04,
      "last_traded_price": 10.04
    },
    "DGB": {
      "highest_buy_bid": 1.6,
      "lowest_sell_bid": 1.83,
      "last_traded_price": 1.82
    },
    "NCASH": {
      "highest_buy_bid": 0.35,
      "lowest_sell_bid": 0.36,
      "last_traded_price": 0.36
    },
    "ADA": {
      "highest_buy_bid": 4.97,
      "lowest_sell_bid": 5.09,
      "last_traded_price": 4.92
    },
    "ICX": {
      "highest_buy_bid": 40.01,
      "lowest_sell_bid": 45.5,
      "last_traded_price": 40.25
    },
    "VEN": {
      "highest_buy_bid": 0.96,
      "lowest_sell_bid": 1.15,
      "last_traded_price": 1.15
    },
    "OMG": {
      "highest_buy_bid": 239.72,
      "lowest_sell_bid": 267.71,
      "last_traded_price": 267.71
    },
    "REQ": {
      "highest_buy_bid": 2.22,
      "lowest_sell_bid": 2.39,
      "last_traded_price": 2.3
    },
    "DGD": {
      "highest_buy_bid": 2385,
      "lowest_sell_bid": 3000,
      "last_traded_price": 2385
    },
    "QLC": {
      "highest_buy_bid": 3.3,
      "lowest_sell_bid": 3.96,
      "last_traded_price": 3.4
    },
    "POWR": {
      "highest_buy_bid": 10.02,
      "lowest_sell_bid": 11.4,
      "last_traded_price": 10.01
    },
    "WPR": {
      "highest_buy_bid": 1.18,
      "lowest_sell_bid": 1.25,
      "last_traded_price": 1.17
    },
    "WAVES": {
      "highest_buy_bid": 150.1,
      "lowest_sell_bid": 179,
      "last_traded_price": 150
    },
    "WAN": {
      "highest_buy_bid": 58.51,
      "lowest_sell_bid": 69.9,
      "last_traded_price": 53.55
    },
    "ACT": {
      "highest_buy_bid": 2.21,
      "lowest_sell_bid": 2.68,
      "last_traded_price": 2.21
    },
    "XEM": {
      "highest_buy_bid": 5.7,
      "lowest_sell_bid": 7.51,
      "last_traded_price": 10
    },
    "XVG": {
      "highest_buy_bid": 0.89,
      "lowest_sell_bid": 0.92,
      "last_traded_price": 0.88
    },
    "BLZ": {
      "highest_buy_bid": 7.61,
      "lowest_sell_bid": 7.8,
      "last_traded_price": 7.8
    },
    "SUB": {
      "highest_buy_bid": 7.06,
      "lowest_sell_bid": 8.5,
      "last_traded_price": 7.45
    },
    "LRC": {
      "highest_buy_bid": 6.5,
      "lowest_sell_bid": 9.95,
      "last_traded_price": 6.7
    },
    "NEXO": {
      "highest_buy_bid": 3.91,
      "lowest_sell_bid": 4.19,
      "last_traded_price": 3.91
    },
    "EFX": {
      "highest_buy_bid": 0.69,
      "lowest_sell_bid": 0.9,
      "last_traded_price": 0.7
    },
    "CPX": {
      "highest_buy_bid": 1.05,
      "lowest_sell_bid": 1.27,
      "last_traded_price": 1.05
    },
    "ZRX": {
      "highest_buy_bid": 38.09,
      "lowest_sell_bid": 39.49,
      "last_traded_price": 37.77
    },
    "REP": {
      "highest_buy_bid": 1050,
      "lowest_sell_bid": 1200,
      "last_traded_price": 1025
    },
    "LOOM": {
      "highest_buy_bid": 5.06,
      "lowest_sell_bid": 6.7,
      "last_traded_price": 6.7
    },
    "EOSD": {
      "highest_buy_bid": 3.51,
      "lowest_sell_bid": 3.88,
      "last_traded_price": 3.51
    },
    "STORM": {
      "highest_buy_bid": 0.47,
      "lowest_sell_bid": 0.5,
      "last_traded_price": 0.48
    },
    "GNT": {
      "highest_buy_bid": 9.25,
      "lowest_sell_bid": 9.26,
      "last_traded_price": 9.26
    },
    "QTUM": {
      "highest_buy_bid": 235,
      "lowest_sell_bid": 288.97,
      "last_traded_price": 247.69
    },
    "QKC": {
      "highest_buy_bid": 1.86,
      "lowest_sell_bid": 2.34,
      "last_traded_price": 1.76
    },
    "LSK": {
      "highest_buy_bid": 230,
      "lowest_sell_bid": 286,
      "last_traded_price": 230
    },
    "NPXS": {
      "highest_buy_bid": 0.11,
      "lowest_sell_bid": 0.12,
      "last_traded_price": 0.11
    },
    "USDT": {
      "highest_buy_bid": 74.12,
      "lowest_sell_bid": 77,
      "last_traded_price": 74.11
    },
    "ETC": {
      "highest_buy_bid": 804.02,
      "lowest_sell_bid": 850,
      "last_traded_price": 804
    },
    "DENT": {
      "highest_buy_bid": 0.15,
      "lowest_sell_bid": 0.17,
      "last_traded_price": 0.17
    },
    "CLOAK": {
      "highest_buy_bid": 120.51,
      "lowest_sell_bid": 159.92,
      "last_traded_price": 135
    },
    "KMD": {
      "highest_buy_bid": 70,
      "lowest_sell_bid": 77,
      "last_traded_price": 77.6
    },
    "GRS": {
      "highest_buy_bid": 35,
      "lowest_sell_bid": 39.4,
      "last_traded_price": 38.4
    },
    "RAM": {
      "highest_buy_bid": 0.38,
      "lowest_sell_bid": 0.4,
      "last_traded_price": 0.38
    },
    "LET": {
      "highest_buy_bid": 0.64,
      "lowest_sell_bid": 0.68,
      "last_traded_price": 0.68
    },
    "SOUL": {
      "highest_buy_bid": 2.26,
      "lowest_sell_bid": 2.71,
      "last_traded_price": 2.7
    },
    "PHX": {
      "highest_buy_bid": 0.77,
      "lowest_sell_bid": 0.82,
      "last_traded_price": 0.8
    },
    "VET": {
      "highest_buy_bid": 0.96,
      "lowest_sell_bid": 1.15,
      "last_traded_price": 1.15
    },
    "TST": {
      "highest_buy_bid": 23,
      "lowest_sell_bid": 27.5,
      "last_traded_price": 25
    }
  },
  "status": 1,
  "error": null
}

Getting current balance of crypto asset

Inputing "INR" in place of crypto asset would list your inr balance .
bitbnsObj.currentCoinBalance('BTC')
View Response
    {
  "data": {
    "inorderBTC": 8.34,
    "availableorderBTC": 15.76
  },
  "status": 1,
  "error": null
}

Explanation of fields: inorderBTC -> volume which is the order book availableorderBTC -> volume which is present in wallet

Get Deposit History

bitbnsObj.depositHistory('BTC', 0)
View Response
 {
  data: [
    {
      type: 'BTC deposited',
      typeI: 1,
      amount: 0.00159302,
      date: '2018-08-21T14:35:02.000Z',
      unit: 'BTC',
      factor: 100000000,
      fee: 0,
      delh_btc: 0,
      delh_inr: 0,
      rate: 0,
      del_btc: 159302,
      del_inr: 0
    },
    {
      type: 'BTC deposited',
      typeI: 1,
      amount: 0.00142951,
      date: '2018-08-21T14:35:02.000Z',
      unit: 'BTC',
      factor: 100000000,
      fee: 0,
      delh_btc: 0,
      delh_inr: 0,
      rate: 0,
      del_btc: 142951,
      del_inr: 0
    }
  ],
  status: 1,
  error: null
}

Explanation of fields: type -> type of action typeI -> action id amount -> the amount deposited date -> the time at which this event occured unit -> the symbol name of coin factor -> the division factor del_btc -> delta changes in normal wallet of coin del_inr -> delta changes in normal inr wallet delh_btc -> delta changes in hold wallet of coin

Get Withdrawal History

bitbnsObj.withdrawHistory('XRP', 0)
View Response
{
  data: [
    {
      type: 0,
      amount: 1.1,
      unit: 'XRP',
      hash: '42DAD88011C178DCAA1587ABA4458F4D535B30248650A6C353E5E2527',
      fee: 0.1,
      to: 'rB1za2ZVgqvrNB7u8LbVN61k5n1ByBUtXCA',
      status: '-1',
      canSendMail: 0,
      cancelable: -1,
      refer: 5339918,
      expTime: 'XRP withdraw done'
    },
    {
      type: 0,
      amount: 100,
      unit: 'XRP',
      hash: '12520219872260A25457E4D03C8F82F696A23EEA558B693B90FF080C5',
      fee: 0.1,
      to: 'rLdBnLq5C13ood9wdjY9ZCdgycK8KGevkUj',
      status: '-1',
      canSendMail: 0,
      cancelable: -1,
      refer: 6531933,
      expTime: 'XRP withdraw done'
    }
  ],
  status: 1,
  error: null
}
  

List Open Orders

bitbnsObj.listOpenOrders('BTC')
View Response
    {
  "data": [
    {
      "entry_id": 322,
      "btc": 48,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 323,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 324,
      "btc": 100,
      "r ate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 325,
      "btc": 100,
      "rate": 25,
      "time": "2018-0 9-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 326,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "t ype": 1,
      "status": 0
    },
    {
      "entry_id": 327,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "e ntry_id": 328,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 329,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 330,
      "btc": 100,
      "rate": 25,
      "time": "201 8-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 331,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 332,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 333,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 334,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:29:52.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 337,
      "btc": 100,
      "rate": 25,
      "time": " 2018-09-10T12:45:51.000Z",
      "type": 1,
      "status": 0
    },
    {
      "entry_id": 338,
      "btc": 100,
      "rate": 25,
      "time": "2018-09-10T12:46:01.00 0Z",
      "type": 1,
      "status": 0
    }
  ],
  "status": 1,
  "error": null
}

Explanation of fields: entry_id -> the unique id assigned to the order btc -> the volume of the coin rate -> the rate at which the order was placed time -> the timestamp at which the order was placed type -> 1 for sell and 0 for buy order status -> -1 for cancelled , 0 for not processed , 1 for partially executed, 2 for fully executed

List Open Stop Loss Orders

bitbnsObj.listOpenStopOrders('TST')
View Response
    {
  data: [
    {
      entry_id: 28816,
      btc: 40,
      rate: 25,
      t_rate: 24.5,
      type: 1,
      status: 0
    }
  ],
  status: 1,
  error: null
}

Explanation of fields: entry_id -> the unique id assigned to the order btc -> the volume of the coin rate -> the rate at which the order was placed t_rate -> the trigger rate at which the order was placed time -> the timestamp at which the order was placed type -> 1 for sell and 0 for buy order status -> -1 for cancelled , 0 for not processed , 1 for partially executed, 2 for fully executed

Get Specify Crypto Coin Address

Coins Without Tag
bitbnsObj.getCoinAddress('BTC')
View Response
{
  "data": {
    "token": "3QkuWRDRNcjtMQNneoqFV7hpxQPWW6pupK",
    "expiry": "2018-09-12 13:04:09"
  },
  "status": 1,
  "error": null
}

Explanation of fields: token -> the token address expiry -> the time till which this address is user's valid address

Coins With Tag
bitbnsObj.getCoinAddress('XLM')
View Response
{
  "data": {
    "token": "GAVQNY45FBHSN5MEPLAF56U7VDCBDG54TQFGJSS2CRPZTWD3CSHP4YPU",
    "tag": "123151"
  },
  "status": 1,
  "error": null
}

Explanation of fields: token -> the token address tag -> the tag to be used for the token Deposits would not be valid unless you specify the tag

Place Sell Order

bitbnsObj.placeSellOrder('XRP', 200, 25)
200 -> Quantity
25 -> Rate
View Response
  {
  "data": "Successfully placed bid to sell at specified price",
  "status": 1,
  "error": null,
  "id": 489
}

Explanation of fields: data -> Just a custom message id -> the unique id of the order

Place Market Order via cost

bitbnsObj.placeMarketOrder('BTC', 'INR', 'BUY', 100)
'INR' -> Market (INR/USDT)
'BUY' -> Side (BUY/SELL)
100 -> Buy/Sell coin worth Rs 100 
View Response
  {
 'code': 200,
 'data': 'Successfully placed market order to purchase currency',
 'error': None,
 'id': 12618790,
 'status': 1
 }

Explanation of fields: data -> Just a custom message id -> the unique id of the order status -> 1 (0 for failure)

Place Market Order via quantity

bitbnsObj.placeMarketOrderQuantity('BTC', 'INR', 'BUY', 0.00001)
'INR' -> Market (INR/USDT)
'BUY' -> Side (BUY/SELL)
0.00001 -> Quantity
View Response
  {
 'code': 200,
 'data': 'Successfully placed market order to purchase currency',
 'error': None,
 'id': 12578554,
 'status': 1
 }

Explanation of fields: data -> Just a custom message id -> the unique id of the order status -> 1 (0 for failure)

Placing a STOP LOSS order (BUY)

bitbnsObj.buyStopLoss('XRP', 40, 24, 24.5)

40 -> Quantity 24 -> Rate 24.5 -> Trigger rate

View Response
  {
  "data": "Successfully placed order for stop loss buy",
  "status": 1,
  "error": null,
  "id": 28595
}

Explanation of fields: data -> Just a custom message id -> the unique id of the order

Place Buy Order

bitbnsObj.placeBuyOrder('XRP', 200, 25)
200 -> Quantity
25 -> Rate
View Response
  {
  "data": "Successfully placed bid to purchase currency",
  "status": 1,
  "error": null,
  "id": 490
}

Explanation of fields: data -> Just a custom message id -> the unique id of the order

Placing a STOP LOSS order (BUY)

bitbnsObj.buyStopLoss('XRP', 40, 24, 24.5)

40 -> Quantity 24 -> Rate 24.5 -> Trigger rate

View Response
  {
  "data": "Successfully placed order for stop loss buy",
  "status": 1,
  "error": null,
  "id": 28595
}

Explanation of fields: data -> Just a custom message id -> the unique id of the order

Placing a STOP LOSS order (SELL)

bitbnsObj.sellStopLoss('XRP', 40, 25, 24.5)

40 -> Quantity 24 -> Rate 24.5 -> Trigger rate

View Response
    {
  "data": "Successfully placed a stop limit sell order",
  "status": 1,
  "error": null,
  "id": 28596
}

Explanation of fields: data -> Just a custom message id -> the unique id of the order

Place Cancel Order

bitbnsObj.cancelOrder('XRP', 174)
Here 174 is a order id
View Response
    {
  "data": "Successfully cancelled the order",
  "status": 1,
  "error": null
}

Explanation of fields: data -> just a custom message status -> status of cancellation 1 for success

Getting Sell Order Book for BTC

bitbnsObj.getSellOrderBook('BTC')
View Response
    {
  data: [
    {
      rate: 481847.56,
      btc: 6352679
    },
    {
      rate: 481700,
      btc: 5540000
    },
    {
      rate: 481551,
      btc: 5000000
    },
    {
      rate: 481000,
      btc: 11406
    },
    {
      rate: 480000,
      btc: 208021
    },
    {
      rate: 479366.65,
      btc: 5265026
    },
    {
      rate: 479345,
      btc: 453445
    },
    {
      rate: 478854.18,
      btc: 642042
    },
    {
      rate: 478749.87,
      btc: 208356
    },
    {
      rate: 478511.87,
      btc: 2446067
    },
    {
      rate: 478000,
      btc: 80253706
    },
    {
      rate: 477900,
      btc: 6261808
    },
    {
      rate: 477777,
      btc: 208900000
    },
    {
      rate: 477740,
      btc: 15000000
    },
    {
      rate: 477706.19,
      btc: 5003424
    }
  ],
  status: 1,
  error: null
}

Explanation of fields: rate -> the amount of the order btc -> the volume of the coin for that order

Getting Sell Order Book for BTCUSDT

bitbnsObj.getSellOrderBook('BTCUSDT')
View Response
    {
    "data": [
        { "rate": 13701.34, "btc": 0.145853 },
        { "rate": 13701.35, "btc": 0.043633 },
        { "rate": 13701.47, "btc": 0.543258 },
        { "rate": 13701.69, "btc": 0.664955 },
        { "rate": 13701.72, "btc": 0.131749 },
        { "rate": 13702.36, "btc": 0.406614 },
        { "rate": 13703.18, "btc": 0.253289 },
        { "rate": 13713.46, "btc": 0.19549 },
        { "rate": 13713.88, "btc": 0.055847 },
        { "rate": 13740, "btc": 0.03642294 },
        { "rate": 13848.3, "btc": 0.14447299 },
        { "rate": 13855, "btc": 0.03 },
        { "rate": 13855.11, "btc": 0.0119887 },
        { "rate": 13879.39, "btc": 0.0001 },
        { "rate": 14000, "btc": 0.00163832 }
    ],
    "status": 1,
    "error": None,
    "code": 200
}

Explanation of fields: rate -> the amount of the order btc -> the volume of the coin for that order

Getting Buy Order Book for BTC

bitbnsObj.getBuyOrderBook('BTC')
View Response
    { data:
  [ { rate: 481847.56, btc: 6352679 },
    { rate: 481700, btc: 5540000 },
    { rate: 481551, btc: 5000000 },
    { rate: 481000, btc: 11406 },
    { rate: 480000, btc: 208021 },
    { rate: 479366.65, btc: 5265026 },
    { rate: 479345, btc: 453445 },
{ rate: 478854.18, btc: 642042 },
{ rate: 478749.87, btc: 208356 },
{ rate: 478511.87, btc: 2446067 },
{ rate: 478000, btc: 80253706 },
{ rate: 477900, btc: 6261808 },
{ rate: 477777, btc: 208900000 },
{ rate: 477740, btc: 15000000 },
{ rate: 477706.19, btc: 5003424 } ],

status: 1, error: null }

Explanation of fields: rate -> the amount of the order btc -> the volume of the coin for that order

Getting Buy Order Book for BTCUSDT

bitbnsObj.getBuyOrderBook('BTCUSDT')
View Response
    {
    "data": [
        { "rate": 13657.14, "btc": 0.245901 },
        { "rate": 13656.94, "btc": 0.043868 },
        { "rate": 13656.58, "btc": 0.249137 },
        { "rate": 13656.57, "btc": 0.215321 },
        { "rate": 13656.56, "btc": 0.06557399 },
        { "rate": 13656.26, "btc": 0.28264299 },
        { "rate": 13621.07, "btc": 0.086085 },
        { "rate": 13620.93, "btc": 0.307243 },
        { "rate": 13620.77, "btc": 0.466551 },
        { "rate": 13620.71, "btc": 0.203805 },
        { "rate": 13618.79, "btc": 0.01179179 },
        { "rate": 13600, "btc": 0.00461852 },
        { "rate": 13150, "btc": 0.07585551 },
        { "rate": 13000, "btc": 0.00368308 },
        { "rate": 12950, "btc": 0.01540463 }
    ],
    "status": 1,
    "error": None,
    "code": 200
}

Explanation of fields: rate -> the amount of the order btc -> the volume of the coin for that order

Get executed orders

symbol = 'EOSUSDT'    #symbol = 'EOS' for (EOS/INR market)
since_date = '2021-01-01T00:00:00Z'
page_no = 0
bitbnsObj.listExecutedOrders(symbol, since=since_date, pageNo=page_no)
View Response
    {
   "data":[
      {
         "type":"EOS Buy order executed",
         "typeI":29,
         "crypto":28,
         "amount":28,
         "rate":"3.3929",
         "date":"2021-01-06T18:53:25.000Z",
         "unit":"EOS",
         "factor":100,
         "fee":0.01,
         "delh_btc":0,
         "delh_inr":-0.96,
         "del_btc":28,
         "del_inr":0,
         "id":"2249410",
         "log_id":260236056
      }
   ],
   "status":1,
   "error":"None",
   "code":200
}

Explanation of fields: type -> type of action typeI -> action id amount -> the amount deposited date -> the time at which this event occurred unit -> the symbol name of coin factor -> the division factor del_btc -> delta changes in normal wallet of coin del_inr -> delta changes in normal inr wallet delh_btc -> delta changes in hold wallet of coin

Get API usage Status

bitbnsObj.getApiUsageStatus()
View Response
    {
     data: {
        readLimt : 100,
        writeLimit : 30,
        readRateUsed: 0,
        writeRateUsed: 1,
        status: 1
     },
      status: 1,
      error: null
    }

Explanation of the fields: readLimit -> the read limit of the user writeLimit -> the write limit of the user readRateUsed -> the read requests used writeRateUsed -> the write requests used

Getting Order Status

bitbnsObj.orderStatus('BTC', '4221')
4221 -> order id
View Response
{
  data: [
    {
      entry_id: 4221,
      btc: 0.001,
      rate: 306929.01,
      time: '2018-09-20T13:54:21.000Z',
      type: 0,
      status: 0
    }
  ],
  status: 1,
  error: null
}

Explanation of fields: entry_id -> the unique id for the order btc -> the volume of the currency placed rate -> the rate at which the order is placed time -> the timestamp of the entry type -> 0 for buy and 1 for sell status -> -1 for cancelled, 0 for not processed, 1 for partially executed, 2 for fully executed

Cancel Stop Loss Order

bitbnsObj.cancelStopLossOrder('BTC', 4221)
4221 -> order id
View Response
    {
  data: 'Successfully cancelled the order',
  status: 1,
  error: null
}

Explanation of fields: data -> the custom message status -> for successful request the status is 1

Curl request to get server time

curl -H "X-BITBNS-APIKEY: API-KEY" -X GET 'https://api.bitbns.com/api/trade/v1/getServerTime'
View Response
    {
  serverTime: '1538150764273',
  status: 1,
  error: null
}

Explanation of fields: serverTime -> the server timestamp status -> the response succeeded

API V2 (New Features)

Place Orders(BUY or SELL)

(Placing Bracket Order)

bitbnsObj.placeOrders({'symbol': 'XRP', 'side': 'BUY', 'quantity': 40, 'rate': 4, 'target_rate': 5, 't_rate': 3.5, 'trail_rate': .01})

side -> BUY or SELL symbol -> COIN NAME, quantity -> QUANTITY, rate -> RATE, target_rate -> TARGET RATE, t_rate -> TRRIGER RATE, trail_rate -> TRAIL RATE

To Place Simple Buy or Sell Order use rate To Place Stoploss Buy or Sell Order use rate & t_rate To Place Bracket Buy or Sell Order use rate , t_rate, target_rate & trail_rate

View Response
    {
  "data": "Successfully placed a bracket order",
  "status": 1,
  "error": null,
  "id": 4518726,
  "code": 200
}

Explanation of fields: data -> the custom message status -> for successful request the status is 1 id -> the unique id of the order

Cancel Order

bitbnsObj.cancelOrders({'symbol': 'XRP', 'side' : 'cancelOrder', 'entry_id': 462})

side -> "cancelOrder","cancelStopLossOrder", "usdtcancelOrder", "usdtcancelStopLossOrder" symbol -> COIN NAME entry_id : ENTRY ID

View Response
    {
  "data": "Successfully cancelled the order",
  "status": 1,
  "error": null,
  "code": 200
}

Explanation of fields: data -> the custom message status -> for successful request the status is 1

Place Orders in USDT Market

bitbnsObj.placeOrders({'symbol': 'TRX_USDT', 'side': 'BUY', 'quantity': 40, 'rate': 4, 'target_rate': 5, 't_rate': 3.5, 'trail_rate': .01})

side -> BUY or SELL symbol -> COIN NAME(use suffix "_USDT" with coin name) quantity -> QUANTITY, rate -> RATE, target_rate -> TARGET RATE, t_rate -> TRRIGER RATE, trail_rate -> TRAIL RATE

To Place Simple Buy or Sell Order use rate To Place Stoploss Buy or Sell Order use rate & t_rate To Place Bracket Buy or Sell Order use rate , t_rate, target_rate & trail_rate

View Response
   {
  "data": "Successfully placed bid to purchase currency",
  "status": 1,
  "error": null,
  "id": 6743385,
  "code": 200
}

Explanation of fields: data -> the custom message status -> for successful request the status is 1 id -> the unique id of the order

Cancel Order in USDT MARKET

bitbnsObj.cancelOrders({'symbol': 'TRX_USDT', 'side' : 'usdtcancelOrder', 'entry_id': 462})

side -> "cancelOrder","cancelStopLossOrder", "usdtcancelOrder", "usdtcancelStopLossOrder" symbol -> COIN NAME(use suffix "_USDT" with coin name) entry_id : ENTRY ID

View Response
    {
  "data": "Successfully cancelled the order",
  "status": 1,
  "error": null,
  "code": 200
}

Explanation of fields: data -> the custom message status -> for successful request the status is 1

Get Orders in USDT MARKET

bitbnsObj.getOrders({'side' : 'usdtListOpenOrders', 'symbol' : 'TRX_USDT', 'page' : 0})

side -> "listOpenOrders", "listOpenStopOrders", "listOpenBracketOrders", "usdtListOpenBracketOrders", "usdtListOpenStopOrders","usdtListOpenOrders" symbol -> COIN NAME(use suffix "_USDT" with coin name) page -> INTEGER

View Response
    {
  "data": [
    {
      "entry_id": 6747351,
      "btc": 750,
      "rate": 0.02,
      "time": "2020-10-31T04:43:30.000Z",
      "type": 0,
      "status": 0
    }
  ],
  "status": 1,
  "error": null,
  "code": 200
}

Explanation of fields: rate -> the amount of the order btc -> the volume of the coin for that order type -> 1 for sell and 0 for buy order status -> for successful request the status is 1

Get token to authenticate orders

bitbnsObj.getTokenSocket()
View Response
    {
  "data": "Lw7P8tgPk72hKg0ue3BYVCHif_10071804",
  "status": 1,
  'error': None,
  'code': 200
 }

Explanation of fields: data -> token-id based on API keys error -> the custom message status -> for successful request the status is 1

Use socket to get live order book

data = bitbnsObj.getOrderBookSocket(coinName = 'BTC', marketName = 'INR')
socket = data['socket']

@socket.event def news(data): print(data)

@socket.event def disconnect(): print("Disconnected")

Pass USDT as market name to get orderbook of USDT market Pass ALL as coin name to get orderbook of all coins

Use socket to get live Ticker data

data = bitbnsObj.getTickerSocket(marketName = 'INR')
socket = data['socket']

@socket.event def ticker(data): print(data)

@socket.event def disconnect(): print("Disconnected")

Pass USDT as market name to get ticks of USDT market

Use socket to get live executed order of your account

Does not work right now!
token = bitbnsObj.getTokenSocket()
data = bitbnsObj.getExecutedOrders(token['data'])
socket = data['socket']

@socket.event def delta_data(data): print(data)

@socket.event def disconnect(): print("Disconnected")

Margin Trading V2 APIs

Place a margin order

bitbnsObj.placeMarginOrders({'symbol': 'USDT', 'side': 'placeOrder', 'type': 'LEND', 'qnty': 40, 'days': 1, 'rate': 0.0055})

side -> placeOrder type -> BORROW or LEND days -> 1,3,7,15,30 renew -> 0,1,2 symbol -> COIN NAME, qnty -> QUANTITY, rate -> RATE

Renew Flags => 0 - Don't renew, 1 -> Renew only Principal, 2 -> Renew with Principal + Interest

View Response
    {
  "status": 1,
  "error": "Successfully placed lend order for Margin trading.",
  "code": 200
}

Explanation of fields: error -> the custom message status -> for successful request the status is 1

Cancel a margin order

bitbnsObj.cancelMarginOrder({'id': 1, 'side': 'cancelMarginOrder', 'symbol': 'USDT'})

Pass id of the margin transaction you are looking to cancel symbol -> COIN NAME,

View Response
    {
      "status": 1,
      "error": "Successfully cancelled the order",
      "code": 200
    }

Explanation of fields: error -> the custom message status -> for successful request the status is 1

Settle a margin order partially

bitbnsObj.settleMarginPartial({'id': 1, 'side': 'settleMarginOrderPartial', 'amt': 50, 'symbol': 'USDT'})

amt -> Amount to settle

Pass id of the margin transaction you are looking to settle and amt you want to settle

View Response
    {
  "status": 1,
  "error": "Successfully settled the margin order",
  "code": 200
}

Explanation of fields: error -> the custom message status -> for successful request the status is 1

Settle a margin order completely

bitbnsObj.settleMargin({ 'id' : 1, 'side' : 'settleMarginOrder', 'symbol': 'USDT' })

Pass id of the margin transaction you are looking to settle

View Response
    {
  "status": 1,
  "error": "Successfully settled the margin order",
  "code": 200
}

Explanation of fields: error -> the custom message status -> for successful request the status is 1

Get my margin executed orders

bitbnsObj.listMarginExecuted({'page': 1, 'side': 'listMarginExecuted', 'type': 'BORROW', 'symbol': 'USDT'})

type => LEND or BORROW

View Response
  response for borrow:
  {
    "data": [
      {
        "entry_id": 53298,
        "worth_required": 8129.82,
        "worth_current": 26779.7,
        "margin_taken": 85,
        "status": 0,
        "expiry": "2020-11-01T07:03:04.000Z",
        "phase": 0,
        "margin_to_return": 85.04,
        "days": 1,
        "interest": 0.055,
        "coin": 54,
        "margin_partial_return": 0
      }
    ],
    "status": 1,
    "error": null,
    "code": 200
  }
response for lend:
    {
      "data": [
        {
          "entry_id": 114143,
          "amt": 50,
          "time": "2020-02-03T02:48:41.000Z",
          "status": 10,
          "expiry": "2020-02-18T08:18:41.000Z",
          "days": 15,
          "interest": 0.051,
          "coin": 54,
          "renew": 0
        }
      ],
      "status": 1,
      "error": null,
      "code": 200
    }

Explanation of fields: data -> the custom message worth_required -> the amount required to maintain the margin worth_current -> current worth of margin borrwoed margin_taken -> the amount value borrowed expiry -> time of expiry of margin margin_to_return -> amount to be returned. days -> number of days the margin was borrowed or lent. interest -> intreset of margin per day. amt -> the amount of coins lent error -> the custom message status -> for successful request the status is 1

Get my margin pending orders

bitbnsObj.listMarginPending({'page': 1, 'side': 'listMarginPending', 'symbol': 'USDT'})
View Response
    {
  "data": [
    {
      "entry_id": 215769,
      "btc": 40,
      "days": 1,
      "time": "2020-10-31T06:42:54.000Z",
      "type": 0,
      "status": 0,
      "rate": 0.083
    }
  ],
  "status": 1,
  "error": null,
  "code": 200
}

Explanation of fields: data -> the custom message entry_id -> the unique id assigned to the order days -> number of days lent or borrowed btc -> the volume of the coin type -> 1 for borrow and 0 for lend order rate -> the rate at which the margin is lend or borrowed status -> for successful request the status is 1

Get open orders of margin market - all users

bitbnsObj.listMarginMarketOrders({'type': 'BORROW', 'side': 'listMarketOrders', 'symbol': 'XRP'})

type => LEND or BORROW

View Response
    {
  "data": [
    {
      "btc": 486.55,
      "days": 7,
      "rate": 0.0539
    },
    {
      "btc": 2.31,
      "days": 1,
      "rate": 0.055
    },
    {
      "btc": 4392.95,
      "days": 3,
      "rate": 0.06
    },
    {
      "btc": 99.96,
      "days": 15,
      "rate": 0.065
    },
    {
      "btc": 1242,
      "days": 30,
      "rate": 0.065
    },
    {
      "btc": 13287.65,
      "days": 7,
      "rate": 0.067
    },
    {
      "btc": 350,
      "days": 30,
      "rate": 0.068
    },
    {
      "btc": 5500,
      "days": 7,
      "rate": 0.07
    },
    {
      "btc": 2119.34,
      "days": 30,
      "rate": 0.0749
    },
    {
      "btc": 1770.51,
      "days": 30,
      "rate": 0.076
    },
    {
      "btc": 53.52,
      "days": 30,
      "rate": 0.0779
    },
    {
      "btc": 3231.92,
      "days": 15,
      "rate": 0.078
    },
    {
      "btc": 622.69,
      "days": 15,
      "rate": 0.079
    },
    {
      "btc": 17306,
      "days": 1,
      "rate": 0.08
    },
    {
      "btc": 7840,
      "days": 15,
      "rate": 0.085
    },
    {
      "btc": 446.07,
      "days": 30,
      "rate": 0.0855
    },
    {
      "btc": 762.59,
      "days": 30,
      "rate": 0.0856
    },
    {
      "btc": 500,
      "days": 30,
      "rate": 0.087
    },
    {
      "btc": 195.66,
      "days": 30,
      "rate": 0.088
    },
    {
      "btc": 112.33,
      "days": 30,
      "rate": 0.089
    },
    {
      "btc": 2769,
      "days": 1,
      "rate": 0.09
    },
    {
      "btc": 20000,
      "days": 3,
      "rate": 0.09
    },
    {
      "btc": 7000,
      "days": 7,
      "rate": 0.09
    },
    {
      "btc": 8525.51,
      "days": 30,
      "rate": 0.09
    },
    {
      "btc": 206,
      "days": 1,
      "rate": 0.091
    },
    {
      "btc": 20000,
      "days": 15,
      "rate": 0.091
    },
    {
      "btc": 2096.32,
      "days": 30,
      "rate": 0.099
    },
    {
      "btc": 235,
      "days": 1,
      "rate": 0.1
    },
    {
      "btc": 401780.26,
      "days": 30,
      "rate": 0.1
    },
    {
      "btc": 50000,
      "days": 30,
      "rate": 0.11
    },
    {
      "btc": 19999.81,
      "days": 15,
      "rate": 0.12
    },
    {
      "btc": 61.71,
      "days": 30,
      "rate": 0.12
    },
    {
      "btc": 107.45,
      "days": 30,
      "rate": 0.14
    },
    {
      "btc": 43212,
      "days": 15,
      "rate": 0.169
    },
    {
      "btc": 30000,
      "days": 7,
      "rate": 0.17
    },
    {
      "btc": 90610.26,
      "days": 30,
      "rate": 0.18
    }
  ],
  "status": 1,
  "error": null,
  "code": 200
}

Explanation of fields: data -> the custom message days -> number of days lent or borrowed btc -> the volume of the coin rate -> the rate at which the margin is lend or borrowed status -> for successful request the status is 1

FIP Endpoints

List All FIPs

bitbnsObj.listAllFIP({'type': 'ONGOING'})
type => COMPLETE || ONGOING || UPCOMING || DISTRIBUTED
View Response
    {
      'data': [{
        'fip_id': 625,
        'total_amt': 100,
        'amt_raised': 0.77,
        'int_rate': 15,
        'int_rate_month': 0.015,
        'min_instalment': 0.01,
        'max_instalment': 50,
        'start_date': '2022-02-02T06:30:00.000Z',
        'allocation_complete_date': '0000-00-00 00:00:00.0000',
        'maturity_date': '0000-00-00 00:00:00.0000',
        'usersCount': 3,
        'duration': 30,
        'coin': 72,
        'name': 'BNB Mega FD',
        'status': 2,
        'withBNS': 1,
        'redeemable': 0,
        'percentBNS': 1,
        'factor': 10000
       },
       .
       .
       }],
      'status': 1,
      'error': None,
      'code': 200
    }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

Enroll for a FIPs

bitbnsObj.enrollForFIP({'fip_id': 441, 'amt': 10})
fip_id => ID of the FIP for which you want to enroll
View Response

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

Get All FIP Transactions

For trade History
bitbnsObj.getFIPTransactions()
View Response
    {
     'data': [{
       'log_id': 64317,
       'fip_id': 614,
       'user_id': 1199639,
       'time': '2022-02-02T07:55:59.000Z',
       'type': 0,
       'amt': 10,
       'coin': 54,
       'lock1': 0,
       'lock2': 10,
       'bns_amount': 10,
       'name': 'USDT FD Monthly',
       'factor': 100
       }],
     'status': 1,
     'error': None,
     'code': 200
    }
Explanation of fields:
data -> the custom message
status -> for successful request the status is 1
error -> error message if any
  

Get all your ongoing FIPs

bitbnsObj.getOngoingFIP()
View Response
    {
     'code': 200,
     'data': [{
       'amt_available': 0.2,
       'amt_instalment': None,
       'amt_invested': 20,
       'amt_redeemed': 0,
       'days': 3,
       'entry_id': 33381,
       'fip_details': {
          'allocation_complete_date': '2022-02-03T04:30:02.000Z',
          'amt_raised': 4000,
          'coin': 54,
          'days': 4,
          'duration': 30,
          'factor': 100,
          'fip_id': 614,
          'int_rate': 21,
          'int_rate_month': 0.015,
          'maturity_date': '2022-03-05T04:30:02.000Z',
          'min_instalment': 1000,
          'name': 'USDT FD Monthly',
          'percentBNS': 10,
          'redeemable': 0,
          'start_date': '2022-02-02T06:30:00.000Z',
          'status': 3,
          'total_amt': 1500000,
          'withBNS': 1
         },
       'fip_id': 614,
       'lock1': 0,
       'lock2': 0,
       'mat_amount': 2033,
       'others': 20,
       'status': 0,
       'user_id': 1199639,
       'utility': 0
      }],
   'error': None,
   'status': 1
   }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

Presubscribe for an FIP

bitbnsObj.preSubscribeForFIP({'fip_id': 614, 'amt': 10})
View Response
    {
       'data': 'Successfully pre subscribed you for FIP',
       'status': 1,
       'error': None,
       'code': 200
    }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

Fetch all your presubscribed FIPs

bitbnsObj.fetchMySubscriptions()
View Response
    {
       'code': 200,
       'data': [{
         'amt_invested': 1000,
         'entry_id': 9702,
         'fip_id': 614,
         'status': 1,
         'user_id': 1199639
        }],
       'error': None,
       'status': 1
     }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

Fetch different types of historical details

Fetch trade history

body = { 'method' : 'tradeHistory', 'coin_name' : 'BTC', 'market' : 'INR', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body)

Fetch INR deposit

body = { 'method' : 'depINRHistory', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body)

Fetch INR withrawal history

body = { 'method' : 'withINRHistory', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body)

Fetch deposits (crypo including airdrops)

body = { 'method' : 'depCryptoHistory', 'coin_name': 'BTC', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body)

Fetch withdrawals (crypto including airdrops)

body = { 'method' : 'withCryptoHistory', 'coin_name': 'BTC', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body)

Fetch deposit crypto blockchain history

body = { 'method' : 'depCryptoExternalHistory', 'coin_name': 'BTC', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body)

Fetch withdrawals crypto blockchain history

body = { 'method' : 'withCryptoExternalHistory', 'coin_name': 'BTC', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body)

View Response
{
 'data': [], 
 'status': 1, 
 'error': 'Successfully fetched data', 
 'code': 417
}

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

Swap API Endpoints

All Supported coins available for Swap

bitbnsObj.swapCoinList()
View Response
    {
       'code': 200,
       'data': {
         '1inch': {
           'buyEstimate': '1.895',
           'buyEstimateINR': 148.7954,
           'buyLimit': 200000,
           'coinIcon': 'https://s2.coinmarketcap.com/static/img/coins/64x64/8104.png',
           'coinId': 125,
           'coinName': '1inch',
           'floatPlaces': 2,
           'inrDecimals': 3,
           'isActiveSwap': 1,
           'sellEstimate': '1.876',
           'sellEstimateINR': 145.85899999999998,
           'sellLimit': 200000,
           'usdtDecimals': 3
         },
         .
         .
         }
       },
       'error': None,
       'msg': 'Coin Details',
       'status': 1
    }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

Place limit order on Swap in INR Market

bitbnsObj.swapLimitINR({'coin': 'BTC', 'quantity':0.000005, 'rate': 3358000, 'type': 1})
type => 0 for buy, 1 for sell
View Response
    {
     'code': 200,
     'data': 'Successfully placed order.',
     'error': None,
     'id': 746314,
     'status': 1
    }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any id -> order id

Place limit order on Swap in USDT Market

bitbnsObj.swapLimitUSDT({'coin': 'BTC', 'quantity':0.000005, 'rate': 430000, 'type': 1})
type => 0 for buy, 1 for sell
View Response
    {
     'code': 200,
     'data': 'Successfully placed order.',
     'error': None,
     'id': 746317,
     'status': 1
    }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any id -> order id

Place market order on Swap INR market

bitbnsObj.swapMarketINR({'coin': 'BTC', 'quantity':0.000005, 'type': 1})
type => 0 for buy, 1 for sell

To place order based on quantity, pass quantity in the dictionary To place order based on volume (max. amount you want to buy irresp. of quantity), pass volume in the dictionary
View Response
    {
     'code': 200,
     'data': 'Successfully placed order.',
     'error': None,
     'id': 746328,
     'status': 1
    }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any id -> order id

Place market order on Swap USDT market

bitbnsObj.swapMarketUSDT({'coin': 'BTC', 'quantity':0.000005, 'type': 1})
type => 0 for buy, 1 for sell

To place order based on quantity, pass quantity in the dictionary To place order based on volume (max. amount you want to buy irresp. of quantity), pass volume in the dictionary
View Response
    {
     'code': 200,
     'data': 'Successfully placed order.',
     'error': None,
     'id': 746338,
     'status': 1
    }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any id -> order id

Get swap orders history

bitbnsObj.swapOrderHistory({'page': 0})
type => 0 for buy, 1 for sell
View Response
{'code': 200,
 'data': [{'coin_name': {'coin_name': 'BTC'},
   'coin_type': 0,
   'credit_amount': 500,
   'date': '2022-02-28T07:42:54.000Z',
   'exchange': 2,
   'executed_inr_rate': 3358000,
   'executed_usdt_rate': 42688.66090951,
   'extraPaid': 0,
   'factor': 100000000,
   'id': 779285,
   'market': 0,
   'order_type': 1,
   'quantity': 500,
   'rate': 3358000,
   'status': 3,
   'volume': 1680},
  {'coin_name': {'coin_name': 'BTC'},
   'coin_type': 0,
   'credit_amount': 500,
   'date': '2022-02-28T07:39:14.000Z',
   'exchange': 2,
   'executed_inr_rate': 3358000,
   'executed_usdt_rate': 42688.66090951,
   'extraPaid': 0,
   'factor': 100000000,
   'id': 779283,
   'market': 0,
   'order_type': 1,
   'quantity': 500,
   'rate': 3358000,
   'status': 3,
   'volume': 1680},
  {'coin_name': {'coin_name': 'BTC'},
   'coin_type': 0,
   'credit_amount': 500,
   'date': '2022-02-28T07:29:24.000Z',
   'exchange': 2,
   'executed_inr_rate': 3083238.016875,
   'executed_usdt_rate': 38198.36115429,
   'extraPaid': 137,
   'factor': 100000000,
   'id': 779282,
   'market': 0,
   'order_type': 0,
   'quantity': 500,
   'rate': 3358000,
   'status': 3,
   'volume': 1680},
  {'coin_name': {'coin_name': 'BTC'},
   'coin_type': 0,
   'credit_amount': 3032,
   'date': '2022-02-07T03:11:47.000Z',
   'exchange': 1,
   'executed_inr_rate': 3298356.72,
   'executed_usdt_rate': 42341.16,
   'extraPaid': 0,
   'factor': 100000000,
   'id': 746446,
   'market': 0,
   'order_type': 1,
   'quantity': 3032,
   'rate': 3298356.72,
   'status': 3,
   'volume': 10001}],
 'error': None,
 'msg': 'Order History',
 'status': 1}

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

Cancel swap order

bitbnsObj.swapCancelOrder({'order_id': '746342', 'market': 0})
order_id  =>    The id of the order to be cancelled
market    =>    0 for INR, 1 for USDT
View Response
    {
      'code': 200, 
      'data': Successfully cancelled order, 
      'error': None, 
      'status': 1
    }

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

List open swap order

bitbnsObj.swapListOpenOrders({'page': 0})

Endpoint is paginated
View Response
  {
   'code': 200,
   'data': [{'coin_name': {'coin_name': 'BTC'},
   'coin_type': 0,
   'credit_amount': 0,
   'date': '2022-04-11T06:20:29.000Z',
   'exchange': 1,
   'executed_inr_rate': 0,
   'executed_usdt_rate': 0,
   'extraPaid': 0,
   'factor': 100000000,
   'id': 825865,
   'market': 0,
   'order_type': 0,
   'quantity': 500,
   'rate': 3358000,
   'status': 0,
   'volume': 1680}],
 'error': None,
 'msg': 'Order List',
 'status': 1
}

Explanation of fields: data -> the custom message status -> for successful request the status is 1 error -> error message if any

Partner Endpoints

Bitbns provides support to its partners via the partner endpoints. One needs to get whitelisted by the bitbns team to use these APIs

Create new account

body = {
	'email' : '[email protected]',
	'phone' : '8676857590',
	'pass' : 'hd237ydkldl',
	'dormant' : 1,
    	'country' : 0
    }
b.createNewAccount(body = body)
View Response
{
  data: { 
    User_id: 1877083 
    },
  status: 1,
  error: 'Successfully registered',
  code: 200
}

Explanation of fields: data -> User ID status -> for successful request the status is 1 error -> error message if any

Update Account details

For pan card addtion

body = { 'target_uid' : 1705823, 'type' : 'pan', 'id' : 'DVZPS7302U', 'name' : 'Prashant Singh', 'dob': '12-03-1992' } b.updateUserAccountDetails(body = body)

For Aadhaar card addition

body = { 'target_uid' : 1705823, 'type' : 'aadhaar', 'id' : '782379829288', 'name' : 'Prashant Singh', } b.updateUserAccountDetails(body = body)

For addition of bank details

body = { 'target_uid' : 1705823, 'type' : 'bank', 'acc_id' : '782373229829288', 'name' : 'Prashant Singh', 'branch' : 'Koramangala', 'bank_name' : 'HDFC Bank', 'ifsc' : 'HDFC00000017', 'mob' : '8676857590', 'bank_type' : 'Savings', } b.updateUserAccountDetails(body = body)

Adding UPI id

body = { 'target_uid' : 1705823, 'type' : 'upi', 'vpa' : 'atiprashant@okhdfc' } b.updateUserAccountDetails(body = body) print(response)

Mark KYC Uploaded

body = { 'target_uid' : 1705823, 'type' : 'kycUploaded' } b.updateUserAccountDetails(body = body)

View Response
{ 
    status: 1, 
    error: 'Successfully updated', 
    code: 200 
}

Explanation of fields: status -> for successful request the status is 1 error -> error message if any

Fetch user details

b.fetchUserAccountDetails(body = {
    'target_uid': 1705823
    })
View Response
// In case of rejection
{
  data: {
    panCard: true,
    eyeFront: true,
    eyeBack: true,
    isTelegramLinked: false,
    upiList: [],
    email: '[email protected]',
    phone: '+919090909090',
    country: 0,
    phone_verified: 0,
    video_kyc: 0,
    '2fa_en': '',
    kyc_status: 'REJECTED',
    allBanks: []
  },
  status: 1,
  error: null,
  code: 200
}

// In case not submitted { data: { panCard: true, eyeFront: true, eyeBack: true, isTelegramLinked: false, upiList: [], email: '[email protected]', phone: '+919090909090', country: 0, phone_verified: 0, video_kyc: 0, '2fa_en': '', kyc_status: 'REJECTED', allBanks: [] }, status: 1, error: null, code: 200 }

// In case its pending { data: { panCard: true, eyeFront: true, eyeBack: true, isTelegramLinked: false, upiList: [], email: '[email protected]', phone: '+919090909090', country: 0, phone_verified: 0, video_kyc: 0, '2fa_en': '', kyc_status: 'PENDING', pan: 'ABCDE7302T', dob: '1992-03-12', name: 'Test Buyhatke', aadhar: '722319529382', allBanks: [ [Object] ], mobile_bank: '9234567891', bank_name: 'HDFC Bank', ifsc: 'HDFC00000017', branch: 'Koramangala', acc_type: 'Savings', name_bank: 'Test Buyhatke', acc_num: '722675224822281', ibank: '', verified: 0 }, status: 1, error: null, code: 200 }

Explanation of fields: code -> code for the request (200 means ok) panCard -> pan card added or not isTelegramLinked -> Telegram linked or not upiList -> List of UPI ids email -> email id of the user phone -> phone no. of the user country -> country of the user phone_verified -> is phone verified or not video_kyc -> Video KYC kyc_status -> Status of KYC allBanks -> List of all banks pan -> pan card id dob -> Date of birth of User name -> name of the user aadhaar -> Aadhaar card of the user bank_name -> name of the bank ifsc -> IFSC code branch -> branch of bank acc_type -> Type of account acc_num -> Account number verified -> Verified or not status -> 0 is for unsuccessful request, 1 is for a successful one

Generate new API Keys

b.generateNewAPIKey(body = {
    'target_uid': 1705823
    })
View Response
{
  apiSecret: '502C783C2B50983F8BCD1F4940F54CF6',
  apiPublic: '63C809662EC27B19396BB1FE12E556D4',
  status: 1,
  error: null,
  code: 200
}

Explanation of fields: apiSecret -> API Secret key apiPublic -> API Public Key status -> 1 for a successful request error -> Custom message code -> code for the request (200 means ok)

Transfer funds to Pool account

b.transferToPoolAccount(body = {    
	'pool_uid' : 64873278,
	'amount' : 50,
	})
View Response

{ status: 1, error: 'Successfully transfered funds to pool account', code: 200 }

Explanation of fields: code -> code for the request (200 means ok) error -> custom message status -> 0 is for unsuccessful request, 1 is for a successful one

Transfer coin to Pool account

body = {    
	'pool_uid' : 64873278,
	'amount' : 0.01,
	'coin_name': 'SOL'
	}
b.transferCoinToPoolAccount(body = body)
View Response

{ status: 1, error: 'Successfully transfered funds from pool account', code: 200 }

Explanation of fields: code -> code for the request (200 means ok) error -> custom message status -> 0 is for unsuccessful request, 1 is for a successful one

Transfer coin from Pool account

body = {    
	'target_uid' : 64873278,
	'amount' : 1,
	'coin_name': 'GARI'
	}
b.transferCoinFromPoolAccount(body = body)
View Response

{ status: 0, error: 'Insufficient permission for this operation 0', code: 416 }

Explanation of fields: code -> code for the request (200 means ok) error -> custom message status -> 0 is for unsuccessful request, 1 is for a successful one

Transfer USDT funds from Pool account

b.transferUSDTFromPoolAccount(body = {    
	'target_uid' : 64873278,
	'amount' : 50,
	})
View Response

{ status: 0, error: 'Insufficient permission for this operation', code: 416 }

Explanation of fields: code -> code for the request (200 means ok) error -> custom message status -> 0 is for unsuccessful request, 1 is for a successful one

Transfer INR funds from Pool account

b.transferINRFromPoolAccount(body = {    
	'target_uid': 28746827,
	'usdtAmt' : 50,
	'inrAmt' : 4000,
  'vpa': 'test@pingpay'
	})
View Response

{ status: 0, error: 'Insufficient permission for this operation', code: 416 }

Explanation of fields: code -> code for the request (200 means ok) error -> custom message status -> 0 is for unsuccessful request, 1 is for a successful one

Request Coin Withdrawal

b.requestCoinWithdrawFromPoolAccount(body = {
	'target_uid' : 23342324,
	'amount' : 1,
  'coin_name': 'GARI'
})
View Response

Explanation of fields:

Payment Gateway

For people who would want to use bitbns gateway for crypto payments, can do so using the endpoints described in this section. You need two things before you can start to use the portal:
  • merchant_id
  • merchant_secret
You need to get an approval from the Bitbns dev team for generating and using the gateway.

To successfully use the gateway, please follow the following steps:
  1. Generate a payment request
  2. Step 1 would redirect you to a payment URL
  3. On success/failure, Bitbns will redirect you to landing/callback page with fields - status, msg, amount, coin, signature
  4. Verify the signature
  5. Alternatively, you can also fetch payment status from fetchPGOrderStatus

Create New Payment Gateway Order

body = {
    'merchant_id': 1,
    'amt': 25, 
    'coin': "USDT", 
    'refId': "ORDER_CLIENT123487134", 
    'email': '[email protected]'
}
response = b.createNewPGOrder(body = body)
View Response

{ data: { order_id: 22, url: 'https://bitbns.com/payments/?oid=22' }, status: 1, error: 'Successfully generated order', code: 200 }

Explanation of fields: order_id -> Id of the Order url -> Payment URL status -> 1 for successful request error -> custom message

Fetch Payment Gateway Order

b.createNewPGOrder(body = { 'merchant_id': 1, 'order_id': 21 })

View Response

// If user is on the payment page { data: [ { id: 40, merchant_id: 1, coin: 54, amount: 10000, init_time: '2022-01-05T08:51:26.000Z', payment_time: '0000-00-00 00:00:00', client_ref_id: 'ORDER_CLIENT112', status: 0, user_id: 103602, errMsg: '' } ], status: 1, error: 'Successfully fetched details', code: 200 }

// If the user has declined payment { data: [ { id: 40, merchant_id: 1, coin: 54, amount: 10000, init_time: '2022-01-05T08:51:26.000Z', payment_time: '0000-00-00 00:00:00', client_ref_id: 'ORDER_CLIENT112', status: -1, user_id: 103602, errMsg: 'User declined payment' } ], status: 1, error: 'Successfully fetched details', code: 200 }

// If user has successfully paid { data: [ { id: 43, merchant_id: 1, coin: 54, amount: 1, init_time: '2022-01-05T11:03:34.000Z', payment_time: '2022-01-05T11:34:04.000Z', client_ref_id: 'ORDER_CLIENT112', status: 1, user_id: 103602, errMsg: '' } ], status: 1, error: 'Successfully fetched details', code: 200 }

// Unauthorized payment - order_id or otherwise {
status: 0, error: 'Unauthorized to fetch order status ', code: 200 }

Explanation of fields:

Futures

Bitbns is proud to announce the release of futures trading on its platform. Here lies the documentation for the same

Active markets

response = b.futuresInstList(body = {'network': 'mainnet'})
View Response
       {'code': 200,
 'data': {'1': {'coin_id': 477,
                'default_leverage': '10',
                'factor': 100000000,
                'inst_id': 1,
                'inst_leverage_json': {'1': 20, '10': 2, '3': 7, '5': 4},
                'margin_bucket_json': {'1': 20, '10': 2.5, '3': 10, '5': 5},
                'min_allowed': 0.0003,
                'name': 'IC15USDT Perpetual',
                'price_prec': 2,
                'qnty_prec': 4,
                'status': 0,
                'usdt_settled': 1},
          '2': {'coin_id': 0,
                'default_leverage': '10',
                'factor': 100000000,
                'inst_id': 2,
                'inst_leverage_json': {'1': 30, '10': 3, '3': 10, '5': 6},
                'margin_bucket_json': {'1': 20, '10': 2.5, '3': 10, '5': 5},
                'min_allowed': 0.0003,
                'name': 'BTCUSDT Perpetual',
                'price_prec': 2,
                'qnty_prec': 4,
                'status': 0,
                'usdt_settled': 1},
          '3': {'coin_id': 6,
                'default_leverage': '10',
                'factor': 100000000,
                'inst_id': 3,
                'inst_leverage_json': {'1': 500, '10': 50, '3': 175, '5': 100},
                'margin_bucket_json': {'1': 20, '10': 2.5, '3': 10, '5': 5},
                'min_allowed': 0.005,
                'name': 'ETHUSDT Perpetual',
                'price_prec': 2,
                'qnty_prec': 3,
                'status': 0,
                'usdt_settled': 1},
          '4': {'coin_id': 77,
                'default_leverage': '3',
                'factor': 100,
                'inst_id': 4,
                'inst_leverage_json': {'1': 12500000, '3': 5000000},
                'margin_bucket_json': {'1': 20, '3': 10},
                'min_allowed': 25000,
                'name': 'BNSUSDT Perpetual',
                'price_prec': 8,
                'qnty_prec': 0,
                'status': 0,
                'usdt_settled': 1}},
 'error': None,
 'msg': 'Instrument Details',
 'status': 1}

Explanation of fields: coin_id -> Coin ID default_leverage -> default leverage set by trading system factor -> factor in which coin operates inst_id -> Instrument ID min_allowed -> Minimum order quantity name -> Name of the instrument price_prec -> Price precision qnty_prec -> Quantity Precision

Wallet Balance

response = b.futuresWalletBalance(body = {'network': 'mainnet'})
View Response

Explanation of fields:

Allowed Open Position

body = {
    'inst_id': 1,
    'network': 'mainnet'
    }
response = b.futuresMaxOpenPos(body = body)
View Response
{
 'code': 200,
 'data': {'maxOpenPositionsAllowed': {'1': 0}},
 'error': 'Max Open Positions',
 'status': 1
 }

Explanation of fields: data -> max open position allowed for the specified instrument

Update user leverage

body = {
    'inst_id': 2,
    'leverage': 7,
    'network': 'mainnet'
    }
response = b.futuresUpdateLeverage(body = body)
View Response
{
 'code': 200,
 'data': {
  'leverage': 7
  },
 'error': 'Leverage Updated Successfully',
 'status': 1
 }

Explanation of fields: leverage -> leverage amount it has been updated to

Get Open Orders

body = {'network': 'mainnet'}
response = b.futuresOpenOrders()
View Response
{'code': 200,
 'data': [{'initial_margin': 0.86,
           'inst_id': 2,
           'order_id': 152538,
           'order_time': '2022-07-14T08:10:01.000Z',
           'qnty': 0.0003,
           'qnty_rem': 0.0003,
           'rate': 19700,
           'side': 'Long',
           'type': 'Open',
           'usdt_settled': 1}],
 'error': 'Open Orders',
 'status': 1}

Explanation of fields: data -> An array of open orders initial_margin-> Initial Margin inst_id -> Instrument ID order_id -> Order ID qnty -> Quantity placed qnty_rem -> Remaining quantity to execute rate -> Rate at which the order was placed side -> Long/Short type -> Open/Close

Get Open Positions

body = {
    'network': 'mainnet'
    }
response = b.futuresOpenPositions()
View Response
{'code': 200,
 'data': [{'avg_price': 19977.6,
           'factor': 100000000,
           'inst_id': 2,
           'lock': 0,
           'position': 0.001,
           'side': 0,
           'usdt_settled': 1}],
 'error': 'Open Positions',
 'status': 1}

Explanation of fields: avg_price -> Current average price inst_id -> Instrument ID lock -> Amount locked position -> Size of the position side -> Long/Short

Place Open Orders

posSide => 0/1 (Long/Short)

body = { 'inst_id': 2, 'rate': 19700, 'qnty': 0.0003, 'posSide': 0 # Going long 'network': 'mainnet' } response = b.futuresPlaceOpenOrder(body = body)
View Response
{'code': 200,
 'data': {'order_id': 152538},
 'error': 'Successfully placed order ',
 'status': 1}

Explanation of fields: order_id -> Order ID of the order

Cancel Open Orders

body = {
    'order_id': 152538,
    'network': 'mainnet'
    }
response = b.futuresCancelOpenOrder(body = body)
View Response
{'code': 412,
 'data': {'order_id': '152538'},
 'error': 'Successfully canceled open order',
 'status': 1}

Explanation of fields: order_id -> Order ID of the order

Place Close Orders

posSide => 0/1 (Long/Short)

body = { 'inst_id': 8, 'rate': 98000, 'qnty': 0.1, 'posSide': 0 # Going long 'network': 'mainnet' } response = b.futuresPlaceCloseOrder(body = body) print(response)
View Response
{'code': 200,
 'data': {'order_id': 153430},
 'error': 'Successfully placed order',
 'status': 1}

Explanation of fields: order_id -> Order ID of the order

Cancel Close Orders

body = {
    'order_id': 152538,
    'network': 'mainnet'
    }
response = b.futuresCancelCloseOrder(body = body)
print(response)
View Response
{'code': 412,
 'data': {'order_id': '152538'},
 'error': 'Successfully canceled close order',
 'status': 1}

Explanation of fields: order_id -> Order ID of the order

HTTP error status codes

HTTP error codes would be returned incase of any errors, the body will also cointain an error feild which will explain the cause of the error

Code Meaning
200 null -- requested action has been performed without any problems
400 Invalid Request -- Invalid request format
401 authentication -- Not authorised or invalid API key
403 Undefined -- this request is forbidden
404 Exchange not found -- Unable to find exchange
406 Coin name not supplied or not yet supported -- coin name applied is incorrect
409 parameter type not correct -- parameters entered is incorrect
412 Oops ! Cancellation failed. Something went wrong ! -- Unable to cancel order
413 volume asked not acceptable -- Desired volume is not within bounds
416 Oops ! Not sufficient balance to purchase currency -- wallet balance is not sufficient
417 Oops ! Order doesn't exist any more -- Order has alredy been deleted
428 Price seems Irregular from current market price. -- Entered price is more than current price
500 Problem with our servers, try again later
503 currently down for maintaince

bitbnspy's People

Contributors

atiprashant avatar dependabot[bot] avatar its-mohnish avatar mohnish-agrawal avatar sanket-buyhatke avatar sanket-k avatar sumit4613 avatar tanmesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bitbnspy's Issues

error while importing bitbnspy

hi I have installed bitbnspy from anaconda command prompt in windows10 using following:
pip3 install python-socketio
pip3 install bitbnspy

Installation was successful. When I am trying to import bitbnspy I am getting error:

(base) C:\Users\USER>python
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bitbnspy import bitbns
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bitbnspy'

Could you please advice how to resolve this error?

Endpoint for fee-rebates

Describe the enhancement

I would suggest to add a new endpoint to check the amount of fee rebate that users are getting from bitbns

How to get tickers data for the last n hours?

Hello All,

Is there a way to get tickers data (last traded price) for the last "n" hours? If yes, could someone please post the method to get thsi data?

Also, can we restrict the fetchTickers method to get the data for a specified coin? When I checked the source code, looks like fetchTickers is not accepting any parameters. Is there any other method to retrieve tickers data for a specific coin?

Thanks!

BTC/INR pair giving wrong Qty via api

Describe your environment

  • Operating system: Windows 10
  • Python Version: 3 above via conda platform

Describe the problem:

running this Api:
pd.json_normalize(bitbnsObj.getBuyOrderBook(BTC), "data", meta=["status", "error","code"])

Observed Results:

  • What happened?
    Output is coming as below:
    0
    dict
    2
    {'rate': 2666145.61, 'btc': 7050}
    1
    dict
    2
    {'rate': 2663113.45, 'btc': 87190000}
    2
    dict
    2
    {'rate': 2663069.89, 'btc': 19216500}
    3
    dict
    2
    {'rate': 2662923.18, 'btc': 7543600}
    4
    dict
    2
    {'rate': 2662518.18, 'btc': 26679500}
    5
    dict
    2
    {'rate': 2662454.75, 'btc': 16096000}
    6
    dict
    2
    {'rate': 2662453.99, 'btc': 43969700}
    7
    dict
    2
    {'rate': 2662164.37, 'btc': 4170200}
    8
    dict
    2
    {'rate': 2662144.51, 'btc': 8369799}
    9
    dict
    2
    {'rate': 2662027.59, 'btc': 7842000}
    10
    dict
    2
    {'rate': 2661978.69, 'btc': 32316200}
    11
    dict
    2
    {'rate': 2652240.89, 'btc': 18641647}
    12
    dict
    2
    {'rate': 2650352.7, 'btc': 3764}
    13
    dict
    2
    {'rate': 2649811.09, 'btc': 186252}
    14
    dict
    2
    {'rate': 2642000, 'btc': 301846}
  • What did you expect to happen?
    BTC Value - which is qty to be in range of 0.1289 onwards

please opine

Socket usages

Can you provide example on socket usage mentioned in README

KeyError: 'serverTime' while invoking bitbns method

Sample Code used

from bitbnspy import bitbns
key = '***********************'
secretKey = '**********************'
bitbnsObj = bitbns(key, secretKey)
print(bitbnsObj.getSellOrderBook('XRPUSDT'))

Error -

C:\Users\**********\PycharmProjects\bitbns\venv\Scripts\python.exe C:/Users/singha2/PycharmProjects/bitbns/test.py
Traceback (most recent call last):
  File "C:/Users/*********/PycharmProjects/bitbns/test.py", line 4, in <module>
    bitbnsObj = bitbns(key, secretKey)
  File "C:\Users\********\PycharmProjects\bitbns\venv\lib\site-packages\bitbnspy\bitbnspy.py", line 25, in __init__
    serverTime = int(response['serverTime'])
KeyError: 'serverTime'

Process finished with exit code 1

getTickerApi() giving error : AttributeError: 'str' object has no attribute 'pop'

While running the following code, it is giving error :

bitbnsObj = bitbns(key, secretKey)

bitbnsObj
Out[23]: <bitbnspy.bitbnspy.bitbns at 0x224b0b8b2b0>

bitbnsObj.getTickerApi( 'MATIC' )
Traceback (most recent call last):

  File "<ipython-input-24-17c6c2c9e69c>", line 1, in <module>
    bitbnsObj.getTickerApi( 'MATIC' )

  File "C:\anaconda\lib\site-packages\bitbnspy\bitbnspy.py", line 99, in getTickerApi
    req[key].pop('yes_price', None)

AttributeError: 'str' object has no attribute 'pop'

Module bitbns not present

import bitbnspy
help("bitbnspy")
Help on package bitbnspy:

NAME
bitbnspy

PACKAGE CONTENTS
bitbns
bitbnspy
main

FILE
c:\users\singha2\appdata\local\programs\python\python36\lib\site-packages\bitbnspy_init_.py

from bitbns import bitbnsApi
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'bitbns'

Placing orders - Irregular price problem

Coin LRC have been showing irregular price problem.

Steps to reproduce:

Place order for the coin mentioned above

Observed Results:

  • Order not placed, produces irregular price problem
  • Order should have been placed

logs, a copy-pastable example

{
'data': None,
'status': 0,
'error': 'Price seems Irregular from current market price. 18.180279665397926',
'code': 428
}

coins returning not supported error

Describe the problem:

Three tickers - WBTC, ZEBI and PHB have been returning coins not supported error.

Steps to reproduce:

  1. Use any function on the three tickers mentioned above

Observed Results:

  • Returned coin not supported error
  • Expected it to return a valid response

Relevant code exceptions or logs

Code Sample, a copy-pastable example

bitbnsObj.getBuyOrderBook('WBTC') #Could be any function except getTickerApi

logs, a copy-pastable example

{
 'data': '', 
 'status': 0, 
 'msg': 'coin name not supplied', 
 'code': 406
} 

Bitbnspy Installation issue

team,

did step 1:
Installation
sudo -H pip3 install python-socketio[client]
pip3 install bitbnspy

Step 2 ran this in spyder - python:

and got error of: "ModuleNotFoundError: No module named 'bitbnspy'"

please help how to resolve this

thanks
sukhwant

code used to run on spyder:

from bitbnspy import bitbns
key = 'yourKey'
secretKey = 'yourSecretKey'
bitbnsObj = bitbns(key, secretKey)
print(bitbnsObj.getSellOrderBook('XRPUSDT'))

adding market order functionality

Describe the enhancement

Implementation of market order via API trading, would help place orders immediately and ensures the user is able to enter/exit their position irrespective of market condition.

Currently this is achieved by calling two functions (example for exiting BTC/USDT position):
bitbnsObj.getSellOrderBook('BTCUSDT')
bitbnsObj.placeOrders({'symbol': 'BTCUSDT', 'side': 'SELL', 'quantity': 0.1, 'rate': 33000})

this action could be achieved by just 1 action by user:
bitbnsObj.placeOrders({'symbol': 'BTCUSDT', 'side': 'SELL', 'type':'MARKET', 'quantity': 0.1})
note: rate is not considered in this case.

Not able to get USDT withdrawal history with api

It is not possible to get the withdrawal history for USDT

>BITBNS_API.withdrawHistory("USDT", page=0)
Out[1]: {'data': [], 'status': 1, 'error': None, 'code': 204}

There should be data, and code = 200
Does this require a separate code per withdrawal network?

Thank you

Incorrect quantity for ETN - using listExecutedOrders

Describe your environment

  • Operating system: mac os - 10.14.5
  • Python Version: 3.7.7

Describe the problem:

symbol: ETN
quantity: 500

after placing an order for 500 ETN, while checking for executed orders the amount field the returned amount was showing 5000 ETN (10x more than the originally placed quantity),
this issue seems to be only with this endpoint as on bitbns website the quantity was 500 ETN.

Steps to reproduce:

  1. place order for ETN
  2. fetch executed order using listExecutedOrders function

Observed Results:

  • What happened?
    • the quantity returned by endpoint is 5000 ETN
  • What did you expect to happen?
    • the quantity returned by endpoint is 500 ETN

Relevant code exceptions or logs

Code Sample, a copy-pastable example

# to place an order
side = 'BUY'
symbol = 'ETN'
min_amount = 380 
rate = 0.755
quantity = (min_amount / rate)
print(bitbnsObj.placeOrders({"symbol":symbol,"side":side,"quantity":quantity,"rate":rate}))

# to fetch executed order for ETN
symbol = 'ETN'
since_date = '2021-01-01T00:00:00Z'
page_no = 0
print(bitbnsObj.listExecutedOrders(symbol, since=since_date, pageNo=page_no))

logs, a copy-pastable example

// response for placing order
{'data': 'Successfully placed bid to purchase currency', 'status': 1, 'error': None, 'id': 549056, 'code': 200}

// response for fetch executed order for ETN
{'code': 200,
 'data': [{'amount': 3750,
           'crypto': 3750,
           'date': '2021-06-01T06:19:16.000Z',
           'del_btc': 3750,
           'del_inr': 2.63,
           'delh_btc': 0,
           'delh_inr': -283.84,
           'factor': 10,
           'fee': 0.71,
           'id': '547003',
           'rate': '0.755',
           'type': 'ETN Buy order executed',
           'typeI': 7,
           'unit': 'ETN'},
          {'amount': 1250,
           'crypto': 1250,
           'date': '2021-06-01T06:19:16.000Z',
           'del_btc': 1250,
           'del_inr': 0,
           'delh_btc': 0,
           'delh_inr': -94.62,
           'factor': 10,
           'fee': 0.24,
           'id': '547003',
           'rate': '0.755',
           'type': 'ETN Buy order executed',
           'typeI': 7,
           'unit': 'ETN'}],
 'error': None,
 'status': 1}

A snippet from the exchange to show the actual volume:
image

API trading issue

Describe your environment

  • Operating system: ____
  • Python Version: _____ (python -V)

Describe the problem:

unable to place order using bitbns API on bituniverse
it shows the following error
Error_in_grpc_call
Explain the problem you have encountered

Steps to reproduce:




Observed Results:

  • What happened?unable to place order using bitbns API on bituniverse
    it shows the following error
    Error_in_grpc_call
  • What did you expect to happen?unable to place order using bitbns API on bituniverse
    it shows the following error
    Error_in_grpc_call

Relevant code exceptions or logs

Code Sample, a copy-pastable example

# Your code here

logs, a copy-pastable example

// paste your log here

response json dont have an attribute called servertime

Describe your environment

  • Operating system: ____
  • Python Version: _____ (python -V)

Describe the problem:

Explain the problem you have encountered

Steps to reproduce:




Observed Results:

  • What happened?
  • What did you expect to happen?

Relevant code exceptions or logs

Code Sample, a copy-pastable example

# Your code here

logs, a copy-pastable example

// paste your log here

swap order is not working

HTTPSConnectionPool(host='api.bitbns.com', port=443): Read timed out. (read timeout=30)
{'data': None, 'status': 0, 'error': 'Invalid Non-JSON response - swapLimitINR'}

i got above error when i place swap order
this command i used
bitbnsObj.swapLimitINR({'coin': 'BTC', 'quantity':0.000005, 'rate': 3358000, 'type': 0})

No data is returned for a few pairs using - currentCoinBalance

Describe your environment

  • Operating system: macos - 10.14.5
  • Python Version: 3.7.10

Describe the problem:

currentCoinBalance returns no data for recently added pairs.

this issue is observed in USDC, BUSD, RUNE, SOL, SAND, MANA etc (while opening issue, there were most recently added)

Steps to reproduce:

  1. fetch current coin balance via currentCoinBalance function.

Observed Results:

  • What happened?
    • the data field returns empty value.
  • What did you expect to happen?
    • the data field to return 0 balance.

Relevant code exceptions or logs

Code Sample, a copy-pastable example

# Your code here
print(bitbnsObj.currentCoinBalance('BUSD'))

logs, a copy-pastable example

{'code': 200, 'data': {}, 'error': None, 'status': 1}

Bracket orders - listOpenBracketOrders shows completed orders

Describe the problem:

A completed bracket order is shown in the response when listOpenBracketOrders is passed as type for getOrders

Observed Results:

  • Completed orders showing in listOpenBracketOrders
  • Hoped to only see my open bracket orders

Relevant code exceptions or logs

Code Sample, a copy-pastable example

bitbnsObj.getOrders({'side': 'listOpenBracketOrders', 'symbol': 'XRP', 'page': 0})

logs, a copy-pastable example

{
 'data': [
    {
       'entry_id': 44912,
       'type': 0, 
       'target_rate': 100, 
       'limit_rate': 81, 
       'status': 2, 
       'quantity': 0.25, 
       'coin': 1, 
       'trail': 0.02, 
       'order_id': 10865255, 
       'sl_id': 126268, 
       'entry_rate': 83, 
       'tried': 0, 
       'profit': 0, 
       'amt_total': 0
      },
       .
       .
   ]
}

platformStatus endpoint does not return all tickers

Describe your environment

  • Operating system: windows
  • Python Version: python-3.8.8

Describe the problem:

platformStatus only returns status for a few tickers

Steps to reproduce:

  1. load bitbns API into an object
  2. call platformStatus

Observed Results:

  • Returned status for only 25 tickers
  • Expected to return status for around 150 tickers

Relevant code exceptions or logs

Code Sample, a copy-pastable example

API_KEY, SECRET_KEY = "####", "####"
bitbnsObj = bitbns(API_KEY, SECRET_KEY)
bitbnsObj.platformStatus()

logs, a copy-pastable example

{'code': 200,
 'data': {'ADA': {'status': 1},
  'BCH': {'status': 1},
  'BTC': {'status': 1},
  'DASH': {'status': 1},
  'DGD': {'status': 1},
  'ETH': {'status': 1},
  'GAS': {'status': 1},
  'LSK': {'status': 1},
  'LTC': {'status': 1},
  'NEO': {'status': 1},
  'OMG': {'status': 1},
  'ONT': {'status': 1},
  'POLY': {'status': 1},
  'POWR': {'status': 1},
  'QTUM': {'status': 1},
  'REP': {'status': 1},
  'TEL': {'status': 1},
  'TRX': {'status': 1},
  'USDT': {'status': 1},
  'VET': {'status': 1},
  'WAVES': {'status': 1},
  'XLM': {'status': 1},
  'XRP': {'status': 1},
  'XVG': {'status': 1},
  'ZRX': {'status': 1}},
 'error': None,
 'status': 1}

Servertime Key Error

  • Operating system: Windows
  • Python Version: 3.8.8
  • Bitbnspy Version: 0.3.1

When I try to instantiate Bitbns Object with my API Key and Secret, it fails with server time key error. I know this issue had already been raised but it was closed without any solution. This same issue has happened to me before but it will usually automatically get resolved in a few minutes. This time around it has been persisting for 2-3 days.

from bitbnspy import bitbns
key = ''
secretKey = '
****'
bitbnsObj = bitbns(key, secretKey)

C:\ProgramData\Anaconda3\lib\site-packages\bitbnspy\bitbns.py in init(self, apiKey, apiSecretKey, timeout)
29 response = self.connectionsAdaptor.get('https://api.bitbns.com/api/trade/v1/getServerTime', headers=headers)
30 response = response.json()
---> 31 serverTime = int(response['serverTime'])
32 localTime = int(time.time() * 1000.0)
33 self.timeOffset = localTime - serverTime

KeyError: 'serverTime'

Api limits

How can I get higher api rate limits? 100 write calls is not enough

sockets issue, 'error': 'some error in get req'

Facing issue for sockets.
image
image attached above.
code: `from bitbnspy import bitbns
bitbnsObj = bitbns.publicEndpoints()

print(bitbnsObj.fetchTickers())

data = bitbnsObj.getOrderBookSocket(coinName = 'BTC', marketName = 'INR')
print("datahere===> ", data)
socket = data['socket']
@socket.event
def news(data):
print(data)`

ID for margin orders

Describe the problem:

When placing margin orders, the response does not return a ID.

Observed Results:

  • Placed margin order - did not get an ID in response
  • I recommend that an order ID be returned in JSON response

Relevant code exceptions or logs

Code Sample, a copy-pastable example

API_KEY, SECRET_KEY = "####", "####"
bitbnsObj = bitbns(API_KEY, SECRET_KEY)
bitbnsObj.placeMarginOrders({'symbol': 'BTC', 'side': 'placeOrder', 'type': 'BORROW', 'qnty': 0.00102, 'days': 1, 'rate': 0.000001})

logs, a copy-pastable example

{
 'status': 1, 
 'error': 'Successfully placed borrow order for Margin trading.', 
 'code': 200
}

How to execute a coin in USDT market via api

Describe your environment

  • Operating system: Windows 10
  • Python Version: 3.8.3

Your question

how to execute a coin in USDT market via api

import pandas as pd
import datetime as dt
import time
import numpy as np
import http.client
import json
from bitbnspy import bitbns
from BitbnsTradeSuggestions import tradexecute

key = ''
secretKey = ''
bitbnsObj = bitbns(key, secretKey)


tdticker1 = 'XRP_USDT'
tdtickerqty1 = 146.43
tdtickerprice1 = 0.6829

tdticker2 = 'XRP'
tdtickerqty2 = 146.43
tdtickerprice2 = 51

bitbnsObj.placeBuyOrder(tdticker1, tdtickerqty1, tdtickerprice1) 
time.sleep(5)
bitbnsObj.placeSellOrder(tdticker2, tdtickerqty2, tdtickerprice2)

Pleas note: Trade does not get executed, even if USDT of $100 is in the wallet. Rates mentioned in the Ask to buy and bid to sell are present in the order book

Please opine

AttributeError

AttributeError: type object 'bitbns' has no attribute 'publicEndpoints'

Describe your environment

  • Operating system: ubuntu
  • Python Version: 3.8.8 (python -V)

Your question

AttributeError: type object 'bitbns' has no attribute 'publicEndpoints'

from bitbnspy import bitbns
bitbnsObj = bitbns.publicEndpoints()
print(bitbnsObj.fetchTickers())

Order status for stop loss orders

Describe the problem:

orderStatus function does not retrieve data for stop loss orders

Steps to reproduce:

  1. Place a stop loss order
  2. Use the id to check for order status

Observed Results:

  • Response with error field shows - "Nothing to show"
  • Response should show my open stop orders

Relevant code exceptions or logs

Code Sample, a copy-pastable example

bitbnsObj.buyStopLoss('USDT', 1, 80, 79)
bitbnsObj.orderStatus('USDT', 147718)

logs, a copy-pastable example

{
 'data': 'Successfully placed order for stop loss buy', 
 'status': 1, 
 'error': None, 
 'id': 147718, 
 'code': 200
}
{
 'data': [], 
 'status': 0, 
 'error': 'Nothing to show', 
 'code': 417
}

Shiba Inu Place Buy Order

Describe your environment

  • Operating system: Linux
  • Python Version: 3.8.2

Describe the problem:

Unable to place Buy Order on SHIBA INU coin worth more than around 50$. Getting "volume asked not acceptable" response with a 413 error code.
However, for a smaller SHIB volume, it places orders successfully

Relevant code exceptions or logs

Code Sample, a copy-pastable example

API_KEY, SECRET_KEY = "####", "####"
bitbnsObj = bitbns(API_KEY, SECRET_KEY)
bitbnsObj.placeBuyOrder('SHIB', 5000000, 0.001)

logs, a copy-pastable example

{
'data': '', 'status': 0, 'error': 'volume asked not acceptable', 'code': 413
}

Not supported coins for placeOrders

Describe the problem:

Coins BNB/USDT, BNSD/USDT, FET/USDT & FUN/USDT are returning not supported coins as response for placeOrders for order types - normal and stoploss

Steps to reproduce:

  1. Run placeOrders function with just rate parameter and/or t_rate parameter set

Observed Results:

  • Response code 406 - Coin not supported or name not supplied error
  • Should have placed order succesfully

Relevant code exceptions or logs

Code Sample, a copy-pastable example

bitbnsObj.placeOrders({'symbol': 'BNB_USDT', 'side': 'BUY', 'quantity': 0.01, 'rate': 290})

logs, a copy-pastable example

{
 'data': None, 
 'status': 0, 
 'error': 'Coin Type Not Valid or Not Supported Yet!!', 
 'code': 406
}

old/changed coins

Describe the enhancement

Coins VEN, RPX and PUNDIX have changed their names while KSM, REN, UMA, AMPL, WNXM & SRM is not there on the website
I would suggest removing them from the response of getTickerApi()

Error code 200 - while getting Bid/ask for multiple coins

Describe your environment

  • Operating system: Win 10
  • Python Version: _____ 3.8.3

Your question

Get error code 200, while running a loop for 10 coins

import pandas as pd
import http.client
import json
import requests
from bitbnspy import bitbns

# BNS Private Keys
key = ''
secretKey = ''
bitbnsObj = bitbns(key, secretKey)


#Get Tickers
tickerdf = pd.read_excel (r'C:\Documents\Crptos\StaticData.xlsx', sheet_name= 'BNS') 
    
    
for index,row in tickerdf.iterrows():
    
    ticker1 = row['BNSTicker']
     # -------------------------------------------get the order book for specific pair
    
    #get sell/ask orderbook
    data = bitbnsObj.getSellOrderBook(ticker1)
    CoinBuy = pd.json_normalize(data, "data", meta=["status", "error","code"])

    #get Buy/bid orderbook
    data = bitbnsObj.getBuyOrderBook(ticker1)
    CoinSell = pd.json_normalize(data, "data", meta=["status", "error","code"])

    time.sleep(10)

Please advise solution, as i dont want to use time.sleep function and sometimes, it still gives error in fetching data

Ticker list is here:

BTCUSDT
ETHUSDT
XRPUSDT
ADAUSDT
TRXUSDT
LTCUSDT
BCHUSDT

API allows to trade CPX

Describe your environment

  • Operating system: windows
  • Python Version: 3.8.8

Describe the problem:

CPX has been delisted from the marketplace. However, we can still get buy & sell order book, use getTickerApi, place stoploss orders and cancelOrders.

Steps to reproduce:

  1. Load the bitbns obj in python
  2. Run API functions for CPX

Observed Results:

  • I could get info. on CPX and place orders for it
  • It has been delisted

Relevant code exceptions or logs

Code Sample, a copy-pastable example

API_KEY, SECRET_KEY = "####", "####"
bitbnsObj = bitbns(API_KEY, SECRET_KEY)
print(bitbnsObj.getTickerApi("CPX"))
print(bitbnsObj.buyStopLoss("CPX", 200, 0.35, 0.3))
print(bitbnsObj.cancelOrder("CPX", 47996))

logs, a copy-pastable example

{
 'CPX': 
   {'highest_buy_bid': 0.35, 
    'lowest_sell_bid': 0.36, 
    'last_traded_price': 0.36
  }
}
{
 'data': 'Successfully placed order for stop loss buy', 
 'status': 1, 
 'error': None, 
 'id': 147703, 
 'code': 200
}
{
 'data': 'Successfully cancelled the order', 
 'status': 1, 
 'error': None, 
 'code': 200
}

Placing orders - Irregular price problem

Describe the problem:

Coins BCHSV, DENT, LET, CLOAK, BTT have been showing irregular price problem.

Steps to reproduce:

  1. Place order for any of the coins mentioned above

Observed Results:

  • Order not placed, produces irregular price problem
  • Order should have been placed

Relevant code exceptions or logs

Code Sample, a copy-pastable example

#Actual market price during the posting of this issue was 12800
bitbnsObj.placeBuyOrder('BCHSV', 0.0043, 11500)

logs, a copy-pastable example

{
 'data': None, 
 'status': 0, 
 'error': 'Price seems Irregular from current market price. 31974.284532737227', 
 'code': 428
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.