Skip to main content

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

energy_tracker_api-2.0.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

energy_tracker_api-2.0.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

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

Hashes for energy_tracker_api-2.0.0.tar.gz
Algorithm Hash digest
SHA256 3dc11fe68b460458eb76cf51d182ba7498fea53233b0a1fc6be1c80e98b6f139
MD5 06997c0d48523ccd2f8400cbed0efc87
BLAKE2b-256 408eec074e78485d4b7fd3c5ec10c0aa2345d17c00032faf10ebf92c1b370f0a

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file energy_tracker_api-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for energy_tracker_api-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f8ff2fc7f3b07d0d49e854b1cd972cdc66c5d6cdb4ef6fc36511277a00d1a08
MD5 7e632f56659f23b7f8c5cbacb53903b4
BLAKE2b-256 bac27094b473a57611725c55e1159a54b6e5e17dae864497a014c6cce0a56966

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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