Skip to main content

aioengiebelgium

Unofficial asynchronous Python library to interact with the ENGIE Belgium API.

Requires Python >= 3.14.

Install

pip install aioengiebelgium

Usage

import asyncio
import json
from pathlib import Path

from aioengiebelgium import EngieBeClient, MfaMethod

_TOKEN_FILE = Path("tokens.json")


async def persist_tokens(access_token: str, refresh_token: str) -> None:
    # Save the token pair for the next refresh.
    payload = json.dumps({"access": access_token, "refresh": refresh_token})
    await asyncio.to_thread(_TOKEN_FILE.write_text, payload)


async def first_login() -> None:
    # First run: log in with MFA. on_token_refresh saves the tokens.
    async with EngieBeClient(on_token_refresh=persist_tokens) as client:
        flow = await client.async_start_authentication(
            "user@example.com",
            "password",
            mfa_method=MfaMethod.SMS,
        )
        # Once you receive your MFA code, then:
        await flow.async_submit_mfa("123456")

        relations = await client.async_get_customer_account_relations()
        print(relations)


async def next_run() -> None:
    # Later runs: reuse the saved tokens and skip the login entirely.
    raw = await asyncio.to_thread(_TOKEN_FILE.read_text)
    tokens = json.loads(raw)

    async with EngieBeClient(
        access_token=tokens["access"],
        refresh_token=tokens["refresh"],
        on_token_refresh=persist_tokens,
    ) as client:
        contracts = await client.async_get_energy_contracts("1234567890")
        print(contracts)


if _TOKEN_FILE.exists():
    asyncio.run(next_run())
else:
    asyncio.run(first_login())

Development

This project uses uv and targets Python 3.14+.

uv sync
uv run python -m scripts.check

License

MIT, see LICENSE.

Download files

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

Source Distribution

aioengiebelgium-0.1.1.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

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

aioengiebelgium-0.1.1-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

Details for the file aioengiebelgium-0.1.1.tar.gz.

File metadata

  • Download URL: aioengiebelgium-0.1.1.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for aioengiebelgium-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0612a092cda3c0275b0f3c63fbc53ccc4f6836d0addb76ef65e67a6d00c370dd
MD5 099688b1aff290a545d4e2ab72a53e2c
BLAKE2b-256 b6a4687693fe075535d2e04c0084f8f0f9c29dbab6eb880890a0fd6196c231d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioengiebelgium-0.1.1.tar.gz:

Publisher: release.yml on DaanVervacke/aioengiebelgium

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

File details

Details for the file aioengiebelgium-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aioengiebelgium-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for aioengiebelgium-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26f1098fb5a0b22969d1c5fd3d455caa957d8ffa426a47316b658783eb916794
MD5 7bfeadbe98d2559113a5ed02cfc49b83
BLAKE2b-256 9e3f3ec4eaa722d860fd5b431f985c7860cfe5192e703a813e05453b8e60c84b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioengiebelgium-0.1.1-py3-none-any.whl:

Publisher: release.yml on DaanVervacke/aioengiebelgium

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

Release history Release notifications | RSS feed

0.1.3

2 files

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page