{"library":"lusid-sdk","title":"LUSID SDK for Python","description":"The `lusid-sdk` is the official Python SDK for interacting with the LUSID API, a cloud-native investment data platform. It enables programmatic management of portfolios, holdings, transactions, reference data, and various other financial data entities within the LUSID ecosystem. The SDK is actively maintained by FINBOURNE, with frequent releases often several times a month to reflect API updates and feature enhancements.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install lusid-sdk"],"cli":null},"imports":["from lusid_sdk.utilities import ApiClientFactory","from lusid_sdk.api import PortfoliosApi"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom lusid_sdk.utilities import ApiClientFactory\nfrom lusid_sdk.api import PortfoliosApi\n\n# Configure environment variables for LUSID authentication.\n# These can be set in your shell or via a .env file.\n# Example for Personal Access Token (PAT):\n# export LUSID_FBN_TOKEN='your_finbourne_token'\n# export LUSID_API_URL='https://lusid.finbourne.com/api'\n# export LUSID_APP_NAME='my-python-app'\n#\n# Example for OAuth 2.0 Client Credentials:\n# export LUSID_CLIENT_ID='your_client_id'\n# export LUSID_CLIENT_SECRET='your_client_secret'\n# export LUSID_TOKEN_URL='https://identity.finbourne.com/oauth/token'\n# export LUSID_API_URL='https://lusid.finbourne.com/api'\n# export LUSID_APP_NAME='my-python-app'\n\ntry:\n    # Create an ApiClientFactory instance. It picks up config from environment variables.\n    # For LUSID_FBN_TOKEN, you would use: ApiClientFactory()\n    # For OAuth, you might need to pass details if not in env vars, but env vars are preferred.\n    api_factory = ApiClientFactory()\n\n    # Get a specific API client, e.g., for portfolios\n    portfolios_api: PortfoliosApi = api_factory.build(PortfoliosApi)\n\n    # List all portfolios\n    paginated_response = portfolios_api.list_portfolios(\n        limit=5,\n        scope='default'\n    )\n\n    print(f\"Successfully connected to LUSID. Found {paginated_response.paging.total_items} portfolios.\")\n    for portfolio in paginated_response.values:\n        print(f\"- {portfolio.display_name} ({portfolio.scope}/{portfolio.code})\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    if \"401 Unauthorized\" in str(e):\n        print(\"Please check your LUSID authentication details (LUSID_FBN_TOKEN or OAuth credentials).\")\n    elif \"Missing configuration\" in str(e):\n        print(\"Ensure LUSID_API_URL and authentication environment variables are set.\")","lang":"python","description":"This quickstart demonstrates how to initialize the `ApiClientFactory`, authenticate using environment variables (supporting both Personal Access Token and OAuth2 Client Credentials flows), and make a simple call to list portfolios. Ensure the necessary LUSID environment variables are set before running.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}