Skip to main content

LUSID_by_Finbourne

Finbourne Python SDK

Contents

Summary

This is the python SDK for all of Finbourne's applications, part of the LUSID by FINBOURNE platform. To use it you'll need a LUSID account - sign up for free at lusid.com.

Some description For more details on other applications in the LUSID platform, see Understanding all the applications in the LUSID platform.

This sdk supports Production, Early Access, Beta and Experimental API endpoints. For more details on API endpoint categories, see What is the LUSID feature release lifecycle. To find out which category an API endpoint falls into, see the api reference.

This code is automatically generated by the OpenAPI Generator project.

Endpoints and models

Versions

  • SDK version: 0.2.5

Requirements

  • Python 3.10+

Installation

If using uv

uv add finbourne-sdk

If using pip

pip install finbourne-sdk

Then import the package in your python file

import finbourne.sdk

Getting Started

You'll need to provide some configuration to connect to the Merged OpenAPI Specification - see the articles about short-lived access tokens and a long-lived Personal Access Token. This configuration can be provided using a secrets file or environment variables.

For some configuration it is also possible to override the global configuration at the ApiClientFactory level, or at the request level. For the set of configuration which can be overridden, please see ConfigurationOptions. For a code illustration of this configuration being overridden, please see the example.

Environment variables

Required for a short-lived access token

FBN_TOKEN_URL
FBN_BASE_URL
FBN_USERNAME
FBN_PASSWORD
FBN_CLIENT_ID
FBN_CLIENT_SECRET

Required for a long-lived access token

FBN_BASE_URL
FBN_ACCESS_TOKEN

Other optional configuration

# sdk client timeouts in milliseconds - a value of 0 means no timeout, otherwise timeout values must be a positive integer
# please note - the chances of seeing a network issue increase with the duration of the request
# for this reason, rather than increasing the timeout, it will be more reliable to use an alternate polling style endpoint where these exist
FBN_TOTAL_TIMEOUT_MS # the default is 1800000 (30 minutes)
FBN_CONNECT_TIMEOUT_MS # the default is 0 (no timeout)
FBN_READ_TIMEOUT_MS # the default is 0 (no timeout)
FBN_RATE_LIMIT_RETRIES # the default is 2
# retries for conflicts (409), server errors (5xx) and errors returned with a Retry-After header - other client errors (4xx) are not retried
FBN_NUMBER_OF_RETRIES # the default is 3

Secrets file

The secrets file must be in the current working directory. By default the SDK looks for a secrets file called secrets.json

Required for a short-lived access token

{
  "profiles": {
    "default": {
        "tokenUrl":"<your-token-url>",
        "baseUrl":"https://<your-domain>.lusid.com",
        "username":"<your-username>",
        "password":"<your-password>",
        "clientId":"<your-client-id>",
        "clientSecret":"<your-client-secret>"
    }
}

Required for a long-lived access token

{
  "profiles": {
    "default": {
        "baseUrl":"https://<your-domain>.lusid.com",
        "accessToken":"<your-access-token>"
    }
}

Retries

The SDK automatically retries failed requests that are likely to succeed on a later attempt:

Response Retried? Setting that controls the number of retries Default
429 Too Many Requests Yes rate_limit_retries 2
409 Conflict Yes number_of_retries 3
Server errors (5xx) Yes number_of_retries 3
Any other error with a Retry-After header Yes number_of_retries 3
Any other client error (4xx), e.g. 400, 404 No - raised immediately - -

If the response has a Retry-After header, the SDK waits for that many seconds before retrying. Otherwise it uses exponential backoff with jitter (about 1-2s, then 2-4s, then 4-8s, capped at 60s).

Retries can be configured in the same places as the other configuration. Set a value to 0 to turn that type of retry off.

Using environment variables:

FBN_RATE_LIMIT_RETRIES=5
FBN_NUMBER_OF_RETRIES=1

Using the secrets file:

{
  "profiles": {
    "default": {
        "baseUrl":"https://<your-domain>.lusid.com",
        "accessToken":"<your-access-token>",
        "rateLimitRetries": 5,
        "numberOfRetries": 1
    }
}

For every request made by an api client factory, which takes precedence over environment variables and the secrets file:

from finbourne.sdk.extensions import SyncApiClientFactory
from finbourne.sdk.extensions.configuration_options import ConfigurationOptions

opts = ConfigurationOptions(rate_limit_retries=5, number_of_retries=1)
api_client_factory = SyncApiClientFactory(opts=opts)

For a single request, which takes precedence over everything else:

from finbourne.sdk.extensions import SyncApiClientFactory
from finbourne.sdk.extensions.configuration_options import ConfigurationOptions
import finbourne.sdk.services.lusid.api as lusid

api_client_factory = SyncApiClientFactory()
portfolios_api = api_client_factory.build(lusid.PortfoliosApi)

# fail fast on this request instead of retrying
portfolio = portfolios_api.get_portfolio(
    scope="my-scope",
    code="my-portfolio",
    opts=ConfigurationOptions(number_of_retries=0, rate_limit_retries=0)
)

Authentication Example

The minimum requirements for authentication are having the FBN_ACCESS_TOKEN and FBN_FINBOURNE/SDK_URL environment variables set, or a secrets.json file with the accessToken and finbourneSdkUrl fields populated.

Authenticate using environment variables:

from finbourne.sdk.extensions import SyncApiClientFactory

# The factory will automatically read from the FBN_* environment variables
api_client_factory = SyncApiClientFactory()

Authenticate using a secrets file:

import os
from finbourne.sdk.extensions import SyncApiClientFactory

os.environ["LUSID_SECRETS_FILE"] = "/path/to/my/secrets.json"
api_client_factory = SyncApiClientFactory()

Authenticate with configuration overrides:

from finbourne.sdk.extensions import SyncApiClientFactory
from finbourne.sdk.extensions.configuration_options import ConfigurationOptions

opts = ConfigurationOptions()
opts.total_timeout_ms = 30_000
api_client_factory = SyncApiClientFactory(opts=opts)

Using the Python async client:

from finbourne.sdk.extensions import ApiClientFactory
async with api_factory:
    application_meta_data_api = api_factory.build(lusid.ApplicationMetadataApi)
    await application_meta_data_api.get_lusid_versions_async()

Metadata

Release files for finbourne-sdk 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for finbourne-sdk 0.2.5
File Size Uploaded Provenance Actions
finbourne_sdk-0.2.5.tar.gz 4.1 MB Without provenance Details for finbourne_sdk-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for finbourne-sdk 0.2.5
File Interpreter ABI Platform Actions
finbourne_sdk-0.2.5-py3-none-any.whl Python 3 none any Details for finbourne_sdk-0.2.5-py3-none-any.whl

Total release size: 14.3 MB

Release files / finbourne_sdk-0.2.5.tar.gz

Download URL finbourne_sdk-0.2.5.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
2dcb6347d6f3953e307222133d07d08ef8e2d83208de03fb9d14ead5b97ebd18
BLAKE2b-256 checksum
How to use checksums
80077e1442b71847330c09c14da65c2f02ab4f4eaaf727cd698fa9bbec59f007
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.2

Release files / finbourne_sdk-0.2.5-py3-none-any.whl

Download URL finbourne_sdk-0.2.5-py3-none-any.whl
Size 10.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
23804df76c58237b94a1eb6aeefc683fe5d0095fa1cea15adb10944980c762ef
BLAKE2b-256 checksum
How to use checksums
110e87e13e163de97493d4c4825b358bb393561264dfdd051f146f2fb8a9b4c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.2

Security for finbourne-sdk 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page