Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chloris_app_sdk-1.2.2.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chloris_app_sdk-1.2.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file chloris_app_sdk-1.2.2.tar.gz.

File metadata

  • Download URL: chloris_app_sdk-1.2.2.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for chloris_app_sdk-1.2.2.tar.gz
Algorithm Hash digest
SHA256 73506f8bfcc619171ebec1fb94e2350b79eeb4ac3ed4b4996bf093fcc5450a54
MD5 b4d79f22ed904fed68a59b4f20d78bff
BLAKE2b-256 1d7c036c3a78f132b1cfe43a0fbe4bce8df8b0a6ccfc77f421b0b294f932c650

See more details on using hashes here.

File details

Details for the file chloris_app_sdk-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for chloris_app_sdk-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 859cb30866429b164ade3dfc64b2fbec63479091d9b05fc78cc7a58a960d59bf
MD5 420f14171058f581c2a9e388bb2b93a1
BLAKE2b-256 09b770565df8c7a064486b9af785dab524434b8f459263cac3a3f9faecbf3a83

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page