Example code from Reuters is not working

So helpdesk has asked me to ask the community?? here ? why the quick tutorial code isnt working, i am using vs code python with jupyter notebook.

The code is just a copy from the quick start guide on the refinitiv website

import eikon as ek

import pandas as pd

ek.set_app_key('my-api tokin')

ek.get_news_headlines('EU AND POL',1)

it works fine until the last line, but simply doesnt return any code, instead after like 10 min waiting or similar it returns this:

2024-01-18 20:47:48,591 P[10672] [MainThread 28692] 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>2024-01-18 20:47:48,593 P[10672] [MainThread 28692] HTTP request failed: EikonError-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>

Best Answer

  • Jirapongse
    Answer ✓

    @johan01

    Thank you for reaching out to us.

    The error indicates that your account doesn't support the API feature.

    Cannot POST /api/v1/data

    As I know, it depends on the Eikon variant that you are using. For example, the Eikon Core variant doesn't include Eikon Data API.

    You can check it by folllowing the steps mentioned in the Eikon Data API and Refinitiv Data Library - Troubleshooting article.

    Otherwise, you can contact your LSEG account team or Sales team to verify your account.


Answers

  • I am using the API feature daily with C#....

    And they have verified it should work and themselves referenced to this code being the one that i should use

  • @johan01

    Which API are you using with C#?

  • i have not spent to much time looking into all different APIs i just use what has been given and works ( not good but at least sometimes )

    EikonDesktopDataAPI



  • @johan01

    EikonDesktopDataAPI is a different API and it doesn't connect to the API proxy to get the data. However, Eikon Data API (Python) requires the AP proxy to get the data.

    It could mean that your account doesn't support the API Proxy feature.

    To verify if the API proxy is running, please check the Eikon Data API and Refinitiv Data Library - Troubleshooting article.

  • any reason why there are so many different APIs instead of one universal like BBGAPI?
  • @johan01

    I think EikonDesktopDataAPI uses the old COM technology which is suitable for C# . However, it is not covenient for other programming langugaes, such as Python, and TypeScript.

    The Eikon Data API supports several programming languages via the Refinitiv Data Libraies.

  • I have done all the tests necessary and the only difference i can see is that when running http://localhost:9000/ping?all

    it doesnt have the sxsApps path stated {"path":"api"} is missing....

    It seems when i google it that it could be something with the subscription being "Eikon Exchange Pricing" which doesnt include API?

    On the other hand there is no problem generating an API key and also Python and the example code runs absolutely fine login me in using the key, there is no error or warning or anything only thing is that it doesnt return data....


    Also, i use the old COM API daily and it works so some sort of access i should have.

  • @johan01

    The response should look like this:

    1705986524551.png

    If it doesn't have the "path":"/api" property, it could means that your Eikon variant doesn't support this feature. Therefore, you can't use the Eikon Data API to get the data.

  • I also added

    ek.set_log_level(1) which was not in the quick start code and i get the following returned then, it seems the access is missing then ?

    2024-01-22 13:23:09,245 P[19380] [MainThread 16008] Send GET request to http://127.0.0.1:9060/api/status to detect API Proxy...2024-01-22 13:23:09,246 P[19380] [MainThread 16008] Request to http://127.0.0.1:9060/api/status headers = {'x-tr-applicationid': 'myId'} params = None2024-01-22 13:23:11,297 P[19380] [MainThread 16008] HTTP request failed: ConnectError('All connection attempts failed')2024-01-22 13:23:11,298 P[19380] [MainThread 16008] Error on checking proxy url http://127.0.0.1:9060/api/status : ConnectError('All connection attempts failed')2024-01-22 13:23:11,300 P[19380] [MainThread 16008] Retrieved port 9060 value from .portIntUse isn't valid.2024-01-22 13:23:11,302 P[19380] [MainThread 16008] Warning: file .portInUse was not found. Try to fallback to default port number.2024-01-22 13:23:11,304 P[19380] [MainThread 16008] Try defaulting to port 9000...2024-01-22 13:23:11,306 P[19380] [MainThread 16008] Send GET request to http://127.0.0.1:9000/api/status to detect API Proxy...2024-01-22 13:23:11,308 P[19380] [MainThread 16008] Request to http://127.0.0.1:9000/api/status headers = {'x-tr-applicationid': 'ef2da95d05c64fec94c7c172bdb2de0aaabbe824'} params = None2024-01-22 13:23:11,314 P[19380] [MainThread 16008] Send request with headers [(b'Host', b'127.0.0.1:9000'), (b'Accept-Encoding', b'gzip, deflate'), (b'Connection', b'keep-alive'), (b'User-Agent', b'python-httpx/0.26.0'), (b'Accept', b'application/json'), (b'x-tr-applicationid', MYID')] and cookies None2024-01-22 13:23:11,315 P[19380] [MainThread 16008] HTTP request response 404: <!DOCTYPE html>

  • @johan01

    Yes, it seems that the API access is missing. It should not return 404 with the HTML document.

     404: <!DOCTYPE html>