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

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • Gurpreet
    Gurpreet admin
    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()

Answers

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.