Skip to main content

Async Python client for the mijn.ista.nl energy portal

Project description

mijn-ista-api

Async Python client for the mijn.ista.nl energy monitoring portal.

Installation

pip install mijn-ista-api

Requirements

  • Python 3.12+
  • aiohttp 3.9+

Usage

import asyncio
import aiohttp
from mijn_ista_api import MijnIstaAPI, MijnIstaAuthError, MijnIstaConnectionError

async def main():
    async with aiohttp.ClientSession() as session:
        api = MijnIstaAPI(session, "you@example.com", "your-password", lang="nl-NL")

        # Authenticate (obtains JWT)
        await api.authenticate()

        # Fetch account + annual comparison data
        user_data = await api.get_user_values()
        for cus in user_data.get("Cus", []):
            cuid = cus["Cuid"]
            print(cus.get("Adress"), cus.get("City"))

            # Full monthly history (polls until all shards are loaded)
            month_data = await api.get_month_values(cuid)

            # Building averages for the current billing year
            periods = cus.get("curConsumption", {}).get("BillingPeriods", [])
            if periods:
                p = sorted(periods, key=lambda x: x["y"], reverse=True)[0]
                avg_data = await api.get_consumption_averages(
                    cuid, p["s"][:10], p["e"][:10]
                )

asyncio.run(main())

API overview

Method Endpoint Description
authenticate() POST /api/Authorization/Authorize Obtain JWT
get_user_values() POST /api/Values/UserValues Account info, annual comparison
get_month_values(cuid) POST /api/Consumption/MonthValues Full monthly history (auto-polls shards)
get_consumption_values(cuid, billing_period) POST /api/Values/ConsumptionValues Meter totals for one billing year
get_consumption_averages(cuid, start, end) POST /api/Values/ConsumptionAverages Building-wide normalised averages

Error handling

from mijn_ista_api import MijnIstaAuthError, MijnIstaConnectionError

try:
    await api.authenticate()
except MijnIstaAuthError:
    # Bad credentials
    ...
except MijnIstaConnectionError:
    # Network error or API unavailable
    ...

Notes

  • The JWT is passed in the request body, not as an Authorization header.
  • Every API response returns a refreshed JWT; the client handles this automatically.
  • get_month_values polls until the server has loaded all data shards (the API streams results).
  • Transient 425 Too Early / 503 Service Unavailable responses are retried with exponential backoff.

Home Assistant integration

This library powers the ista Nederland Home Assistant custom integration.

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

mijn_ista_api-0.1.7.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

mijn_ista_api-0.1.7-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file mijn_ista_api-0.1.7.tar.gz.

File metadata

  • Download URL: mijn_ista_api-0.1.7.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mijn_ista_api-0.1.7.tar.gz
Algorithm Hash digest
SHA256 076626a7c215741cfbb83c30779b67cc90e61a61af70682ec3d0b6c329654928
MD5 98f54e94f1b26384eb7f042f4417f951
BLAKE2b-256 c9f722aedc49275879e270a4ef747ee90cbcb0b2cc0dc29ce152694dbf753f4c

See more details on using hashes here.

File details

Details for the file mijn_ista_api-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: mijn_ista_api-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mijn_ista_api-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c655bb15c1894a195a021d3916e5d7c28558a12c1ad2dd1c573971e95486781a
MD5 97ee862bf61b5c3dcdf536eec1af2c8c
BLAKE2b-256 d58a27a6a96902f2d7f45814f3b29a348a61e03d8b8038c8dc0a8358ab7a5675

See more details on using hashes here.

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