cloverly-python-module

Cloverly API Module for Python


Keywords
carbon-emissions, carbon-offsets, cloverly, python, sustainability
License
MIT
Install
pip install cloverly-python-module==0.7.0

Documentation

Cloverly Python Module

PyPI version License: MIT

The Cloverly API Python module

Usage

Requirements

You should be signed up on the Cloverly Dashboard so that you can create and manage cloverly resources.

Installation

To easily install or upgrade to the latest release, use pip.

pip3 install --upgrade cloverly-python-module
Table of Contents (click to open)
  1. Getting started
  2. Resources
  3. API Versioning
  4. Limitations

Getting Started

  1. Log in to your cloverly dashboard and grab your public API key.
  2. Set up a cloverly session using clover.CloverlyResource.activate_session like so:
import cloverly

cloverly.CloverlyResource.activate_session(api_key=API_KEY, version=API_VERSION)
  1. Now you can perform any resource actions as needed in an authenticated section
  2. It's generally best practice to clear your session once you're done like so:
cloverly.CloverlyResource.clear_session()

Resources

As of 06/08/2021, there are 4 key resource classes:

The resource classes are what allow you to create, update, delete and list resource endpoints. Resources also implement subpoints in accordance with Cloverly's API documentation. For example, the /estimates/shipping endpoint can be accessed via the Shipping sub class:

cloverly.Estimate.Shipping(_from={"zip":"35209"}, _to={"zip":"94043"})

The above code snippet would return an instance of the Estimate class. All attributes returned in the expected payload would be able to be accessed as instance attributes, like estimate.slug

API Versioning

Versioning of the API can be passed to the python module in the session activation. Essentially, this populates the following in an API url:

https://api.cloverly.com/VERSION_HERE/estimates

Limitations

Currently there is no support for:

  • asynchronous requests
  • persistent connections