Hide code cell content

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

Authenticating with a configuration file

By default, the LSEG Data Library for Python expects you to provide credentials in a configuration file named lseg-data.config.json.

At minimum, it must include your application key, as well as the username and password you use to access the LSEG web portal.

Start by copying and pasting the following snippet into a file named lseg-data.config.json. Replace the placeholder values with your credentials.

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

Note

A fuller example of all the configuration options available can be found in the official documentation.

Unless you provide further instruction your Python script will expect the configuration file to be located in the same directory as the script you are running. Once the file is in place, you can import the library and open a session by running the following code:

import lseg.data as ld

ld.open_session()
<lseg.data.session.Definition object at 0x7fef48ed38c0 {name='rdp'}>

Verify the session is open by executing a query for the current price of Thomson Reuters stock. You should back a table of data.

ld.get_history('TRI.N')
TRI.N TRDPRC_1 HIGH_1 LOW_1 ACVOL_UNS OPEN_PRC BID ASK TRNOVR_UNS VWAP BLKCOUNT BLKVOLUM NUM_MOVES TRD_STATUS SALTIM VWAP_VOL
Date
2026-07-31 98.26 98.69 96.5 28715 96.57 98.04 98.33 2806630 97.7409 <NA> <NA> 873 1 71949 28715
2026-08-03 101.56 102.93 100.305 28993 101.215 101.36 101.76 2948966 101.713 <NA> <NA> 645 1 71995 28993
2026-08-04 109.0 109.36 101.255 88028 101.255 108.23 109.29 9389641 106.6665 <NA> <NA> 1603 1 71999 88028
2026-08-05 98.6 112.91 97.89 99849 110.51 98.46 98.95 10109799 101.2509 <NA> <NA> 1790 1 71996 99849
2026-08-06 100.14 101.48 96.405 70698 101.42 100.07 100.16 6979123 98.7174 <NA> <NA> 1380 1 71987 70698
2026-08-07 101.805 103.91 99.09 20045 99.62 101.79 101.84 2049169 102.2284 <NA> <NA> 403 1 71995 20045
2026-08-10 104.425 104.425 101.005 31843 101.005 104.18 104.44 3306961 103.8521 <NA> <NA> 605 1 71995 31843
2026-08-11 104.89 105.8 102.475 20829 103.59 104.69 105.0 2186434 104.9707 <NA> <NA> 355 1 71938 20829
2026-08-12 102.49 103.95 101.12 18365 103.53 102.42 102.74 1868755 101.7563 <NA> <NA> 457 1 71958 18365
2026-08-13 106.0 106.37 102.23 18785 104.0 105.97 106.16 1964364 104.5709 <NA> <NA> 422 1 71995 18785
2026-08-14 103.56 106.27 102.74 11157 106.27 103.53 103.62 1154574 103.4842 <NA> <NA> 362 1 71967 11157
2026-08-17 99.09 102.4 98.84 20578 102.39 98.98 99.08 2056080 99.9164 <NA> <NA> 411 1 71978 20578
2026-08-18 100.91 102.6 100.9 25970 101.305 100.9 101.09 2639534 101.6378 <NA> <NA> 520 1 71999 25970
2026-08-19 104.955 106.81 103.31 18005 103.31 104.86 105.68 1902241 105.6507 <NA> <NA> 428 1 71931 18005
2026-08-20 105.91 106.56 104.19 24685 104.89 105.79 106.05 2613515 105.8746 <NA> <NA> 536 1 71995 24685
2026-08-21 105.54 106.81 105.01 33407 106.1 105.38 105.66 3540136 105.9699 <NA> <NA> 542 1 71957 33407
2026-08-24 108.63 109.26 105.77 23161 105.77 108.5 108.77 2507374 108.2585 <NA> <NA> 474 1 71994 23161
2026-08-25 104.385 107.39 104.26 19580 105.0 104.3 104.52 2061719 105.2972 <NA> <NA> 425 1 71991 19580
2026-08-26 102.48 105.21 102.095 31530 104.57 102.36 102.65 3244182 102.8919 <NA> <NA> 607 1 71956 31530
2026-08-27 104.76 107.62 103.39 35716 103.39 104.62 104.89 3765602 105.4318 <NA> <NA> 619 1 71999 35716

The library expects you to close your session when you’re finished. You can do so by running the following code:

ld.close_session()

Specifying a configuration file

If you want to store your configuration file in a different location, you can specify its path when you open a session.

For example, if you gave your configuration file with a shorter name and stored it in a subdirectory named config, you could open a session by running something like the following:

ld.open_session(config_name="./config/lseg.json")