Error 400 and 504 - Python API - How to fetch the data for analyst estimates?



I'm using the below code to get the data but the response we're getting is not what we want . I have attached the screenshot of the code with response we're getting with the excel sheet which contain the type of response we want. Can you please help with the code to use?


df, err = ek.get_data(
instruments = ['AAPL.O'],
fields = ['TR.RevenueMean.periodenddate','TR.RevenueMean.calcdate','TR.RevenueMean.date','TR.EPSMean','TR.NetProfitMean','TR.RevenueMean']
,parameters={'SDate':'2010-01-01','EDate':'2023-10-10','Frq':'FQ'}
)

display(df)





I am getting error 400 and 504. Please advise. Thank you.

Best Answer

  • Hi @irenebandal14,


    Please

    (i) make sure you have the latest version of Eikon/Workspace,

    (ii) make sure you have the latest version of `refinitiv.data` (via `pip install refinitiv-data --upgrade`), the latest version is 1.4.0;

    (iii) import `eikon` from the `refinitiv.data` library,

    (iv) authenticate yourself to the LSEG services via `ek.set_app_key("InsertAppKeyHere")` (more on the App Key here) with the Eikon or Workspace Desktop Application running on the machine where the code is being run, when using a desktop session (more on sessions here), and

    (v) do not hesitate to search the LSEG Developer Q&A Forum for answers on the errors you are experiencing; concerning error 400, please see this previous discussion; concerning 504, please see here.

    By searching for your error within forums, you will be able to find other relevant discussion threads, pertaining to the same.

    Please note that we now advise to upgrade to the new Refinitiv Data Library for Python (RD Lib. for Python), instead of the Eikon Data API (EDAPI). This latest library, RD Lib., will receive patches and improvements faster in new releases.