Async Python client for Energy Tracker API
Project description
Energy Tracker API Client
Async Python client for the Energy Tracker public REST API.
Installation
pip install energy-tracker-api
Requirements
- Python 3.14+
- Personal Access Token from Energy Tracker
Quick Start
import asyncio
from decimal import Decimal
from energy_tracker_api import EnergyTrackerClient, CreateMeterReadingDto
async def main():
async with EnergyTrackerClient(access_token="your-token") as client:
# List devices
devices = await client.devices.list_standard()
# Create a meter reading
reading = CreateMeterReadingDto(value=Decimal("12345.67"))
await client.meter_readings.create(
device_id="your-device-id",
meter_reading=reading,
)
asyncio.run(main())
Resources
The client exposes three resource groups — all endpoints, parameters, and DTOs are documented in the OpenAPI specification.
| Resource | Methods |
|---|---|
client.devices |
list_standard(), list_virtual() |
client.meter_readings |
list(), create(), delete(), export() |
client.environments |
list(), get(), create(), delete(), create_entry(), delete_entry() |
Configuration
client = EnergyTrackerClient(
access_token="your-token",
base_url="https://custom-api.example.com", # Optional
timeout=30, # Optional, default: 10s
)
Error Handling
All API errors inherit from EnergyTrackerAPIError and carry an api_message list with details from the server.
from energy_tracker_api import (
EnergyTrackerAPIError,
ValidationError,
AuthenticationError,
ForbiddenError,
ResourceNotFoundError,
ConflictError,
RateLimitError,
)
try:
await client.meter_readings.create(device_id, reading)
except RateLimitError as e:
print(f"Retry after {e.retry_after}s")
except EnergyTrackerAPIError as e:
print(e.api_message)
Development
make install-dev # Install dependencies
make test # Run tests
make type-check # mypy
make format # black + isort
make lint # Linters
License
MIT
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
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 energy_tracker_api-2.0.0.tar.gz.
File metadata
- Download URL: energy_tracker_api-2.0.0.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dc11fe68b460458eb76cf51d182ba7498fea53233b0a1fc6be1c80e98b6f139
|
|
| MD5 |
06997c0d48523ccd2f8400cbed0efc87
|
|
| BLAKE2b-256 |
408eec074e78485d4b7fd3c5ec10c0aa2345d17c00032faf10ebf92c1b370f0a
|
Provenance
The following attestation bundles were made for energy_tracker_api-2.0.0.tar.gz:
Publisher:
release.yml on energy-tracker/api-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
energy_tracker_api-2.0.0.tar.gz -
Subject digest:
3dc11fe68b460458eb76cf51d182ba7498fea53233b0a1fc6be1c80e98b6f139 - Sigstore transparency entry: 953272372
- Sigstore integration time:
-
Permalink:
energy-tracker/api-client-python@55c2655b01c2f9a127309e1402f40e39d18992b7 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/energy-tracker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55c2655b01c2f9a127309e1402f40e39d18992b7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file energy_tracker_api-2.0.0-py3-none-any.whl.
File metadata
- Download URL: energy_tracker_api-2.0.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f8ff2fc7f3b07d0d49e854b1cd972cdc66c5d6cdb4ef6fc36511277a00d1a08
|
|
| MD5 |
7e632f56659f23b7f8c5cbacb53903b4
|
|
| BLAKE2b-256 |
bac27094b473a57611725c55e1159a54b6e5e17dae864497a014c6cce0a56966
|
Provenance
The following attestation bundles were made for energy_tracker_api-2.0.0-py3-none-any.whl:
Publisher:
release.yml on energy-tracker/api-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
energy_tracker_api-2.0.0-py3-none-any.whl -
Subject digest:
5f8ff2fc7f3b07d0d49e854b1cd972cdc66c5d6cdb4ef6fc36511277a00d1a08 - Sigstore transparency entry: 953272373
- Sigstore integration time:
-
Permalink:
energy-tracker/api-client-python@55c2655b01c2f9a127309e1402f40e39d18992b7 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/energy-tracker
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55c2655b01c2f9a127309e1402f40e39d18992b7 -
Trigger Event:
push
-
Statement type: