API Related Query

Hi Team, please can you answer the below questions from my client.
I have a couple of questions on the recommended Python package and required credentials please.
There are three Python packages available:
https://pypi.org/project/refinitiv-data/
https://pypi.org/project/refinitiv-dataplatform/
https://pypi.org/project/lseg-data/
Which one do you recommend to use?
And then given the recommended package, could you share some example code that initiates a session without need for a config file please?
For example, using the definitiv.dataplatform I have tried:
import refinitiv.dataplatform as rdp
grant = rdp.GrantPassword(username="
cip@vitol.com
", password=xyz)
rdp.open_platform_session(
app_key="as generated on the workspace app",
grant=grant,
)
But this give me a PlatformSessionError:
PlatformSessionError: Error code -1 | ERROR!!! response 400 while requesting URL('https://api.refinitiv.com/auth/oauth2/v1/token').
{"error":"access_denied" ,"error_description":"Invalid username or password." }
I have also tried refinitiv.data but this seems more involved:
import refinitiv.data as rd
grant = rd.session.platform.GrantPassword(username="
cip@vitol.com
", password=…)
definition = rd.session.platform.Definition(
app_key="another api key",
grant=grant,
signon_control=False)
session = definition.get_session()
rd.open_session()
df = rd.get_data(
universe=['USD=', 'EUR=', "LSEG.L"],
fields=['BID', 'ASK', 'TR.Revenue']
)
Thank you for looking into this.
Kind regards,
Denis
Best Answer
-
Hello @Denis Gribenyuk
lseg-data has superseded other legacy packages and is the right library to use. You can see the examples for it in the GitHub samples.
The notebook example on sessions show how to create and open a session without using configuration file.
session = ld.session.platform.Definition( app_key = APP_KEY, grant = ld.session.platform.GrantPassword( username = RDP_LOGIN, password = RDP_PASSWORD ) ).get_session()
1
Answers
-
Thank you Gurpreet. I have shared with client. If any further questions I will post here.
0 -
Hi @Denis Gribenyuk ,
For more detail, here's related article
0 -
Hi Gurpreet,
Please see response from user.
This is helpful. Unfortunately my credentials don’t give me an open session – see my code and returned error below.
import lseg.data as ld
APP_KEY = "as generated for EDP"
RDP_LOGIN ="…”
RDP_PASSWORD ="…"
session = ld.session.platform.Definition(
app_key= APP_KEY,
grant= ld.session.platform.GrantPassword(
username= RDP_LOGIN,
password= RDP_PASSWORD
)
).get_session()
session.open()
[Error 400] - {'error': 'access_denied', 'error_description': 'Invalid username or password.'}
<OpenState.Closed: 'Closed'>
Let’s clarify please which credentials are needed here.
- I have generated the two API keys as shown in the attached screenshot – could you check please that these are suitable?
- What are my RDP login and password please? I have …
- a user name and password for the LSEG workstation (I can use this e.g. to log on to the web version of the workstation)
- user name (all numerical) and password for the DataScope service: https://select.datascope.refinitiv.com/DataScope/
Please can you help answer these questions.
Thanks,
Denis
0 -
It uses the Data Platform credential. You can try with the following URL.
https://apidocs.refinitiv.com/Apps/ApiDocs
If you have the LSEG Workspace account, you can use the desktop session.
session = ld.session.desktop.Definition(app_key = APP_KEY).get_session() session.open()
However, you need to run the application on the same machine as LSEG workspace and the LSEG workpace must be running.
0 -
Please see reply from client - still unresolved.
My data platform credentials allow me to see the api docs and try out an end point:
However, when I use the same credentials with an app_key…
I get
If I change the APP_KEY variable to some made-up value, the error changes and becomes
Which suggests the APP_KEY variable in the first example is valid and the problem really is with username or password. Do these credentials need to be permissioned separately?
0 -
Does your password contain any special characters, such as '/', '\', '"', or '''?
0 -
Yes, plenty of those.
I wondered about that too but the web gui did not complain about me creating it all, so all seemed good…
0 -
As far as I know, some characters are treated differently when using them in a Python string.
You may try to use a raw string.
s = r"<string>"
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
- 688 Datastream
- 1.4K DSS
- 625 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 557 WebSocket API
- 39 FX Venues
- 15 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
- 276 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 1.9K Refinitiv Data Platform
- 695 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
- 105 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 92 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛