lseg-data API

Hi, im trying to use lseg on Google Colab and I tried both EDP_API and EIKON_API… None worked here:

!pip install lseg.data

import lseg.data as ld

ld.open_session(app_key='edsf….fdss')

An error occurred while requesting URL('http://localhost:9000/api/status').ConnectError('[Errno 99] Cannot assign requested address')An error occurred while requesting URL('http://localhost:9060/api/status').ConnectError('[Errno 99] Cannot assign requested address')Error: no proxy address identified.Check if Desktop is running.An error occurred while requesting URL('http://localhost:9000/api/handshake').ConnectError('[Errno 99] Cannot assign requested address')Error on handshake url http://localhost:9000/api/handshake : ConnectError('[Errno 99] Cannot assign requested address')An error occurred while requesting URL('http://localhost:9000/api/status').ConnectError('[Errno 99] Cannot assign requested address')An error occurred while requesting URL('http://localhost:9060/api/status').ConnectError('[Errno 99] Cannot assign requested address')Error: no proxy address identified.Check if Desktop is running.An error occurred while requesting URL('http://localhost:9000/api/handshake').ConnectError('[Errno 99] Cannot assign requested address')Error on handshake url http://localhost:9000/api/handshake : ConnectError('[Errno 99] Cannot assign requested address')
<lseg.data.session.Definition object at 0x7a383f359350 {name='workspace'}>




ps: on pip install lseg.data, the output:

Collecting lseg.data Downloading lseg_data-2.1.1-py3-none-any.whl.metadata (10 kB)Collecting appdirs~=1.4.4 (from lseg.data) Downloading appdirs-1.4.4-py2.py3-none-any.whl.metadata (9.0 kB)Collecting pyee<=12,>=9.0.4 (from lseg.data) Downloading pyee-12.0.0-py3-none-any.whl.metadata (2.8 kB)Collecting httpx<0.28,>=0.18.0 (from lseg.data) Downloading httpx-0.27.2-py3-none-any.whl.metadata (7.1 kB)Requirement already satisfied: httpcore<1.1.0 in /usr/local/lib/python3.11/dist-packages (from lseg.data) (1.0.9)Requirement already satisfied: numpy in /usr/local/lib/python3.11/dist-packages (from lseg.data) (2.0.2)Requirement already satisfied: pandas<3.0,>=2.0 in /usr/local/lib/python3.11/dist-packages (from lseg.data) (2.2.2)Requirement already satisfied: python-dateutil in /usr/local/lib/python3.11/dist-packages (from lseg.data) (2.9.0.post0)Requirement already satisfied: requests in /usr/local/lib/python3.11/dist-packages (from lseg.data) (2.32.3)Requirement already satisfied: scipy in /usr/local/lib/python3.11/dist-packages (from lseg.data) (1.15.3)Requirement already satisfied: tenacity in /usr/local/lib/python3.11/dist-packages (from lseg.data) (9.1.2)Collecting watchdog (from lseg.data) Downloading watchdog-6.0.0-py3-none-manylinux2014_x86_64.whl.metadata (44 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.3/44.3 kB 1.9 MB/s eta 0:00:00Requirement already satisfied: websocket-client!=1.5.0,!=1.5.2,>=1.5 in /usr/local/lib/python3.11/dist-packages (from lseg.data) (1.8.0)Collecting pyhumps<4.0.0,>=3.0.2 (from lseg.data) Downloading pyhumps-3.8.0-py3-none-any.whl.metadata (4.0 kB)Requirement already satisfied: jinja2<4.0.0,>=3.0.3 in /usr/local/lib/python3.11/dist-packages (from lseg.data) (3.1.6)Requirement already satisfied: simplejson in /usr/local/lib/python3.11/dist-packages (from lseg.data) (3.20.1)Requirement already satisfied: certifi in /usr/local/lib/python3.11/dist-packages (from httpcore<1.1.0->lseg.data) (2025.4.26)Requirement already satisfied: h11>=0.16 in /usr/local/lib/python3.11/dist-packages (from httpcore<1.1.0->lseg.data) (0.16.0)Requirement already satisfied: anyio in /usr/local/lib/python3.11/dist-packages (from httpx<0.28,>=0.18.0->lseg.data) (4.9.0)Requirement already satisfied: idna in /usr/local/lib/python3.11/dist-packages (from httpx<0.28,>=0.18.0->lseg.data) (3.10)Requirement already satisfied: sniffio in /usr/local/lib/python3.11/dist-packages (from httpx<0.28,>=0.18.0->lseg.data) (1.3.1)Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2<4.0.0,>=3.0.3->lseg.data) (3.0.2)Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.11/dist-packages (from pandas<3.0,>=2.0->lseg.data) (2025.2)Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.11/dist-packages (from pandas<3.0,>=2.0->lseg.data) (2025.2)Requirement already satisfied: typing-extensions in /usr/local/lib/python3.11/dist-packages (from pyee<=12,>=9.0.4->lseg.data) (4.13.2)Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.11/dist-packages (from python-dateutil->lseg.data) (1.17.0)Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests->lseg.data) (3.4.2)Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests->lseg.data) (2.4.0)Downloading lseg_data-2.1.1-py3-none-any.whl (872 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 872.3/872.3 kB 16.2 MB/s eta 0:00:00Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)Downloading httpx-0.27.2-py3-none-any.whl (76 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 76.4/76.4 kB 6.3 MB/s eta 0:00:00Downloading pyee-12.0.0-py3-none-any.whl (14 kB)Downloading pyhumps-3.8.0-py3-none-any.whl (6.1 kB)Downloading watchdog-6.0.0-py3-none-manylinux2014_x86_64.whl (79 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.1/79.1 kB 6.2 MB/s eta 0:00:00Installing collected packages: pyhumps, appdirs, watchdog, pyee, httpx, lseg.data Attempting uninstall: httpx Found existing installation: httpx 0.28.1 Uninstalling httpx-0.28.1: Successfully uninstalled httpx-0.28.1ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.google-genai 1.14.0 requires httpx<1.0.0,>=0.28.1, but you have httpx 0.27.2 which is incompatible.Successfully installed appdirs-1.4.4 httpx-0.27.2 lseg.data-2.1.1 pyee-12.0.0 pyhumps-3.8.0 watchdog-6.0.0

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    a@augusto_krappa

    Thank you for reaching out to us.

    Please check the answers on the following discussions.

    To use the library with the desktop session, the Workspace application is required to run on the same machine as a Python environment (Google Colab server). I am not sure if is possible to run the Workspace application which is a Windows application on the Colab server machine.

    Otherwise, you need to use the platform.ldp session which requires the RDP's username, password, and application key.

       "sessions": {
    "default": "platform.ldp",
    "platform": {
    "ldp": {
    "app-key": "YOUR APP KEY GOES HERE!",
    "username": "YOUR LDP LOGIN OR MACHINE GOES HERE!",
    "password": "YOUR LDP PASSWORD GOES HERE!"
    },

    Or the code:

    session = ld.session.platform.Definition(
    app_key = APP_KEY,
    grant = ld.session.platform.GrantPassword(
    username = RDP_LOGIN,
    password = RDP_PASSWORD
    )
    ).get_session()

    The example is on GitHub.

  • It didnt work here. I tried both ways:

    1)
    sessions = {    "default": "platform.ldp",    "platform": {        "ldp": {            "app-key": os.environ['REFINITIV_EDP_API'],            "username": os.environ['REFINITIV_USER'],            "password": os.environ['REFINITIV_PASSWORD']        }    }}
    ld.open_session(sessions)

    ---------------------------------------------------------------------------
    
    KeyError                                  Traceback (most recent call last)
    
    /usr/local/lib/python3.11/dist-packages/lseg/data/_configure.py in get_param(self, param)    302         try:--> 303             return self[param]    304         except KeyError:
    

    7 frames

    KeyError: "sessions.{'default': 'platform.ldp', 'platform': {'ldp': {'app-key': 'sdgs………bsd', 'username': 'zxv……………xvsv', 'password': 'bdsb………….fbbf'}}}"
    
    During handling of the above exception, another exception occurred:
    
    AttributeError                            Traceback (most recent call last)
    
    AttributeError: Config object doesn't has 'sessions.{'default': 'platform.ldp', 'platform': 'ldp': {'app-key': 'sdgs………bsd', 'username': 'zxv……………xvsv', 'password': 'bdsb………….fbbf'}}' attribute
    
    During handling of the above exception, another exception occurred:
    
    NameError                                 Traceback (most recent call last)
    
    /usr/local/lib/python3.11/dist-packages/lseg/data/_access_layer/session.py in open_session(name, app_key, config_name)     52     except Exception:     53         config_name = f" {config_name}" if config_name else ""---> 54         raise NameError(     55             f"Cannot open session {name}\nThis session is not defined in the{config_name} configuration file"     56         )
    
    NameError: Cannot open session {'default': 'platform.ldp', 'platform': {'ldp': {'app-key': 'sdgs………bsd', 'username': 'zxv……………xvsv', 'password': 'bdsb………….fbbf'}}}This session is not defined in the configuration file
    




    2)

    session = ld.session.platform.Definition(
        app_key = os.environ['REFINITIV_EDP_API'],
        grant = ld.session.platform.GrantPassword(
            username = os.environ['REFINITIV_USER'],
            password = os.environ['REFINITIV_PASSWORD']
        )
    ).get_session()

    ld.open_session(session)

    ---------------------------------------------------------------------------
    
    KeyError                                  Traceback (most recent call last)
    
    /usr/local/lib/python3.11/dist-packages/lseg/data/_configure.py in get_param(self, param)    302         try:--> 303             return self[param]    304         except KeyError:
    

    7 frames

    KeyError: 'sessions.PlatformSession\n\t\tname = default\n\t\tconnection = PlatformDataConnection\n\t\tstream_auto_reconnection = True\n\t\tauthentication_token_endpoint_url = https://api.refinitiv.com/auth/oauth2/v1/token\n\t\tsignon_control = False\n\t\tserver_mode = False\n\t\tstate = OpenState.Closed\n\t\tsession_id = 9\n\t\tlogger_name = sessions.platform.default.9'
    
    During handling of the above exception, another exception occurred:
    
    AttributeError                            Traceback (most recent call last)
    
    AttributeError: Config object doesn't has 'sessions.PlatformSessionname = defaultconnection = PlatformDataConnectionstream_auto_reconnection = Trueauthentication_token_endpoint_url = https://api.refinitiv.com/auth/oauth2/v1/tokensignon_control = Falseserver_mode = Falsestate = OpenState.Closedsession_id = 9logger_name = sessions.platform.default.9' attribute
    
    During handling of the above exception, another exception occurred:
    
    NameError                                 Traceback (most recent call last)
    
    /usr/local/lib/python3.11/dist-packages/lseg/data/_access_layer/session.py in open_session(name, app_key, config_name)     52     except Exception:     53         config_name = f" {config_name}" if config_name else ""---> 54         raise NameError(     55             f"Cannot open session {name}\nThis session is not defined in the{config_name} configuration file"     56         )
    
    NameError: Cannot open session PlatformSessionname = defaultconnection = PlatformDataConnectionstream_auto_reconnection = Trueauthentication_token_endpoint_url = https://api.refinitiv.com/auth/oauth2/v1/tokensignon_control = Falseserver_mode = Falsestate = OpenState.Closedsession_id = 9logger_name = sessions.platform.default.9This session is not defined in the configuration file
    
  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @augusto_krappa

    For the first method, you need to add it in the configuration file (lseg-data.config.json). Then, set the LD_LIB_CONFIG_PATH environment variable, as shown in the example.

    import os
    os.environ["LD_LIB_CONFIG_PATH"] = "../../Configuration"

    For the second method, the code looks like this:

    session = ld.session.platform.Definition(
        app_key = APP_KEY, 
        grant = ld.session.platform.GrantPassword(
            username = RDP_LOGIN, 
            password = RDP_PASSWORD
        ),
        signon_control = True
    ).get_session()
    session.open()
    ld.session.set_default(session)
    
  • worked! thank you.