| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
The Python client for the Lightkeeper Web API. It handles the OAuth2 client credentials flow, secure credential storage, and returns API data as pandas data frames.
If you'd like to know more about API access to your existing Lightkeeper environment, or have any enquiries about working with Lightkeeper, please contact us.
Requires python>=3.10.
pip install lkapiFor development on this repo, use uv from the python/ directory:
uv sync
uv run --group dev pytestPrior to using the API, you will need a client_id and client_secret from Lightkeeper. These credentials are required to make requests against your Lightkeeper environment.
The quickest start is to copy a url from the Lightkeeper UI (Grid > Api Routes) and pass credentials directly:
import lkapi
frames = lkapi.get_grid_data(
url="https://YOUR-ENVIRONMENT.lightkeeperhq.com/lightstation/api/reports/query/layout/YOUR_GRID/v2?focus=PORT&rollup=ISSUER&bd=20250101&ed=20250131",
username="YOUR_CLIENT_ID",
password="YOUR_CLIENT_SECRET",
)The keys in the returned dictionary are:
If you would like to work with the raw response object instead, set debug=True in the get_grid_data call.
In a longer term development or production environment, store credentials once in secure credential storage (via the keyring python module if installed) or environment variables, rather than passing them in code.
import lkapi
# a long-lived credential manager which stores to the keyring if available or environment variables otherwise
credential_manager = lkapi.get_credential_manager(url="https://YOUR-ENVIRONMENT.lightkeeperhq.com")
credential_manager.set_secret('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET')The CredentialManager base class can be extended to provide custom credential storage mechanisms.
With credentials stored, requests can be built from components instead of a copied url or sourced from the API source information found in the Grid:
import lkapi
frames = lkapi.get_grid_data(
grid="YOUR_LAYOUT_ID",
environment="YOUR-ENVIRONMENT",
portfolio="LKP_YOUR_PORTFOLIO__PORT",
rollup="ISSUER",
begin_date="20250101",
end_date="20250131",
)If you have any suggestions or requests regarding examples, features or additional languages for clients, please submit an issue to this repository or reach out to Lightkeeper support.
| Back | FazBrowse Home | New Git URL |