Rest API Rate Limit?

What is a reasonable Rest API requests per second on the
https://api.binance.com/api/v3/
As to avoid a HTTP status 429

e.g. For the Websocket it is quoted as 5 requests per second.

Hi Aisling

I see what you are indicating now, thank you.

So far I have got to:

Using the General API Information, weighting system in Limits, I have 1200 weight limit for general requests, I am using a Python URL requests module and now understand the URL Response code is normally 200. I am still looking for the X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter), so currently I can not keep a live binance side tally, until I have worked this part out. But can keep a client side tally.

I am calling each Symbol (approx. 950) in turn and do not want to break the 1200 per min weighting. For historic Klines, to get a new DB up to date, I am calling a limit of 1000 at a time so this looks to be a weighting of 10 (from the table in What are the IP weights?), so that would be 120 calls per min or 2 a second. This will take 8 mins. I have created an intelligent delay function that can limit to this.

binance_Query= “https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1d&limit=1000

try:
cursor.execute(binance_Query)
binance_Query_Output = cursor.fetchall()

I am continuing to investigate the information from the header so I can incorporate X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter) and complete my code correctly.

So ideally I do not get a 429 response and if I do I can respect the 418 time period.

Thank You

Okay, I have got all the information, Thanks :smiley:

import requests

urlExample = ‘https://api.binance.com/api/v3/klinessymbol=BTCUSDT&interval=1d&limit=1000

def function_Get_Klines(urlSymbol):

print ("Fetching data")
response = requests.get(urlSymbol)

responseHeaders = response.headers
print ("responseHeaders: ",responseHeaders)

responseStatus = response.status_code
print ("responseStatus: ",responseStatus )

responseJson = response.json()
        
return responseJson

So as part of the response.headers I get the correct information
‘x-mbx-used-weight’: ‘53’, ‘x-mbx-used-weight-1m’: ‘53’,

and can check for code 429 and 418 as part of the response.status_code.

Please consult this part of the documentation: https://binance-docs.github.io/apidocs/spot/en/#limits