When new products are introduced on crypto exchanges, the python api’s and docuementation sometime is not complete, and it’s difficult to find exact symbol names and other paramters.To quickly find out symbol names and other paramters for api calls, we can use chrome.
In this example we will find out symbol names and api paramters for new binance coin futures (delivered in coin).
1. Open chrome and choose product of interest, in this case ETH USD quarterly future.
2. Press Ctrl-SHift-I this will open developer tools.
3. Choose “Network” tab and reload the webpage
4. Scroll through https calls and find data you are interested in i.e. Book Depth, Klines for candlesticks, etc
5. Now click on the data we are interested in (Klines in this case) and full API url will be shown
Now you can use it in jupyter notebook to get the data:
import requests r =requests.get('https://www.binance.com/dapi/v1/continuousKlines?pair=ETHUSD&interval=15m&contractType=CURRENT_QUARTER&limit=800').json() pd.DataFrame(r)
Which results in:
To convert timestamps we can use the following code:
from datetime import datetime def ts2dt(x): return (datetime.utcfromtimestamp(int(x)/1000.)) df=df.apply(ts2dt) df=df.apply(ts2dt)