Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/finbourne/lusid-sdk-python

Python SDK for LUSID by FINBOURNE, a bi-temporal investment management data platform with portfolio accounting capabilities.
https://github.com/finbourne/lusid-sdk-python

bi-temporal data-platform finbourne fintech lusid openapi python

Last synced: 4 days ago
JSON representation

Python SDK for LUSID by FINBOURNE, a bi-temporal investment management data platform with portfolio accounting capabilities.

Awesome Lists containing this project

README

        

![LUSID_by_Finbourne](./resources/Finbourne_Logo_Teal.svg)

# Python SDK for the LUSID API

## Contents

- [Summary](#summary)
- [Versions](#versions)
- [Requirements](#requirements)
- [Installation](#installation)
- [Getting Started](#getting-started)
* [Environment variables](#environment-variables)
* [Secrets file](#secrets-file)
* [Example](#example)
- [Endpoints and models](#endpoints-and-models)

## Summary

This is the python SDK for the LUSID API, part of the [LUSID by FINBOURNE](https://www.finbourne.com/lusid-technology) platform. To use it you'll need a LUSID account - [sign up for free at lusid.com](https://www.lusid.com/app/signup).

LUSID is a bi-temporal investment management data platform with portfolio accounting capabilities - see https://support.lusid.com/knowledgebase/ to learn more.

For more details on other applications in the LUSID platform, see [Understanding all the applications in the LUSID platform](https://support.lusid.com/knowledgebase/article/KA-01787).

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](https://support.lusid.com/knowledgebase/article/KA-01786). To find out which category an API endpoint falls into, see the [swagger page](https://www.lusid.com/api/swagger/index.html).

This code is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.

## Versions

- API version: 0.11.7268
- SDK version: 2.1.668

## Requirements

- Python 3.7+

## Installation

If using [poetry](https://python-poetry.org/docs/)

```
poetry add lusid-sdk
```

If using [pip](https://pypi.org/project/pip/)

```
pip install lusid-sdk
```

Then import the package in your python file
```python
import lusid
```

## Getting Started

You'll need to provide some configuration to connect to the LUSID API - see the articles about [short-lived access tokens](https://support.lusid.com/knowledgebase/article/KA-01654) and a [long-lived Personal Access Token](https://support.lusid.com/knowledgebase/article/KA-01774). 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](sdk/lusid/extensions/configuration_options.py). For a code illustration of this configuration being overridden, please see the [example](#example).

### Environment variables

Required for a short-lived access token
```
FBN_TOKEN_URL
FBN_LUSID_URL
FBN_USERNAME
FBN_PASSWORD
FBN_CLIENT_ID
FBN_CLIENT_SECRET
```

Required for a long-lived access token
```
FBN_LUSID_URL
FBN_ACCESS_TOKEN
```

You can send your requests to the LUSID API via a proxy, by setting `FBN_PROXY_ADDRESS`. If your proxy has basic auth enabled, you must also set `FBN_PROXY_USERNAME` and `FBN_PROXY_PASSWORD`.

Other optional configuration

```bash
# 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
```

### 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
```json
{
"api":
{
"tokenUrl":"",
"lusidUrl":"https://.lusid.com/api",
"username":"",
"password":"",
"clientId":"",
"clientSecret":"",
}
}
```

Required for a long-lived access token
```json
{
"api":
{
"lusidUrl":"https://.lusid.com/api",
"accessToken":""
}
}
```

You can send your requests to the LUSID API via a proxy, by adding a proxy section. If your proxy has basic auth enabled, you must also supply a `username` and `password` in this section.

```json
{
"api":
{
"lusidUrl":"https://.lusid.com/api",
"accessToken":""
},
"proxy":
{
"address":"",
"username":"",
"password":""
}
}
```

Other optional configuration

```javascript
{
"api":
{
// 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
"totalTimeoutMs":, // the default is 1800000 (30 minutes)
"connectTimeoutMs":, // the default is 0 (no timeout)
"readTimeoutMs":, // the default is 0 (no timeout)
"rateLimitRetries": // the default is 2
}
}
```

### Example
```python
from lusid.exceptions import ApiException
from lusid.extensions.configuration_options import ConfigurationOptions
from lusid.models import *
from pprint import pprint
from lusid import (
SyncApiClientFactory,
AborApi
)

def main():

with open("secrets.json", "w") as file:
file.write('''
{
"api":
{
"tokenUrl":"",
"lusidUrl":"https://.lusid.com/api",
"username":"",
"password":"",
"clientId":"",
"clientSecret":""
}
}''')

# Use the lusid SyncApiClientFactory to build Api instances with a configured api client
# By default this will read config from environment variables
# Then from a secrets.json file found in the current working directory

# uncomment the below to use configuration overrides
# opts = ConfigurationOptions();
# opts.total_timeout_ms = 30_000

# uncomment the below to use an api client factory with overrides
# api_client_factory = SyncApiClientFactory(opts=opts)

api_client_factory = SyncApiClientFactory()

# Enter a context with an instance of the SyncApiClientFactory to ensure the connection pool is closed after use

# Create an instance of the API class
api_instance = api_client_factory.build(AborApi)
scope = 'scope_example' # str | The scope of the Abor.
code = 'code_example' # str | The code of the Abor.

# Objects can be created either via the class constructor, or using the 'from_dict' or 'from_json' methods
# Change the lines below to switch approach
# diary_entry_request = DiaryEntryRequest.from_json("")
# diary_entry_request = DiaryEntryRequest.from_dict({})
diary_entry_request = DiaryEntryRequest()

try:
# uncomment the below to set overrides at the request level
# api_response = api_instance.add_diary_entry(scope, code, diary_entry_request, opts=opts)

# [EXPERIMENTAL] AddDiaryEntry: Add a diary entry to the specified Abor.
api_response = api_instance.add_diary_entry(scope, code, diary_entry_request)
pprint(api_response)

except ApiException as e:
print("Exception when calling AborApi->add_diary_entry: %s\n" % e)

main()
```

## Endpoints and models

- See [Documentation for API Endpoints](sdk/README.md#documentation-for-api-endpoints) for a description of each endpoint
- See [Documentation for Models](sdk/README.md#documentation-for-models) for descriptions of the models used