trying to connect to eikon api - error 404

I'm trying to get data in the Eikon api in Python.

i run the following code:

import eikon as ek

API_KEY = "my_api_generated_from_eikon"
ek.set_app_key(API_KEY)
df = ek.get_timeseries(["MSFT.O"], start_date="2023-01-01", end_date="2023-01-10")

but i get the following error:

2023-11-27 13:10:29,087 P[12100] [MainThread 20108] Error code 404 | Client Error: <!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Error</title>

</head>

<body>

<pre>Cannot POST /api/v1/data</pre>

</body>

</html>


I tried going into the troubleshooting section, and went into http://localhost:9000/ping?all

but could not find any {"path":"api"}

also, i don't get any response from: http://localhost:9060/api/status

What is the problem?

Best Answer

  • Jirapongse
    Answer ✓

    @shai

    If you don't have {"path":"/api"} in ping?all, it could mean that your Eikon or Workspace account doesn't have permission to use the API.

    1704428768253.png

    You can contact your Refinitiv account team or sales team directly to verify your account.

Answers

  • Hi @shai,


    Please note that we are deprecating the `eikon` library (a.k.a.: the EDAPI); we advise using the RD library. It works very similarly to the `eikon` library in your case.
    With that said, if upgrading to the refinitiv data library does not resolve your issue, would you mind please letting me know if you have Eikon/Workspace running on the machine you are running the code on? This is necessary to run the above.

  • How about you guys fix the issues with the Eikon API until everyone has trasitioned to RD Library?? This is an ongoing issue and there are so many posts about this issue

  • Hi, i tried using the RD library. it seems like i am able to connect but i don't manage to get any data. my code is quite simple:

    import refinitiv.data as rd
    from refinitiv.data.content import pricing

    import os
    os.environ["RD_LIB_CONFIG_PATH"] = "C:/Users/Shai Ben Shabat/PycharmProjects/TheSystem/venv/Lib/site-packages/refinitiv/configuration"
    rd.open_session()

    non_streaming = rd.content.pricing.Definition(['EUR=', 'GBP=', 'JPY=', 'CAD='],fields=['BID', 'ASK']).get_stream()
    # We want to just snap the current prices, don't need updates
    # Open the instrument in non-streaming mode
    print(non_streaming['EUR=']['BID'])

    but this only returns "None". when i try non_streaming.open(with_updates=False) it fails and gives back:
    No user scope for key=/streaming/pricing/v1/, method=GET.
    Insufficient Scope. Cannot load the list of associated URLs from https://api.refinitiv.com/streaming/pricing/v1/ for apis.streaming.pricing.endpoints.main endpoint.


  • Hi @shai, Can you use the get_history function? It seems appropriate if you would not like a stream


    import refinitiv.data as rd
    rd.open_session()

    snapshot = rd.get_history(
    universe=['EUR=', 'GBP=', 'JPY=', 'CAD='],
    fields=['BID', 'ASK'],
    interval='tick',
    count=1) # returns data in GMT
    # Get localised timezone:
    mrkt_price = snapshot.copy()
    mrkt_price.index = pd.MultiIndex.from_tuples(
    [(i, j) for i, j in zip(
    snapshot.index,
    snapshot.index.tz_localize('GMT').tz_convert('Europe/Paris'))],
    names=["gmt", "cet"])
    mrkt_price

    1701357794058.png


    Does this provide you with the data intended?

  • It does, thank you, but the reason i went to non_stream was that i wanted to see if something works because get_data didn't. If i do want to stream, the code, as i understand it is:

    response = rd.content.pricing.Definition(['EUR=', 'GBP=', 'JPY=', 'CAD='], fields=['BID', 'ASK']).get_data()

    but that returns:

    Traceback (most recent call last):

    File "C:\Users\Shai Ben Shabat\PycharmProjects\TheSystem\api_connect.py", line 7, in <module>

    response = rd.content.pricing.Definition(

    File "C:\Users\Shai Ben Shabat\PycharmProjects\TheSystem\venv\lib\site-packages\refinitiv\data\content\_content_provider_layer.py", line 58, in get_data

    return super().get_data(session, on_response)

    File "C:\Users\Shai Ben Shabat\PycharmProjects\TheSystem\venv\lib\site-packages\refinitiv\data\delivery\_data\_data_provider_layer.py", line 149, in get_data

    response = get_data(self._data_type, self._provider, session, **self._kwargs)

    what am i doing wrong?

    another question - whenever i run the api, does it force eikon to close?

  • Hi @shai, above, you were using the content layer. I would not advise using the content layer, as it may need more configuration setup steps than the access layer. For examples on using streaming services in the access layer, please see here.
  • Ok, thanks.

    2 questions: 1. Can i access the option volatility data with the access layer?

    2. I noticed that everytime i connect, the eikon closes. Is there a way to avoid that?

  • Hi @shai,

    1. No, there are no access layer Option Volatility functionalities available on the RD Lib. as of today. There are, however, such fuctions available via the Delivery and Content Layers as shown in the article "Implied Volatility and Greeks of Index 'At The Money' Options".

    2. Yes, it is expected for Desktop Applications such as Workspace or Eikon to shut down when using the platform session when connecting to one of the RDP APIs. This procedure is named 'AAA', or 'single sign on'. To avoid this, you can use the desktop session

    You can find information about these sessions here:
    https://developers.lseg.com/en/article-catalog/article/summary-of-common-lseg-refinitiv-apis
  • Hi Jonathan, i do manage to work with the default session but that means my Eikon keeps closing. When i try to move to the desktop session i get this:

    An error occurred while requesting URL('http://localhost:9060/api/status').

    ConnectError('[WinError 10061] No connection could be made because the target machine actively refused it')


    my code is:

    rd.open_session("desktop.workspace")
    snapshot = rd.get_history(
    universe=[currency],
    fields=['BID', 'ASK'],
    interval='tick',
    count=1)
    mrkt_price = snapshot.copy()
  • Hi @shai, The default session is the Desktop Session (unless you changed the definition of the default session in your configuration file). It looks like the default session must have been redefined to be the Platform Session. It looks like you are encountering a proxy issue when using hte Desktop Session; for more information on solving this, please refer to this Q&A:

    https://community.developers.refinitiv.com/questions/112359/how-to-choose-what-proxy-eikon-or-workspace-choose.html

    Please do let us know if it solves your issue.

  • Hi, i looked at the link but this doesn't solve my problem. my code is:

    import refinitiv.data as rd


    def get_realtime_spot(currency):
    rd.open_session("desktop.workspace")
    snapshot = rd.get_history(
    universe=[currency],
    fields=['BID', 'ASK'],
    interval='tick',
    count=1)
    mrkt_price = snapshot.copy()
    mrkt_price_bid = mrkt_price.to_dict()["BID"]
    mrkt_price_ask = mrkt_price.to_dict()["ASK"]
    for key in mrkt_price_bid:
    bid = mrkt_price_bid[key]
    for key in mrkt_price_ask:
    ask = mrkt_price_ask[key]
    return round((bid + ask)/2, 4)

    when i run it with rd.open_session() it works perfectly but logs out from Eikon. When i try to run it like this it returns:

    Traceback (most recent call last):

    File "C:\Users\Shai Ben Shabat\PycharmProjects\Pricer\main.py", line 34, in <module>

    constant_calc()

    File "C:\Users\Shai Ben Shabat\PycharmProjects\Pricer\main.py", line 18, in constant_calc

    create_strategy(pricer)

    File "C:\Users\Shai Ben Shabat\PycharmProjects\Pricer\entry_processor.py", line 19, in create_strategy

    spot = get_spot(currency, pricer.spot_manual_entry.get())

    File "C:\Users\Shai Ben Shabat\PycharmProjects\Pricer\base_params.py", line 47, in get_spot

    return get_realtime_spot(currency)

    File "C:\Users\Shai Ben Shabat\PycharmProjects\Pricer\api_connect.py", line 9, in get_realtime_spot

    snapshot = rd.get_history(

    File "C:\Users\Shai Ben Shabat\PycharmProjects\Pricer\venv\lib\site-packages\refinitiv\data\_access_layer\get_history_func.py", line 206, in get_history

    raise RDError(-1, except_msg)

    refinitiv.data._errors.RDError: Error code -1 | No data to return, please check errors: ERROR: No successful response.

    (404, <!DOCTYPE html>


    I'd appreciate your support on the matter

  • Hi @shai, may I ask, what is written in your configuration file under "Default"?


    1702984140739.png

    I am asking because if it is "platform.rdp", as per the screenshot above, then this is what is used with the `rd.open_session()`, explaining why Workspace closes when you run your code. Since it works when using `rd.open_session()`, then, if "Default" in your configuration file says "platform.rdp", I woudl suggest (i) checking that configuration file and making sure that the "app-key" argument is the same under "platform" "rdp" and "desktop" "workspace", (ii) checking that you are logging into the Workspace Desktop App on the same machine on which you are running your Python code, (iii) checking that you are loging into the Workspace Desktop App with the same "username" & "password" arguments as what is in said configuration file.

    Please let me know if you can go through (i) to (iii) and if you are still getting the same issue.

  • Hi, the current default is indeed "platform.rdp". I did check everything and all seems in order. the app-key is the same one. I did notice that the original config file did not have a username and password under the desktop, so i added it but still no luck. I'm attaching here the structure without the details, so you can see that it's good.

    {

    "logs": {

    "level": "debug",

    "transports": {

    "console": {

    "enabled": false

    },

    "file": {

    "enabled": false,

    "name": "refinitiv-data-lib.log"

    }

    }

    },

    "sessions": {

    "default": "platform.rdp",

    "platform": {

    "rdp": {

    "app-key": "XXX",

    "username": "YYY",

    "password": "ZZZ"

    },

    "deployed": {

    "app-key": "XXX",

    "realtime-distribution-system": {

    "url" : "YOUR DEPLOYED HOST:PORT GOES HERE!",

    "dacs" : {

    "username" : "YOUR DACS ID GOES HERE!",

    "application-id" : 256,

    "position" : ""

    }

    }

    }

    },

    "desktop": {

    "workspace": {

    "app-key": "XXX",

    "username": "YYY",

    "password": "ZZZ"

    }

    }

    }

    }