IMPORT ORDER BOOK FROM CRYTOCOMPARE

    Hi everyone,

i would like to import the order book from cryptocompare and use for a trading strategy hft.



Followed the course about crypto i have find how i can import raw data code…

but i need an help in coding to import the order book.



for example i have write



APIKEY="***********************************************************"

url= 'https://min-api.cryptocompare.com/data/ob/exchanges'

requests.get(url).json()



but the output give me this errore

{'Response': 'Error',
 'Message': 'You need a valid auth key or api key to access this endpoint',
 'HasWarning': False,
 'Type': 1,
 'RateLimit': {},
 'Data': {}}

could someone help me?
thank you 

sorry i have roselved the error

just with

the f' before the http

and &api_key{}& after the url.

 

Hello Irene,



It's great that you found your error. It's pretty common to have this kind of situation while coding. 



Please let us know in case you need more help,



Thanks and regards,



José Carlos

hi josè…

i have imported the order book…but i don t understand how can i reorder the data…so how can i have a columns and row about bid ask price of btc and eth in usd and euro…

hope you can help me



belove the ouptup of my input order book import from cryptocompare…

{'Response': 'Success',
 'Message': '',
 'HasWarning': False,
 'Type': 100,
 'RateLimit': {},
 'Data': {'RAW': {'BTC': {'USD': {'CCSEQ': 2209382576,
     'BID': 22905.69,
     'BID_REPORTED_MS': 1658429755411,
     'ASK': 22905.7,
     'ASK_REPORTED_MS': 1658429755394},
    'EUR': {'CCSEQ': 1100082462,
     'BID': 22464.36,
     'BID_REPORTED_MS': 1658429755411,
     'ASK': 22472.25,
     'ASK_REPORTED_MS': 1658429755357}},
   'ETH': {'USD': {'CCSEQ': 2459453732,
     'BID': 1543.61,
     'BID_REPORTED_MS': 1658429755400,
     'ASK': 1543.72,
     'ASK_REPORTED_MS': 1658429755377},
    'EUR': {'CCSEQ': 967939704,
     'BID': 1513.38,
     'BID_REPORTED_MS': 1658429755412,
     'ASK': 1514.34,
     'ASK_REPORTED_MS': 1658429755350}}},
  'DISPLAY': {'BTC': {'USD': {'BID': '$ 22,905.7', 'ASK': '$ 22,905.7'},
    'EUR': {'BID': '€ 22,464.4', 'ASK': '€ 22,472.3'}},
   'ETH': {'USD': {'BID': '$ 1,543.61', 'ASK': '$ 1,543.72'},
    'EUR': {'BID': '€ 1,513.38', 'ASK': '€ 1,514.34'}}}}}

Hi Irene,



The data obtained is in form of a JSON object. You can convert it into a pandas object by using the read_json method. You can refer to the following documentation for the method details:



https://pandas.pydata.org/docs/reference/api/pandas.read_json.html



Hope this helps!



Thanks,

Akshay