![見出し画像](https://assets.st-note.com/production/uploads/images/127114497/rectangle_large_type_2_666e145448d63558120453d0f67765f1.png?width=1200)
ccxtでResponse Headerに含まれるRate Limitなどを取得する方法
Rate Limitをハンドリングしようと思ったとき、ccxtを使ってるとResponse Headerにアクセスできないじゃんって思ってたら緊急避難的な方法があったので、メモ。
import ccxt
binance = ccxt.binanceusdm({'apiKey': 'my_key', 'secret': 'my_secret'})
# API Call
binance.fetch_open_orders('BTC/USDT')
# 最後にcallしたResponse Headerが保持されている
print(binance.last_response_headers.get('x-mbx-used-weight-1m'))
直近でAPI CallしたときのResponse Headerが、last_response_headersに保持されてました。
現場からは以上です。