-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Armin Ghofrani
authored
Apr 26, 2023
1 parent
edc855b
commit 96a218b
Showing
1 changed file
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,67 @@ | ||
# DitchCarbon Python Wrapper | ||
<div align="center"> | ||
<img src="https://ditchcarbon.com/wp-content/uploads/2021/05/Group-119.svg"><br> | ||
</div> | ||
|
||
Use this library to interact with the DitchCarbon API. | ||
----------------- | ||
|
||
# ditchcarbon-python | ||
|
||
![PyPI](https://img.shields.io/pypi/v/ditchcarbon-python?color=5CB381) | ||
![PyPI - Downloads](https://img.shields.io/pypi/dm/ditchcarbon-python?color=5CB381) | ||
![PyPI - License](https://img.shields.io/pypi/l/ditchcarbon-python?color=5CB381) | ||
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ditchcarbon-python?color=5CB381) | ||
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/ditchthis/ditchcarbon-python?color=5CB381) | ||
[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) | ||
|
||
## What is it? | ||
|
||
**ditchcarbon-python** is the official Python wrapper for the DitchCarbon API. DitchCarbon calculates the carbon impact of almost anything using a combination of GHG protocol approved calculations and an unparalleled database of company and product disclosures. | ||
|
||
## Where to get it? | ||
|
||
You can install the library via PyPI (hosted [here](https://pypi.org/project/ditchcarbon-python)): | ||
|
||
```sh | ||
pip3 install ditchcarbon-python | ||
``` | ||
|
||
The source code is currently hosted on GitHub, [here](https://github.com/ditchthis/ditchcarbon-python). | ||
|
||
## How to use it? | ||
|
||
First, import and initialise the library with your API token: | ||
|
||
```python | ||
from ditchcarbon_python import Client | ||
client = Client(token="YOUR_TOKEN") | ||
ditchcarbon = Client(token="YOUR_TOKEN") | ||
``` | ||
|
||
Then, use it: | ||
|
||
```python | ||
# Activities | ||
ditchcarbon.activities.retrieve(1) | ||
ditchcarbon.activities.retrieve_many(**params) | ||
ditchcarbon.activities.retrieve_assessment(1, **params) | ||
ditchcarbon.activities.retrieve_categories(**params) | ||
|
||
client.products.calculate_emissions(manufacturer="Apple", name="iPhone 12", price=1000) | ||
# Categories | ||
ditchcarbon.categories.search(**params) | ||
|
||
# Expenses | ||
ditchcarbon.expenses.calculate_emissions(**params) | ||
|
||
# Products | ||
ditchcarbon.products.calculate_emissions(**params) | ||
|
||
# Servers | ||
ditchcarbon.servers.find(**params) | ||
ditchcarbon.servers.retrieve(1) | ||
ditchcarbon.servers.calculate_emissions(1, **params) | ||
|
||
# Suppliers | ||
ditchcarbon.suppliers.calculate_emissions(**params) | ||
``` | ||
View our API reference [here](https://docs.ditchcarbon.com/reference). | ||
|
||
## Documentation and Help | ||
View our API reference [here](https://docs.ditchcarbon.com/reference). For usage questions, feel free to contact us [here](mailto:enquiries@ditchcarbon.com). |