### Installing Bitbns Python API Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This command installs the `bitbnspy` library using pip, the Python package installer. It is the first step to set up the Bitbns API wrapper in your Python environment, ensuring all necessary dependencies are met. ```Shell pip3 install bitbnspy ``` -------------------------------- ### Placing a New Open Order in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This example shows how to place a new open order on the futures market. It requires the instrument ID, desired rate, quantity, position side (0 for Long, 1 for Short), and the network. ```Python 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) ``` -------------------------------- ### Listing Python Project Dependencies Source: https://github.com/bitbns-official/bitbnspy/blob/master/requirements.txt This snippet provides a list of Python packages and their exact versions, typically found in a `requirements.txt` file. These dependencies are crucial for ensuring the project runs correctly and consistently across different environments. To install these, one would typically use `pip install -r requirements.txt`. ```Python bidict==0.21.2 certifi==2021.5.30 chardet==4.0.0 idna==2.10 python-engineio==4.2.0 python-socketio==5.3.0 requests==2.25.1 urllib3==1.26.5 websocket-client==1.1.0 ``` -------------------------------- ### Getting All Ongoing FIPs - Bitbns API - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves a list of all Fixed Income Plans (FIPs) that are currently ongoing for the user. It provides details about active investments and their current status. ```Python bitbnsObj.getOngoingFIP() ``` -------------------------------- ### Retrieving All Supported Swap Coins (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves a list of all cryptocurrencies currently supported for swap operations on the Bitbns platform. It calls the `swapCoinList` method on the `bitbnsObj` to get this information. ```Python bitbnsObj.swapCoinList() ``` -------------------------------- ### Getting API Usage Status - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to query the current API usage status, providing details on read and write limits, as well as the number of requests used. It helps in monitoring API rate limits. ```Python bitbnsObj.getApiUsageStatus() ``` -------------------------------- ### Getting Platform Status - Bitbns API (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to check the live status of various cryptocurrencies on the Bitbns platform. It calls the `platformStatus` method, which returns an object indicating whether each coin is currently active on the exchange. ```Python bitbnsObj.platformStatus(); ``` -------------------------------- ### Getting Executed Orders - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to retrieve a list of executed orders for a specified symbol. It allows filtering by a `since` date and pagination using `pageNo`. The `symbol` parameter specifies the trading pair (e.g., 'EOSUSDT'). ```Python 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) ``` -------------------------------- ### Getting Server Time - cURL Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This cURL command allows fetching the current server timestamp from the Bitbns API. It requires an API key in the `X-BITBNS-APIKEY` header for authentication. The response includes the `serverTime` in milliseconds. ```cURL curl -H "X-BITBNS-APIKEY: API-KEY" -X GET 'https://api.bitbns.com/api/trade/v1/getServerTime' ``` -------------------------------- ### Getting Max Allowed Open Positions in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This code snippet queries the maximum number of open positions allowed for a specific instrument. It requires the instrument ID (`inst_id`) and the network to be specified in the request body. ```Python body = { 'inst_id': 1, 'network': 'mainnet' } response = b.futuresMaxOpenPos(body = body) ``` -------------------------------- ### Getting Order Status - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to check the status of a specific order using its `order id` and the `symbol` of the cryptocurrency. The `orderStatus` method returns details about the order's current state, volume, rate, and timestamp. ```Python bitbnsObj.orderStatus('BTC', '4221') 4221 -> order id ``` -------------------------------- ### Subscribing to Live Ticker Data via Socket (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to connect to a WebSocket to receive real-time ticker data for a specified market. It utilizes `getTickerSocket` and includes event handlers for `ticker` (receiving data) and `disconnect` events. You can pass 'USDT' as `marketName` to get ticks for the USDT market. ```Python data = bitbnsObj.getTickerSocket(marketName = 'INR') socket = data['socket'] @socket.event def ticker(data): print(data) @socket.event def disconnect(): print("Disconnected") ``` -------------------------------- ### Get Open Margin Market Orders - Bitbns API (JavaScript) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves open margin market orders from all users. It allows filtering by 'type' (LEND or BORROW) and 'symbol'. The 'side' parameter is 'listMarketOrders'. The response includes a 'data' array, where each object contains 'btc' (volume), 'days' (duration), and 'rate' (interest rate) for available orders. ```JavaScript bitbnsObj.listMarginMarketOrders({'type': 'BORROW', 'side': 'listMarketOrders', 'symbol': 'XRP'}) ``` -------------------------------- ### Retrieving Crypto Coin Address With Tag - Bitbns Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to get the deposit address and the necessary tag for cryptocurrencies that require a tag for valid deposits. The function accepts the coin symbol and provides both the token address and the associated tag. ```Python bitbnsObj.getCoinAddress('XLM') ``` -------------------------------- ### Transferring USDT from Pool Account - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet facilitates the transfer of USDT (Tether) from a specified pool account to a target user's account. It requires `target_uid` and the `amount` of USDT to be transferred in the request body. No example response is provided for this operation. ```Python b.transferUSDTFromPoolAccount(body = { 'target_uid' : 64873278, 'amount' : 50, }) ``` -------------------------------- ### Getting Crypto Deposit History - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to fetch the deposit history for a specific crypto asset. The depositHistory method takes the asset symbol and an offset (e.g., 0 for the latest). The response details include transaction type, amount, date, unit, and delta changes in wallet balances. ```Python bitbnsObj.depositHistory('BTC', 0) ``` -------------------------------- ### Transferring Cryptocurrency from Pool Account - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet enables transferring a specific cryptocurrency from a pool account to a target user's account. It requires `target_uid`, `amount`, and `coin_name` (e.g., 'GARI') in the request body. The example response illustrates a scenario of insufficient permissions for the operation. ```Python body = { 'target_uid' : 64873278, 'amount' : 1, 'coin_name': 'GARI' } b.transferCoinFromPoolAccount(body = body) ``` ```JSON { "status": 0, "error": "Insufficient permission for this operation 0", "code": 416 } ``` -------------------------------- ### Getting Current Crypto Asset Balance - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to retrieve the current balance of a specified crypto asset using the currentCoinBalance method. Inputting "INR" will list your INR balance. The response includes inorderBTC (volume in order book) and availableorderBTC (volume in wallet). ```Python bitbnsObj.currentCoinBalance('BTC') ``` -------------------------------- ### Get Pending Margin Orders - Bitbns API (JavaScript) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet fetches a list of pending margin orders for the authenticated user. It accepts 'page' for pagination and 'symbol' for filtering. The 'side' parameter is 'listMarginPending'. The response contains a 'data' array with order details such as 'entry_id', 'btc' (volume), 'days', 'time', 'type' (0 for lend, 1 for borrow), 'status', and 'rate'. ```JavaScript bitbnsObj.listMarginPending({'page': 1, 'side': 'listMarginPending', 'symbol': 'USDT'}) ``` -------------------------------- ### Getting Crypto Withdrawal History - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to retrieve the withdrawal history for a given crypto asset. The withdrawHistory method requires the asset symbol and an offset. The response provides details such as transaction type, amount, unit, transaction hash, fee, destination address, and status. ```Python bitbnsObj.withdrawHistory('XRP', 0) ``` -------------------------------- ### Getting Latest Price for All Symbols - Bitbns API (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to retrieve the latest ticker information for all available cryptocurrency symbols on the Bitbns platform. By calling `getTickerApi` with an empty string, the API returns comprehensive price data for every listed asset, including highest buy bid, lowest sell bid, and last traded price. ```Python bitbnsObj.getTickerApi('') ``` -------------------------------- ### Get Executed Margin Orders - Bitbns API (JavaScript) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves a list of executed margin orders for the authenticated user. It allows filtering by 'page' number, 'type' (LEND or BORROW), and 'symbol'. The 'side' parameter is 'listMarginExecuted'. The response includes a 'data' array with details like 'entry_id', 'worth_required', 'worth_current', 'margin_taken', 'expiry', 'margin_to_return', 'days', 'interest', and 'coin'. ```JavaScript bitbnsObj.listMarginExecuted({'page': 1, 'side': 'listMarginExecuted', 'type': 'BORROW', 'symbol': 'USDT'}) ``` -------------------------------- ### Getting Latest Price for Multiple Symbols - Bitbns API (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to fetch the latest ticker information for multiple cryptocurrency symbols simultaneously. By passing a comma-separated string of symbols, users can retrieve the highest buy bid, lowest sell bid, and last traded price for each specified asset. ```Python bitbnsObj.getTickerApi('BTC,ETH') ``` -------------------------------- ### Getting Latest Price for a Single Symbol - Bitbns API (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves the latest ticker information for a single cryptocurrency symbol, such as BTC. It provides details like the highest buy bid, lowest sell bid, and last traded price. Providing an invalid crypto name will result in 'undefined' as the price. ```Python bitbnsObj.getTickerApi('BTC') ``` -------------------------------- ### Placing Orders on Bitbns USDT Market (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to place various types of orders (simple, stop-loss, bracket) on the Bitbns USDT market using the `placeOrders` method. It requires parameters such as `symbol`, `side` (BUY/SELL), `quantity`, `rate`, and optionally `target_rate`, `t_rate`, and `trail_rate` depending on the order type. ```Python bitbnsObj.placeOrders({'symbol': 'TRX_USDT', 'side': 'BUY', 'quantity': 40, 'rate': 4, 'target_rate': 5, 't_rate': 3.5, 'trail_rate': .01}) ``` -------------------------------- ### Initializing Bitbns Private Endpoints in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This code initializes the `bitbns` object with your API key and secret key, enabling access to private endpoints. It then demonstrates fetching the sell order book for 'XRPUSDT', which requires authentication and specific permissions. ```Python from bitbnspy import bitbns key = 'yourKey' secretKey = 'yourSecretKey' bitbnsObj = bitbns(key, secretKey) print(bitbnsObj.getSellOrderBook('XRPUSDT')) ``` -------------------------------- ### Enrolling for a FIP - Bitbns API - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to enroll in a specific Fixed Income Plan (FIP) by providing its unique ID and the desired investment amount. The `fip_id` parameter identifies the target FIP, and `amt` specifies the volume of the coin to invest. ```Python bitbnsObj.enrollForFIP({'fip_id': 441, 'amt': 10}) ``` -------------------------------- ### Placing Orders (Bracket, Stoploss, Simple) - Python API V2 Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates placing various types of orders (simple, stop-loss, or bracket) using the `placeOrders` method in API V2. It accepts a dictionary of parameters including `symbol`, `side` (BUY/SELL), `quantity`, `rate`, and optional parameters like `target_rate`, `t_rate` (trigger rate), and `trail_rate` for advanced order types. ```Python bitbnsObj.placeOrders({'symbol': 'XRP', 'side': 'BUY', 'quantity': 40, 'rate': 4, 'target_rate': 5, 't_rate': 3.5, 'trail_rate': .01}) ``` -------------------------------- ### Placing Limit Swap Order in USDT Market (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates placing a limit order for a swap operation in the USDT market. It calls the `swapLimitUSDT` method with a dictionary specifying the `coin`, `quantity`, `rate`, and `type` (0 for buy, 1 for sell) for the order. ```Python bitbnsObj.swapLimitUSDT({'coin': 'BTC', 'quantity':0.000005, 'rate': 430000, 'type': 1}) type => 0 for buy, 1 for sell ``` -------------------------------- ### Placing Market Swap Order in USDT Market (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to place a market order for a swap in the USDT market. It calls `bitbnsObj.swapMarketUSDT` with a dictionary including `coin`, `quantity`, and `type` (0 for buy, 1 for sell). Orders can be placed by specifying either `quantity` or `volume`. ```Python 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 ``` -------------------------------- ### Placing Buy Order - Bitbns Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to place a standard buy order for a specific cryptocurrency. It requires the cryptocurrency symbol, the quantity to buy, and the desired rate. The function confirms successful order placement and returns a unique order ID. ```Python bitbnsObj.placeBuyOrder('XRP', 200, 25) ``` -------------------------------- ### Presubscribing for an FIP - bitbnspy Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to presubscribe a user for a Fixed Income Plan (FIP) using its ID and the desired investment amount. The request requires the FIP ID and the amount to be invested. ```Python bitbnsObj.preSubscribeForFIP({'fip_id': 614, 'amt': 10}) ``` -------------------------------- ### Initializing Bitbns Public Endpoints in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to instantiate the `bitbns` object for accessing public API endpoints without requiring API keys. It then calls `fetchTickers()` to retrieve current ticker information, showcasing a basic public data retrieval operation. ```Python from bitbnspy import bitbns bitbnsObj = bitbns.publicEndpoints() print(bitbnsObj.fetchTickers()) ``` -------------------------------- ### Placing Market Swap Order in INR Market (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to place a market order for a swap in the INR market. It uses `bitbnsObj.swapMarketINR` with a dictionary containing `coin`, `quantity`, and `type` (0 for buy, 1 for sell). Orders can be placed by specifying either `quantity` or `volume`. ```Python 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 ``` -------------------------------- ### Placing Limit Swap Order in INR Market (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to place a limit order for a swap operation in the INR market. It uses the `swapLimitINR` method, passing a dictionary with `coin`, `quantity`, `rate`, and `type` (0 for buy, 1 for sell) to define the order. ```Python bitbnsObj.swapLimitINR({'coin': 'BTC', 'quantity':0.000005, 'rate': 3358000, 'type': 1}) type => 0 for buy, 1 for sell ``` -------------------------------- ### Placing Market Order by Quantity - Bitbns Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to place a market order based on a specified quantity. It requires the coin symbol, market (e.g., INR/USDT), order side (BUY/SELL), and the exact quantity to buy or sell. The function executes a market order for the given volume. ```Python bitbnsObj.placeMarketOrderQuantity('BTC', 'INR', 'BUY', 0.00001) ``` -------------------------------- ### Placing Market Order by Cost - Bitbns Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to place a market order based on a specified cost. It takes the coin symbol, market (e.g., INR/USDT), order side (BUY/SELL), and the total cost as parameters. The function executes a market order to buy or sell coins worth the specified amount. ```Python bitbnsObj.placeMarketOrder('BTC', 'INR', 'BUY', 100) ``` -------------------------------- ### Placing Margin Orders on Bitbns (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet explains how to place margin orders (borrow or lend) using the `placeMarginOrders` method. Key parameters include `symbol`, `side` ('placeOrder'), `type` ('BORROW' or 'LEND'), `qnty` (quantity), `days` (duration), `rate`, and an optional `renew` flag (0: don't renew, 1: renew principal, 2: renew principal + interest). ```Python bitbnsObj.placeMarginOrders({'symbol': 'USDT', 'side': 'placeOrder', 'type': 'LEND', 'qnty': 40, 'days': 1, 'rate': 0.0055}) ``` -------------------------------- ### Listing Open Orders - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to list all open orders for a specified crypto asset. The listOpenOrders method takes the asset symbol as a parameter. The response includes details for each open order, such as entry ID, amount, rate, time, type, and status. ```Python bitbnsObj.listOpenOrders('BTC') ``` -------------------------------- ### Fetching All Presubscribed FIPs - bitbnspy Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to retrieve a list of all Fixed Income Plans (FIPs) that the current user has presubscribed to. It returns details such as the invested amount, entry ID, FIP ID, and status. ```Python bitbnsObj.fetchMySubscriptions() ``` -------------------------------- ### Placing Sell Order - Bitbns Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to place a sell order for a specific cryptocurrency. It requires the cryptocurrency symbol, the quantity to sell, and the desired rate. The function confirms successful order placement and returns a unique order ID. ```Python bitbnsObj.placeSellOrder('XRP', 200, 25) ``` -------------------------------- ### Creating New Partner Account in Bitbns Python API Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to create a new user account via the Bitbns partner endpoints. It requires a `body` dictionary containing the user's `email`, `phone`, `pass`word, `dormant` status, and `country` code. Access to partner APIs requires whitelisting by Bitbns. ```Python body = { 'email' : 'test_bns34324@gmail.com', 'phone' : '8676857590', 'pass' : 'hd237ydkldl', 'dormant' : 1, 'country' : 0 } b.createNewAccount(body = body) ``` -------------------------------- ### Placing Buy Stop Loss Order - Bitbns Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to place a buy stop loss order. It requires the cryptocurrency symbol, the quantity, the desired rate, and the trigger rate at which the order should become active. The function confirms the successful placement of the stop loss order. ```Python bitbnsObj.buyStopLoss('XRP', 40, 24, 24.5) ``` -------------------------------- ### Creating New Payment Gateway Order - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet creates a new payment gateway order for facilitating crypto payments. It requires the `merchant_id`, the `amt` (amount), the `coin` (e.g., "USDT"), a unique client `refId`, and the customer's `email`. Upon successful creation, the API returns an `order_id` and a `url` for the payment page. ```Python body = { 'merchant_id': 1, 'amt': 25, 'coin': "USDT", 'refId': "ORDER_CLIENT123487134", 'email': 'xyz@buyhatke.com' } response = b.createNewPGOrder(body = body) ``` -------------------------------- ### Fetching Payment Gateway Order Status - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet, found under the 'Fetch Payment Gateway Order' section, uses `b.createNewPGOrder` with `merchant_id` and `order_id` parameters. While the method name suggests creation, the context implies an attempt to retrieve the status of an existing payment gateway order. The expected output includes detailed order status information, such as `status` (0: pending, -1: declined, 1: paid) and `errMsg`. ```Python b.createNewPGOrder(body = { 'merchant_id': 1, 'order_id': 21 }) ``` -------------------------------- ### Placing Close Futures Order in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to place a close order for a futures position on the Bitbns platform. It defines a `body` dictionary containing the `inst_id` (instrument ID), `rate` (price), `qnty` (quantity), `posSide` (position side, 0 for long), and `network`. The `futuresPlaceCloseOrder` method is then invoked with this body, and the response is printed. ```Python body = { 'inst_id': 8, 'rate': 98000, 'qnty': 0.1, 'posSide': 0, # Going long 'network': 'mainnet' } response = b.futuresPlaceCloseOrder(body = body) print(response) ``` -------------------------------- ### Subscribing to Live Order Book Data via Socket (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to establish a WebSocket connection to receive live order book updates for a specified coin and market. It uses `getOrderBookSocket` and defines event handlers for `news` (receiving data) and `disconnect` events. You can specify 'ALL' for `coinName` or 'USDT' for `marketName`. ```Python data = bitbnsObj.getOrderBookSocket(coinName = 'BTC', marketName = 'INR') socket = data['socket'] @socket.event def news(data): print(data) @socket.event def disconnect(): print("Disconnected") ``` -------------------------------- ### Listing All FIPs - Bitbns API - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to retrieve a list of all Fixed Income Plans (FIPs) from the Bitbns platform. It allows filtering by type, such as 'ONGOING', 'COMPLETE', 'UPCOMING', or 'DISTRIBUTED', to narrow down the results. ```Python bitbnsObj.listAllFIP({'type': 'ONGOING'}) ``` -------------------------------- ### Retrieving Sell Order Book (BTC) - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to fetch the sell order book for Bitcoin (BTC) using the `getSellOrderBook` method. It returns a list of active sell orders with their respective rates and volumes. ```python bitbnsObj.getSellOrderBook('BTC') ``` ```json { "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 ``` -------------------------------- ### Listing Open Swap Orders in Bitbns Python API Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to retrieve a list of open swap orders from the Bitbns API. The endpoint is paginated, and the `page` parameter can be used to specify the desired page of results. ```Python bitbnsObj.swapListOpenOrders({'page': 0}) ``` -------------------------------- ### Retrieving Open Orders in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This code demonstrates how to retrieve all currently open orders for the user. It requires specifying the network in the request body to filter orders. ```Python body = {'network': 'mainnet'} response = b.futuresOpenOrders() ``` -------------------------------- ### Retrieving Open Orders on Bitbns USDT Market (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to fetch open orders from the Bitbns USDT market using the `getOrders` method. It allows filtering by `side` (e.g., 'usdtListOpenOrders', 'usdtListOpenStopOrders', 'usdtListOpenBracketOrders'), `symbol`, and `page` for pagination. ```Python bitbnsObj.getOrders({'side' : 'usdtListOpenOrders', 'symbol' : 'TRX_USDT', 'page' : 0}) ``` -------------------------------- ### Fetching User Account Details - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves detailed account information for a specified user. It requires `target_uid` as a parameter in the request body. The response includes comprehensive data such as KYC status, contact details, and bank information, reflecting different states like 'REJECTED', 'PENDING', or 'NOT SUBMITTED'. ```Python b.fetchUserAccountDetails(body = { 'target_uid': 1705823 }) ``` ```JSON { "data": { "panCard": true, "eyeFront": true, "eyeBack": true, "isTelegramLinked": false, "upiList": [], "email": "testing_buyhatke1@gmail.com", "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": [ {} ], "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 } ``` -------------------------------- ### Subscribing to Live Executed Orders via Socket (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to use a WebSocket connection to receive live updates on executed orders for the user's account. It first obtains an authentication token via `getTokenSocket` and then uses `getExecutedOrders`. Note that this functionality is currently not working as indicated in the source. ```Python 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") ``` -------------------------------- ### Sample Bitbns Cryptocurrency Market Data Fragment Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This JSON snippet illustrates a fragment of the market data structure for various cryptocurrencies from the Bitbns API. Each cryptocurrency symbol (e.g., 'ONT', 'ZIL') acts as a key, mapping to an object containing its 'highest_buy_bid', 'lowest_sell_bid', and 'last_traded_price'. This format is crucial for applications displaying real-time market depth and trade information. ```JSON "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 ``` -------------------------------- ### Retrieving Swap Orders History (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves the history of swap orders. It calls `bitbnsObj.swapOrderHistory` with a dictionary containing the `page` number to paginate through the history. The `type` parameter (0 for buy, 1 for sell) is mentioned as a general context for order types, though not directly used in the provided code snippet for this specific call. ```Python bitbnsObj.swapOrderHistory({'page': 0}) type => 0 for buy, 1 for sell ``` -------------------------------- ### Retrieving Open Positions in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet fetches all currently open trading positions for the user. The request body specifies the network for which to retrieve the positions. ```Python body = { 'network': 'mainnet' } response = b.futuresOpenPositions() ``` -------------------------------- ### Retrieving FIP Transaction History - Bitbns API - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet is used to fetch the complete transaction history for Fixed Income Plans (FIPs). It provides a comprehensive log of all FIP-related activities and investments made by the user. ```Python bitbnsObj.getFIPTransactions() ``` -------------------------------- ### Placing Stop Loss Sell Order (XRP) - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to place a stop loss sell order for XRP using the `sellStopLoss` method. It requires the cryptocurrency symbol, quantity, target rate, and trigger rate. The order is placed when the price reaches the trigger rate. ```python bitbnsObj.sellStopLoss('XRP', 40, 25, 24.5) ``` ```json { "data": "Successfully placed a stop limit sell order", "status": 1, "error": null, "id": 28596 } ``` -------------------------------- ### Listing Open Stop Loss Orders - Bitbns Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to retrieve a list of all open stop loss orders for a specified cryptocurrency symbol. It requires the cryptocurrency symbol as a parameter and returns a list of order details including entry ID, volume, rates, type, and status. ```Python bitbnsObj.listOpenStopOrders('TST') ``` -------------------------------- ### Updating User Leverage in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to update the leverage for a particular trading instrument. The request body must include the instrument ID, the desired leverage value, and the network. ```Python body = { 'inst_id': 2, 'leverage': 7, 'network': 'mainnet' } response = b.futuresUpdateLeverage(body = body) ``` -------------------------------- ### Retrieving Active Futures Markets - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves a list of active futures trading instruments available on the platform. It takes a `network` parameter, typically 'mainnet', to specify the trading environment. The response provides comprehensive details for each instrument, including its ID, leverage options, pricing precision, and current status. ```Python response = b.futuresInstList(body = {'network': 'mainnet'}) ``` -------------------------------- ### Retrieving Wallet Balance in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to fetch the current futures wallet balance for the authenticated user on the specified network. It makes a call to the `futuresWalletBalance` method. ```Python response = b.futuresWalletBalance(body = {'network': 'mainnet'}) ``` -------------------------------- ### Fetching Trade History - bitbnspy Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet fetches the user's trade history for a specific cryptocurrency and market. It requires parameters for the method ('tradeHistory'), coin name, market, and optional pagination (limit and page). ```Python body = { 'method' : 'tradeHistory', 'coin_name' : 'BTC', 'market' : 'INR', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body) ``` -------------------------------- ### Generating New API Keys - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet generates new API public and secret keys for a given user. It takes `target_uid` as input in the request body. The API returns the newly generated `apiSecret` and `apiPublic` keys along with the request status. ```Python b.generateNewAPIKey(body = { 'target_uid': 1705823 }) ``` ```JSON { "apiSecret": "502C783C2B50983F8BCD1F4940F54CF6", "apiPublic": "63C809662EC27B19396BB1FE12E556D4", "status": 1, "error": null, "code": 200 } ``` -------------------------------- ### Response for Placing Stop Loss Buy Order Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This JSON object represents the successful response received after placing a stop loss buy order. It includes a custom message, a status indicator, and the unique ID of the newly placed order. ```json { "data": "Successfully placed order for stop loss buy", "status": 1, "error": null, "id": 28595 } ``` -------------------------------- ### Fetching OHLCV Data - Bitbns API (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to retrieve OHLCV (Open, High, Low, Close, Volume) data for a specific trading pair from the Bitbns API. The endpoint is paginated, allowing users to fetch older data by incrementing the 'page' parameter. It requires the cryptocurrency symbol, the fiat currency symbol, and the desired page number. ```Python bitbnsObj.fetchOHLCV('BTC', 'INR', page = 1) ``` -------------------------------- ### Fetching Crypto Blockchain Withdrawal History (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to fetch the external crypto withdrawal history for a specific coin. It constructs a `body` dictionary with parameters like `method`, `coin_name`, `limit`, and `page` to specify the query details, then calls `bitbnsObj.fetchMyHistory` with this body. ```Python body = { 'method' : 'withCryptoExternalHistory', 'coin_name': 'BTC', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body) ``` -------------------------------- ### Obtaining Authentication Token for Bitbns Sockets (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to retrieve an authentication token using `getTokenSocket()`. This token is essential for establishing and authenticating WebSocket connections to access live market data and account-specific updates. ```Python bitbnsObj.getTokenSocket() ``` -------------------------------- ### Updating User KYC Status - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet demonstrates how to update a user's account details to mark their KYC as uploaded. It requires a `target_uid` to identify the user and `type` set to 'kycUploaded' in the request body. A successful response indicates the update was applied. ```Python body = { 'target_uid' : 1705823, 'type' : 'kycUploaded' } b.updateUserAccountDetails(body = body) ``` ```JSON { "status": 1, "error": "Successfully updated", "code": 200 } ``` -------------------------------- ### Fetching Order Book using Bitbns Public API in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This function fetches the order book for a specified trading pair, such as 'BTC' against 'INR'. The `depth` parameter allows controlling the number of bids and asks returned, with a default depth of 20. This is a public endpoint. ```Python bitbnsObj.fetchOrderBook('BTC', 'INR', depth = 10) ``` -------------------------------- ### Fetching Crypto Deposit History (Internal) - bitbnspy Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves the user's internal cryptocurrency deposit history, including airdrops, for a specified coin. It uses the 'depCryptoHistory' method and supports pagination. ```Python body = { 'method' : 'depCryptoHistory', 'coin_name': 'BTC', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body) ``` -------------------------------- ### Cancelling Orders - Python API V2 Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to cancel an order using the `cancelOrders` method in API V2. It requires a dictionary specifying the `symbol`, the `side` (e.g., 'cancelOrder', 'cancelStopLossOrder'), and the `entry_id` of the order to be cancelled. This method supports cancelling various order types. ```Python bitbnsObj.cancelOrders({'symbol': 'XRP', 'side' : 'cancelOrder', 'entry_id': 462}) ``` -------------------------------- ### Fetching Recent Trades using Bitbns Public API in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This method retrieves a list of recent trades for a given trading pair, like 'BTC' against 'INR'. The `limit` parameter specifies the number of trades to return, defaulting to 100. This is a public endpoint. ```Python bitbnsObj.fetchTrades('BTC', 'INR', limit = 10) ``` -------------------------------- ### Cancelling an Order (XRP) - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet shows how to cancel an existing order using the `cancelOrder` method. It requires the cryptocurrency symbol and the unique order ID to identify and cancel the specific order. ```python bitbnsObj.cancelOrder('XRP', 174) ``` ```json { "data": "Successfully cancelled the order", "status": 1, "error": null } ``` -------------------------------- ### Fetching Crypto Withdrawal History (Internal) - bitbnspy Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet fetches the user's internal cryptocurrency withdrawal history, including airdrops, for a specified coin. It uses the 'withCryptoHistory' method and supports pagination. ```Python body = { 'method' : 'withCryptoHistory', 'coin_name': 'BTC', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body) ``` -------------------------------- ### Fetching Crypto Deposit Blockchain History - bitbnspy Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves the user's external cryptocurrency deposit history directly from the blockchain for a specified coin. It uses the 'depCryptoExternalHistory' method and supports pagination. ```Python body = { 'method' : 'depCryptoExternalHistory', 'coin_name': 'BTC', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body) ``` -------------------------------- ### Fetching INR Deposit History - bitbnspy Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet retrieves the user's Indian Rupee (INR) deposit history. It uses the 'depINRHistory' method and supports pagination with 'limit' and 'page' parameters. ```Python body = { 'method' : 'depINRHistory', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body) ``` -------------------------------- ### Fetching Ticker Details using Bitbns Public API in Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This method retrieves comprehensive details for all available tickers on the Bitbns exchange. It's a public endpoint call, meaning no authentication is required. The response includes information like highest buy bid, lowest sell bid, last traded price, and volume for each coin. ```Python bitbnsObj.fetchTickers() ``` -------------------------------- ### Fetching INR Withdrawal History - bitbnspy Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet fetches the user's Indian Rupee (INR) withdrawal history. It utilizes the 'withINRHistory' method and allows for pagination using 'limit' and 'page' parameters. ```Python body = { 'method' : 'withINRHistory', 'limit' : 200, 'page': 0 } bitbnsObj.fetchMyHistory(body) ``` -------------------------------- ### Transferring Fiat Funds to Pool Account - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet facilitates the transfer of fiat funds to a specified pool account. It requires `pool_uid` to identify the target pool and the `amount` to be transferred in the request body. A successful response confirms the fund transfer. ```Python b.transferToPoolAccount(body = { 'pool_uid' : 64873278, 'amount' : 50, }) ``` ```JSON { "status": 1, "error": "Successfully transfered funds to pool account", "code": 200 } ``` -------------------------------- ### Transferring Cryptocurrency to Pool Account - Python Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet allows transferring a specific cryptocurrency to a designated pool account. It requires `pool_uid`, `amount`, and `coin_name` (e.g., 'SOL') in the request body. The response confirms the successful transfer of the specified coin. ```Python body = { 'pool_uid' : 64873278, 'amount' : 0.01, 'coin_name': 'SOL' } b.transferCoinToPoolAccount(body = body) ``` ```JSON { "status": 1, "error": "Successfully transfered funds from pool account", "code": 200 } ``` -------------------------------- ### Cancelling Orders on Bitbns USDT Market (Python) Source: https://github.com/bitbns-official/bitbnspy/blob/master/README.md This snippet illustrates how to cancel open orders in the USDT market using the `cancelOrders` method. It requires the `symbol` of the coin, the `side` specifying the type of order to cancel (e.g., 'usdtcancelOrder', 'usdtcancelStopLossOrder'), and the unique `entry_id` of the order. ```Python bitbnsObj.cancelOrders({'symbol': 'TRX_USDT', 'side' : 'usdtcancelOrder', 'entry_id': 462}) ```