Getting data from api

I'm trying to get data from the Eikon api. My code is as following:


import eikon as ek

ek.set_app_key('xxxxxxxx')

fields = ['TR.HeadquartersCountry','CF_LAST','TR.CompanyMarketCap(Scale=6 Curn=EUR)','TR.PricePctChgYTD','TR.PriceToBVPerShare','TR.PE','TR.FwdPE','TR.PriceToCFPSTrailing12m','TR.FwdPriceToCFPerShare','TR.EVToSales','TR.RelValEVSalesNTM','TR.EVToEBITDA','TR.FwdEVToEBITDA','TR.EVToEBIT','TR.FwdEVToEBIT','TR.PEG','TR.ROEPercentTrailing12M','TR.ROEMEAN','TR.ROAMEAN','TR.NetDebtToEBITDA','TR.OperatingMarginPercent','CURRENCY','TR.WACCCostofEquity','TR.WACC','TR.EBITMarginPercent','TR.EBITDAMarginPercent','TR.NetDebt','TR.Cash']

tickers = ['MARL.IC','G1AG.DE','JBT','MIDD.O']

And to get data I do

data = ek.get_data(tickers,fields,None,False,True,False)


I'm not sure if I'm able to connect to eikon, so I don't know if I've established connection. The Eikon application is up an running, so that is not the issue. Maybe my issue is with ek.set_app_key('xxxxxxxx'), where I get no logging after that part of the code.


Best Answer

Answers

  • Hi @olafur,

    If the API wasn't connecting to Eikon, it would throw an exception. What is the output of dataframe?

    print(data)

    To enable logging and see the information on console, you can set:

    import logging.config
    ek.set_log_level(logging.DEBUG)
  • Hi, after some digging I'm getting the following error


    "EikonError(404, 'Client Error: <!DOCTYPE html>\n<html lang="en">\n<head>\n<meta charset="utf-8">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot POST /api/v1/data</pre>\n</body>\n</html>\n')"


    when I use the ek.get_data(tickers,fields,None,False,True,False) function. Any ideas?

  • @olafur

    Were you able to resolve the issue? Or is it still outstanding? If you're still experiencing the problem, could you share the full logging output after setting the log level to the max using ek.set_log_level(1) call?