Cannot retrieve ESG data via RDP libraries in Python
I am using RDP libraries to retrieve ESG data via the delivery layer as per the tutorial written here:
However, when I try it with my code, it says:
EndpointError: Error code -1 | Session is not opened. Can't send any request
Not really sure why. Here is my code below (I removed my real RDP login and pwd for security purpose):
import refinitiv.dataplatform as rdp
APP_KEY = 'DEFAULT_CODE_BOOK_APP_KEY'
RDP_LOGIN = '<MY LOGIN HERE>'
RDP_PASSWORD = '<MY PWD HERE>'
session = rdp.PlatformSession(
APP_KEY,
rdp.GrantPassword(username=RDP_LOGIN, password=RDP_PASSWORD)
)
endpoint_url = 'data/environmental-social-governance/v1/views/scores-full'
endpoint = rdp.Endpoint(session, endpoint_url)
response = endpoint.send_request(method=rdp.Endpoint.RequestMethod.GET, query_parameters={'universe': 'ADVANC.BK'})
My environment is in Codebook.
Best Answer
-
Are you doing the above in CodeBook or your own offline Jupyter or .py file?
Just checking because you have the Codebook APP Key - but then you are trying to open a PlatformSession?
Since codebook is part of Eikon, you should be using a desktop session (i.e. an Eikon/Workspace Session) as explained.
session = rdp.open_desktop_session('DEFAULT_CODE_BOOK_APP_KEY')
However, once you do that and make the request it would appear that the Codebook is not permissioned yet to consume ESG data.
If I print the raw response data:
print(response.data.raw)
I get the following:
{'error': {'id': '2d2199a1-6fca-4ac4-a6e6-dd3fcc6655aa', 'code': 'insufficient_scope', 'message': 'access denied. Scopes required to access the resource [trapi.data.esg.views-scores-full.read]', 'status': 'Forbidden'}}
So, for now - if you want to consume ESG data, I suspect you will need to install Python locally and execute the code locally with a PlatformSession - assuming you MachineID is licensed for ESG data.
If however, you are running locally, then it could be that your session fails because you don't have a valid AppKey?
Once you confirm where/how you are running your script, I will reach out to the Codebook owner to comment if appropriate.
0
Answers
-
Hello @Ativut.Trikalsaransukh
I can replicate the problem using the given source code.
When I change from rdp.PlatformSession(..) to be rdp.open_platform_session(..) then I can get ESG data:
My source code:
session = rdp.open_platform_session(
APP_KEY,
rdp.GrantPassword(username=RDP_USER, password=RDP_PASSWORD)
)endpoint_url = 'data/environmental-social-governance/v1/views/scores-full'
endpoint = rdp.Endpoint(session, endpoint_url)
response = endpoint.send_request(method=rdp.Endpoint.RequestMethod.GET, query_parameters={'universe': 'ADVANC.BK'})
result = response.data.raw
resultresult:
Note: I run the source code above in Jupyter notebook.
0 -
Hello @umer.nalla and @pimchaya.wongrukun01
Thank you both for your insights. To clarify Umer's doubt, I am doing this in Codebook.
I guess I am just confused with the difference between DesktopSession / PlatformSession and open_desktop_session / open_platform_session. In the document, it says that the first should be used in Content Layer and the latter should be used in Function Layer. So is it safe to assume that for data that is currently only available in Delivery Layer, the "open" one should be used?
Next is the Codebook environment, based on Umer's info, is it safe to summarize that:
1) Codebook is not ready to retrieve ESG data yet.
2) Once it's ready, open_desktop_session should be used so I should not have to supply my RDP credential
And lastly on local Jupyter environment:
I tried just a moment ago and it does work indeed. I have to replace my APP_KEY to my own and as Pimchaya mentioned, I will need to use open_platform_session function
0 -
Your welcome.
For clarification of Session type, please refer to part 1 of my article - where I explain the difference between the session types - Dekstop(Eikon/WorkSpace), Platform(Cloud) and Deployed(ADS).
Just to complicate matters slightly, in the future versions of RDP library both Cloud and ADS will be classed as Platform Session (the format of the call will be different).
The session type is independent of the Library layer i.e. Function, Content or Delivery - which reflect different levels of ease of use etc.
At present, you need to use the Delivery layer for ESG data - but in the new version of the RDP library(not generally available yet), there is Function layer support for ESG - thereby making it easier - no need to create Endpoints etc:
df = rdp.get_esg_standard_scores(universe = '6758.T')
But as mentioned this is not available just yet.
Finally, would you be OK if we remove the Internal status of this post, as I think the content will be helpful to customers once they start trialling CodeBook?
Thanks.
0 -
Thank you. Sure I will remove the internal flag on this.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 616 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 653 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 229 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛