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.3.tar.gz (28.0 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.3-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aioengiebelgium-0.1.3.tar.gz
  • Upload date:
  • Size: 28.0 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.3.tar.gz
Algorithm Hash digest
SHA256 244983f23fd2c4b8a23b17a779fe01af9df70c39b9a884b8732948faa94529f2
MD5 fa4884259506d69851aaba525eca51ae
BLAKE2b-256 559d86356502e284d79ec975f15f47850370f8dda77ed211156db1b327b3293f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: aioengiebelgium-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 34.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0113091946f9a8b30216680f12d89b96e4f14ed48845284af5150ee010e05422
MD5 e269a8f5cc535b2c82eb09503a494217
BLAKE2b-256 b9cdb14fcd2ff6c1e4b371054cda19e8d7bf2ecf587cd72da24a7e2500ffc158

See more details on using hashes here.

Provenance

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

This release

0.1.3 This release

2 files

0.1.2

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