Skip to main content

ewii-python

Unofficial client for Denmark’s EWII self-service portal

Query meters, daily kWh, contracts, and more from Python or expose them through a webserver.

📚 Public methods

Method Description
login() Interactive MitID login; copies cookies into your requests.Session.
get_consumption(from, to, meter_id) Array of daily kWh values.
get_individ_oplysninger() Personal/identity data.
get_aftaler() Active contracts.
get_info() Hidden JSON blob from /privat (addresses, meters, etc.).
_keep_alive() Lightweight ping to keep cookies fresh.

📦 Installation

pip install ewii
playwright install chromium

Script example

import json, requests
from datetime import date
from ewii import EwiiClient

client = EwiiClient()
client.login()

info = client.get_info()
meter = info["forbrugssteder"][0]["maalepunkter"][0]["maalepunktId"]

today = date.today(); first = today.replace(day=1)
print(client.get_consumption(first.isoformat(), today.isoformat(), meter))

🌐 Minimal FastAPI webserver

Create a python file called app.py

import json, threading, requests
from datetime import date
from fastapi import FastAPI, Query, HTTPException
from ewii import EwiiClient

KEEP_ALIVE_TIMER = 30
stop = threading.Event()
client = EwiiClient(requests.Session())

def keep_alive(evt):
    while not evt.wait(KEEP_ALIVE_TIMER):
        try:
            client._keep_alive()
            print("keep-alive")
        except Exception as e:
            print(e)

app = FastAPI(title="EWII API")

@app.on_event("startup")
def start():
    threading.Thread(target=keep_alive, args=(stop,), daemon=True).start()

@app.on_event("shutdown")
def done():
    stop.set()

@app.get("/consumption")
def consumption(meter_id: str, date_from: date, date_to: date):
    try:
        return client.get_consumption(date_from.isoformat(),
                                      date_to.isoformat(),
                                      meter_id)
    except Exception as e:
        raise HTTPException(502, str(e))

if __name__ == "__main__":
    import uvicorn

    uvicorn.run("app:app", host="127.0.0.1", port=8000, reload=True)

Open http://127.0.0.1:8000/docs for interactive Swagger UI. The background thread pings EWII every 5 minutes so the session stays alive.


Note This library is unofficial and not affiliated with EWII. Use responsibly and respect EWII’s terms of service.

Release files for ewii 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ewii 0.2.1
File Size Uploaded
ewii-0.2.1.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ewii 0.2.1
File Interpreter ABI Platform
ewii-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / ewii-0.2.1.tar.gz

Download URL ewii-0.2.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e848d5eeda6938787ab5c92b554be2497aba36cd96a98a796ee27b30ac9e604b
BLAKE2b-256 checksum
How to use checksums
0b2724a4620892bd6016307513856af1c8645f007804c8a3c2909a1388cc8fc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 30, 2025.

Transparency log

Release files / ewii-0.2.1-py3-none-any.whl

Download URL ewii-0.2.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36b52ee922e8ef04ad0932ab602ed6071ede5c5daa9b28f8da9ecd7c2a12bafe
BLAKE2b-256 checksum
How to use checksums
a49d4d397c275b5f8e996b4069a5165cf1fef1c094f8e8bd259482468c1f2a1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 30, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release 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