question

Upvotes
Accepted
1 0 1 1

How to set up the Python API?

How do I set up the Python access? I have a Refinitiv Workspace, is there a page describing the configuration necessary?

python#technologypython api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @claudiu.schiller

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS

want to accept the answer with the proposal to check and upgrade the version of the anyio package but I can't see it, did you delete by mistake?

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,


AHS

Upvotes
Accepted
79.2k 251 52 74

I think it requires anyio version 3.x or 4.x.

I am using anyio 3.3.4.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
24.7k 54 17 14

Hello @claudiu.schiller

Thank you for reaching out to us. I strongly suggest you check following the Data Library for Python resources as follows:

  1. The Quick Start page.
  2. The Getting Started with Python page.
  3. the Tutorials page.

The examples can be downloaded from the GitHub repository.

If you encounter any issues, you can follow the steps on this Eikon Data API and Refinitiv Data Library - Troubleshooting article.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 1 1

Thanks. I see 2 alternative packages documented: eikon and refinitiv-data. Are there advantages/disadvantages of working with either?

Follow-on question, maybe you can point to the source of the error I receive after trying to set the app key:

ek.set_app_key(XXXX)

[MainThread 16232] Error: no proxy address identified.
[MainThread 16232] Error on handshake url http://127.0.0.1:None/api/handshake : InvalidURL("Invalid port: 'None'")

Regards,

Claudiu

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
24.7k 54 17 14

Hello @claudiu.schiller

The Eikon Data API is a feature-completed API, the Data Library for Python is the strategic API currently. The new API features will be added to the Data Library only. You can find more detail about Pros and Cons from this Upgrade from using Eikon Data API to the Data library article.

About the issue that you are facing. The Eikon Data API (or Data Library - Desktop session) needs to connect to the Workspace/Eikon desktop application in the same machine (localhost/127.0.0.1 ports 9060 and 9000) as a proxy between the API and the platform. Did you run the Workspace/Eikon desktop application in the same machine as the Python script?

Please try the steps on the following resources:



icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 1 1

Thanks for the pointer. I did check the workspace is running and followed the troubleshooting article to show the DATA API PROXY is Ready. The older posts seem to indicate a library version incompatibility which I'm not sure is still relevant. Any pointers? Let me know if a new post would be better that continuing in this thread.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
24.7k 54 17 14

Hello @claudiu.schiller

I did a quick test. The Eikon Data API version 1.1.18 works fine with httpx version 0.27.0 on my end.

Based on this What version of Eikon (Core, Research and Advisory, Premium) do you need to use the Python Data APIs? old post, the Eikon Data API (and Data Library - Desktop session) supports the Workspace/Eikon premium user only. Please confirm if your Workspace is premium account (you can contact your LSEG representative for more detail).

If you are already on the premium account, please follows the following instructions.

  • Please confirm version of your eikon, httpx and nest-asynco library (you can use pip show command)
  • Does your environment have a firewall or proxy policy that block connect to localhost? You need to contact your local IT team for this.
  • Enable the API logging, please see section "2.1.2) Enable logging" of the troubleshooting article for more detail. Then share a full log messages when the problem occurs here.
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 1 1

eikon: 1.1.18

httpx: 0.26.0

nest_asynco is not installed

See full log of failure below (replaced key id as XXX)

2024-03-11 09:58:21,239 P[888] [MainThread 21024] Reset a Desktop session with new app_key
2024-03-11 09:58:21,246 P[888] [MainThread 21024] Send GET request to http://127.0.0.1:9000/api/status to detect API Proxy...
2024-03-11 09:58:21,247 P[888] [MainThread 21024] Request to http://127.0.0.1:9000/api/status
    headers = {'x-tr-applicationid': 'XXXXXXXXXX'}
    params = None
2024-03-11 09:58:21,249 P[888] [MainThread 21024] HTTP request failed: AttributeError("module 'anyio' has no attribute 'CancelScope'")
2024-03-11 09:58:21,250 P[888] [MainThread 21024] Error on checking proxy url http://127.0.0.1:9000/api/status : AttributeError("module 'anyio' has no attribute 'CancelScope'")
2024-03-11 09:58:21,254 P[888] [MainThread 21024] Retrieved port 9000 value from .portIntUse isn't valid.
2024-03-11 09:58:21,255 P[888] [MainThread 21024] Warning: file .portInUse was not found. Try to fallback to default port number.
2024-03-11 09:58:21,256 P[888] [MainThread 21024] Try defaulting to port 9000...
2024-03-11 09:58:21,258 P[888] [MainThread 21024] Send GET request to http://127.0.0.1:9000/api/status to detect API Proxy...
2024-03-11 09:58:21,259 P[888] [MainThread 21024] Request to http://127.0.0.1:9000/api/status
    headers = {'x-tr-applicationid': 'XXXXXXXXX'}
    params = None
2024-03-11 09:58:21,261 P[888] [MainThread 21024] HTTP request failed: AttributeError("module 'anyio' has no attribute 'CancelScope'")
2024-03-11 09:58:21,262 P[888] [MainThread 21024] Error on checking proxy url http://127.0.0.1:9000/api/status : AttributeError("module 'anyio' has no attribute 'CancelScope'")
2024-03-11 09:58:21,263 P[888] [MainThread 21024] Default proxy port #9000 failed
2024-03-11 09:58:21,264 P[888] [MainThread 21024] Try defaulting to port 9060...
2024-03-11 09:58:21,265 P[888] [MainThread 21024] Send GET request to http://127.0.0.1:9060/api/status to detect API Proxy...
2024-03-11 09:58:21,266 P[888] [MainThread 21024] Request to http://127.0.0.1:9060/api/status
    headers = {'x-tr-applicationid': 'XXXXXXXX'}
    params = None
2024-03-11 09:58:21,267 P[888] [MainThread 21024] HTTP request failed: AttributeError("module 'anyio' has no attribute 'CancelScope'")
2024-03-11 09:58:21,268 P[888] [MainThread 21024] Error on checking proxy url http://127.0.0.1:9060/api/status : AttributeError("module 'anyio' has no attribute 'CancelScope'")
2024-03-11 09:58:21,269 P[888] [MainThread 21024] Default proxy port #9060 failed
2024-03-11 09:58:21,270 P[888] [MainThread 21024] Error: no proxy address identified.
Check if Eikon Desktop or Eikon API Proxy is running.
2024-03-11 09:58:21,272 P[888] [MainThread 21024] Try to handshake on url http://127.0.0.1:None/api/handshake...
2024-03-11 09:58:21,273 P[888] [MainThread 21024] Request to http://127.0.0.1:None/api/handshake
    headers = {'Content-Type': 'application/json', 'x-tr-applicationid': 'XXXXXXX'}
    params = None
2024-03-11 09:58:21,274 P[888] [MainThread 21024] HTTP request failed: InvalidURL("Invalid port: 'None'")
2024-03-11 09:58:21,275 P[888] [MainThread 21024] Error on handshake url http://127.0.0.1:None/api/handshake : InvalidURL("Invalid port: 'None'")
2024-03-11 09:58:21,276 P[888] [MainThread 21024] Error on handshake url http://127.0.0.1:None/api/handshake : InvalidURL("Invalid port: 'None'")
2024-03-11 09:58:21,277 P[888] [MainThread 21024] Port number was not identified, cannot send any request
2024-03-11 09:58:21,278 P[888] [MainThread 21024] Received notification for closed streaming session 0
2024-03-11 09:58:21,278 P[888] [MainThread 21024] Received notification for closed streaming session 0
2024-03-11 09:58:21,279 P[888] [MainThread 21024] Init a Desktop session with new app_key
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Please check the version of anyio used in the application.

1710150537222.png


1710150537222.png (5.5 KiB)
Upvotes
1 0 1 1

anyio at 2.2.0

I can install newer and check tomorrow if this is the cause (installing new packages in our env is a bit complex)

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @claudiu.schiller

I am using anyio version 3.4.0. Please try to upgrade the anyio as suggest by my colleague above.

pip install anyio --upgrade

or

pip install anyio==<version> --upgrade 

You can check the versions of anyio from the PyPI history page.

Upvotes
1 0 1 1

Upgrading anyio to v3.4 helped. Now I get data. Thanks a lot for the help.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @claudiu.schiller

I am glad to hear that the issue is resolved on you end.

I strongly suggest you keep this environment setting for later use. You can use the pip freeze command to generate a requirements file and then install from it in another environment.

python -m pip freeze > requirements.txt

To install the same set of libraries versions:

python -m pip install -r requirements.txt

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.