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.2.tar.gz (27.7 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.2-py3-none-any.whl (34.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aioengiebelgium-0.1.2.tar.gz
  • Upload date:
  • Size: 27.7 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.2.tar.gz
Algorithm Hash digest
SHA256 7fe00b84592227f0fb194aecf2630b9e3825beb0d21803a96ab12e470d7b6f5f
MD5 3602e54cbbc90a28cc44a0b25f1d0023
BLAKE2b-256 66c25cb95843ce85d0e77b0a697661562d34d5e99adec611a79f1c4d2f4df591

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioengiebelgium-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: aioengiebelgium-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 34.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a5a17d2e47c837f291bf4d0a6a06c7989db402b2d176355bc324664433ce0386
MD5 0e95cf7af67228ad2e0d53e6c306b4cb
BLAKE2b-256 7474f6d916e091d39069a487309676ce9801f8b10082e2777d8642e05f6a5a57

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioengiebelgium-0.1.2-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

This release

0.1.2 This release

2 files

0.1.1

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