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?
Best Answer
-
I think it requires anyio version 3.x or 4.x.
I am using anyio 3.3.4.
0
Answers
-
Hello @claudiu.schiller
Thank you for reaching out to us. I strongly suggest you check following the Data Library for Python resources as follows:
- The Quick Start page.
- The Getting Started with Python page.
- 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.
0 -
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
0 -
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:
- Eikon Data API and Refinitiv Data Library - Troubleshooting article.
- Error: no proxy address identified old post.
- Error: no proxy address identified. old post
0 -
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.
0 -
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.
0 -
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_key0 -
Please check the version of anyio used in the application.
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)
0 -
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.
0 -
Upgrading anyio package to v3.4 changed the response. Now the complaint is about access token expiration as far as I understand the log output. I did generate a new app key through app_generator but still same message. See log below:
2024-03-12 08:37:41,707 P[22288] [MainThread 20272] Send GET request to http://127.0.0.1:9000/api/status to detect API Proxy...
2024-03-12 08:37:41,712 P[22288] [MainThread 20272] Request to http://127.0.0.1:9000/api/status
headers = {'x-tr-applicationid': 'XXXXXXX'}
params = None
2024-03-12 08:37:44,835 P[22288] [MainThread 20272] Send request with headers [(b'Host', b'127.0.0.1:9000'), (b'Accept-Encoding', b'gzip, deflate, br'), (b'Connection', b'keep-alive'), (b'User-Agent', b'python-httpx/0.26.0'), (b'Accept', b'application/json'), (b'x-tr-applicationid', b'XXXXXXX')] and cookies None
2024-03-12 08:37:44,838 P[22288] [MainThread 20272] HTTP request response 200: {"statusCode":"ST_PROXY_READY","version":"3.3.1-tsi"}
2024-03-12 08:37:44,839 P[22288] [MainThread 20272] Checking proxy url http://127.0.0.1:9000/api/status response : 200 - {"statusCode":"ST_PROXY_READY","version":"3.3.1-tsi"}
2024-03-12 08:37:44,840 P[22288] [MainThread 20272] Port 9000 was retrieved from .portInUse file
2024-03-12 08:37:44,842 P[22288] [MainThread 20272] Try to handshake on url http://127.0.0.1:9000/api/handshake...
2024-03-12 08:37:44,844 P[22288] [MainThread 20272] Request to http://127.0.0.1:9000/api/handshake
headers = {'Content-Type': 'application/json', 'x-tr-applicationid': 'XXXXXXXX'}
params = None
2024-03-12 08:37:45,042 P[22288] [MainThread 20272] Send request with headers [(b'Host', b'127.0.0.1:9000'), (b'Accept-Encoding', b'gzip, deflate, br'), (b'Connection', b'keep-alive'), (b'User-Agent', b'python-httpx/0.26.0'), (b'Accept', b'application/json'), (b'Content-Type', b'application/json'), (b'x-tr-applicationid', b'XXXXXXXXX'), (b'Content-Length', b'159')] and cookies None
2024-03-12 08:37:45,043 P[22288] [MainThread 20272] HTTP request response 200: {"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjM4NmNiMzkxN2FmMzQwMTY5MThiN2ZiZjAyMTVmMTZhNmFjODFlODYiLCJBcHBTY29wZSI6InRyYXBpIiwiTGlicmFyeU5hbWUiOiJSRFAgUHl0aG9uIExpYnJhcnkiLCJMaWJyYXJ5VmVyc2lvbiI6IjEuMS4xOCIsImlhdCI6MTcxMDIyNTQ2NSwiZXhwIjoxNzExNDM1MDY1fQ.8wU8TZprfYSveWOU_bzNsAvQE3IgUP0hbLpc3gSyUp4","expires_in":1209600,"token_type":"bearer"}
2024-03-12 08:37:45,045 P[22288] [MainThread 20272] Response : 200 - {"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjM4NmNiMzkxN2FmMzQwMTY5MThiN2ZiZjAyMTVmMTZhNmFjODFlODYiLCJBcHBTY29wZSI6InRyYXBpIiwiTGlicmFyeU5hbWUiOiJSRFAgUHl0aG9uIExpYnJhcnkiLCJMaWJyYXJ5VmVyc2lvbiI6IjEuMS4xOCIsImlhdCI6MTcxMDIyNTQ2NSwiZXhwIjoxNzExNDM1MDY1fQ.8wU8TZprfYSveWOU_bzNsAvQE3IgUP0hbLpc3gSyUp4","expires_in":1209600,"token_type":"bearer"}
2024-03-12 08:37:45,046 P[22288] [MainThread 20272] Application ID: XXXXXXXXX
2024-03-12 08:37:45,047 P[22288] [MainThread 20272] Init a Desktop session with new app_key0 -
Upgrading anyio to v3.4 helped. Now I get data. Thanks a lot for the help.
0 -
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
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛