Views:

Related resources:

Explanation

Tutorials

Reference

Every call made to the LUSID API must be authorised by an API access token.

You can call the LUSID REST API directly, or perhaps more conveniently using an appropriate language LUSID SDK. The SDKs have helper classes that automate the process of obtaining an API access token and refreshing it upon expiry.

To enable an SDK to obtain an API access token, you must pass in your LUSID username and password, client ID and client secret, and dedicated Okta token URL using one of the following methods.

Using a secrets file

You can store your LUSID username, password, client ID and client secret in a file on disk and make it available to the SDK. To do this:

  1. Sign in to the LUSID web app using the credentials of a LUSID administrator.
  2. From the left-hand menu, select Identity and access > Applications.
  3. On the Applications dashboard, click the  View icon for an appropriate application. See how to create an application.
  4. In the Export credentials area, make sure Secrets file is selected and copy the data to the clipboard:
  5. Paste the data into an appropriate local file, for example secrets.json.
  6. In the file, replace <password> with your actual LUSID account password.

The following snippet demonstrates passing the secrets file location into the Python SDK. An API access token is automatically generated each time a method is called:

import lusid 
# Obtain an API access token and automatically refresh it: 
secrets_file_path = "/path/to/secrets.json" 
config = lusid.utilities.ApiConfigurationLoader.load(secrets_file_path) 
api_factory = lusid.utilities.ApiClientFactory( 
   token=lusid.utilities.RefreshingToken(config), 
   api_secrets_filename=secrets_file_path 
) 
# Build the instruments API: 
instruments_api = api_factory.build(lusid.api.InstrumentsApi) 
# Retrieve the instrument master: 
response = instruments_api.list_instruments

Using environment variables

You can store your LUSID username, password, client ID and client secret as environment variables and make them available to the SDK. To do this:

  1. Sign in to the LUSID web app using the credentials of a LUSID administrator.
  2. From the left-hand menu, select Identity and access > Applications.
  3. On the Applications dashboard, click the  View icon of an appropriate application. See how to create an application.
  4. In the Export credentials area, make sure Env variables for either Linux or Windows is selected and copy the data to the clipboard:
  5. Run the first five commands in an appropriate shell as-is to set those environment variables.
  6. For the last command, replace <password> with your actual LUSID account password and then run the command to set the FBN_PASSWORD environment variable.

The following snippet demonstrates passing environment variables into the Python SDK. An API access token is automatically generated each time a method is called:

import lusid 
# Obtain an API access token and automatically refresh it: 
config = lusid.utilities.ApiConfigurationLoader.load() 
api_factory = lusid.utilities.ApiClientFactory( 
   token=lusid.utilities.RefreshingToken(config) 
) 
# Build the instruments API: 
instruments_api = api_factory.build(lusid.api.InstrumentsApi) 
# Retrieve the instrument master: 
response = instruments_api.list_instruments