A package created with a setuptools tutorial. See article link for more details.
Project description
The Chloris Platform Python SDK
The Chloris Platform Python SDK (chloris-app-sdk) is a Python package that provides a convenient interface to the Chloris Platform API. It is designed to be used by both humans and machines, but if you are a human you may find it easier to use the Chloris Platform web interface. Note that the API is only available for use with premium organizations, please contact us if you are interested in using the API.
See the API documentation for more information about the Chloris Platform API.
See the Python API reference for the full list of functions and classes available in the SDK.
Installation
To install the Chloris Platform Python SDK run:
pip install chloris_app_sdk
Usage
Authentication
The Chloris Platform API uses OAuth 2.0 for authentication. You can authenticate using either a refresh token or an ID token. Refresh tokens are long-lived and can be used to generate new ID tokens. ID tokens are short-lived and can be used directly for authentication. Refresh tokens are recommended for use in scripts and ID tokens are recommended for use in web applications.
See the Chloris Platform API documentation for more information about authentication.
Listing sites
Here is an example which lists active sites in your organization, then prints the annual stock for the first site, and then the average biomass density for 2015:
from chloris_app_sdk import ChlorisAppClient
from chloris_app_sdk.utils import to_tco2e
# create the client
client = ChlorisAppClient(
organization_id="your-organization-id",
refresh_token="your-refresh-token", # env: CHLORIS_REFRESH_TOKEN
# or
# id_token="your-id-token" # env: CHLORIS_ID_TOKEN
)
# list all active sites and get the stats for the first one
reporting_units = client.list_active_sites()
stats = client.get_reporting_unit_stats(reporting_units[0])
# print the annual stock (in tons co2e) for each year
for i, year in enumerate(stats["annualYears"]):
stock = to_tco2e(stats["annualStock"][i])
print(f"{year}: {stock} tco₂e")
# calculate average biomass density in t/ha for 2015:
i = stats["annualYears"].index(2015)
biomass_density = stats["annualStock"][i] / (stats["annualAreaKm2"][i] * 100)
print(f"Average biomass density in 2015: {biomass_density} t/ha")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chloris_app_sdk-1.0.13.tar.gz.
File metadata
- Download URL: chloris_app_sdk-1.0.13.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24d3f35127d6035c52f80348f54f32493769b0ea45632700f3e627524d86f71d
|
|
| MD5 |
d24eebfa99409d5e7ba08d39abbf5d42
|
|
| BLAKE2b-256 |
60c987ad3c3a792948a5e55aeba7efb5d4ee76f411ce6883a060e3092d4ba8ba
|
File details
Details for the file chloris_app_sdk-1.0.13-py3-none-any.whl.
File metadata
- Download URL: chloris_app_sdk-1.0.13-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f1451e52276636100341791167581150bed868c4ab8f922b746b1009923f587
|
|
| MD5 |
7bd0f9356e6e839f69806dc6d064d396
|
|
| BLAKE2b-256 |
f51b3f0212c41a9e3becdbaa6c77f7c2edc1dee1e8137c5448f6e1e035a6e5c9
|