bitbns-official / bitbnspy

MIT License
9 stars 6 forks source link

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

Open sukhwant280 opened 3 years ago

sukhwant280 commented 3 years ago

Describe your environment

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

sanket-buyhatke commented 3 years ago

hi, response code - 200 means the requested action has been performed without any problems.

could you please specify what issue you are facing ?

also the time.sleep(10), you can reduce the time between requests (to around 1s or so), you can check the number of requests remaining using bitbnsObj.getApiUsageStatus()

sukhwant280 commented 3 years ago

the error i get is " KeyError: "Try running with errors='ignore' as key 'code' is not always present"

Also the JSON output stored in data - dataframe is" Some error in get req"

this usually happens when i run for 30 coins and i have double checked in UI that the bid /ask is present for those 30 coins.

If i make time.sleep(10) to 1s, then it gives the above error more frequently.

1) What is the limit for no of requests? and can this be increased?

sukhwant280 commented 3 years ago
  1. API limit is per month or per day?
sanket-buyhatke commented 3 years ago
  1. API limit is per month or per day?

per minute.

sukhwant280 commented 3 years ago

Thanks Sanket for the above.

Please advise on the error while requesting for 20 coins together. checked the ApiUsageStatus and its in abundance.