Skip to main content

meridian-energy

PyPI

Python client for the Meridian Energy (NZ) customer API.

Unofficial. Not affiliated with or endorsed by Meridian Energy.

Talks to the current MyMeridian stack:

  1. Email one-time code (auth.meridianenergy.nz)
  2. Firebase custom-token exchange
  3. GraphQL (“Kraken”) at api.meridianenergy.nz

Install

pip install meridian-energy
# or
uv add meridian-energy

Requires Python 3.11+.

CLI

uvx meridian login                 # emails a code, prompts for it
uvx meridian accounts
uvx meridian usage --days 14
uvx meridian usage --json
uvx meridian status
uvx meridian logout

Tokens are cached at ~/.cache/meridian-energy/tokens.json (mode 0600). Override with --token-cache or MERIDIAN_TOKEN_CACHE. Email can come from MERIDIAN_EMAIL.

Library

import asyncio
import httpx
from meridian_energy import MeridianEnergyApi, MeridianEnergyAuth

async def main() -> None:
    auth = MeridianEnergyAuth()
    async with httpx.AsyncClient(timeout=30) as http:
        journey = await auth.request_otp(http, "you@example.com")
        await auth.verify_otp(http, "you@example.com", "123456", journey)

    async with MeridianEnergyApi(auth) as api:
        for account in await api.get_accounts():
            print(account.number, account.primary_icp)
            usage = await api.get_usage(account.number, days=10)
            print(usage.import_kwh, usage.export_kwh, usage.cost_nzd)

asyncio.run(main())

Resume a session from stored tokens (refresh is transparent):

from meridian_energy import MeridianEnergyAuth, MeridianEnergyApi, TokenSet

async def save(tokens: TokenSet) -> None:
    store.write(tokens.to_dict())

auth = MeridianEnergyAuth(
    tokens=TokenSet.from_dict(store.read()),
    on_token_update=save,
)
api = MeridianEnergyApi(auth)

Development

uv sync --group dev
uv run ruff check src tests
uv run ruff format src tests
uv run ty check src
uv run pytest

Home Assistant

The companion integration is hardbyte/ha-meridian-energy.

Release files for meridian-energy 0.1.5

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

Source distribution (sdist)

Source distribution for meridian-energy 0.1.5
File Size Uploaded
meridian_energy-0.1.5.tar.gz 42.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for meridian-energy 0.1.5
File Interpreter ABI Platform
meridian_energy-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 64.3 kB

Release files / meridian_energy-0.1.5.tar.gz

Download URL meridian_energy-0.1.5.tar.gz
Size 42.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bb49e16f58eb6caeefe106fd93ff86530f7d72ae8c500fe96a3cc08ca444eb28
BLAKE2b-256 checksum
How to use checksums
58b4ba83ed229edb81549346691b40161895fcc8b49ac75dc10fa088347ece7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / meridian_energy-0.1.5-py3-none-any.whl

Download URL meridian_energy-0.1.5-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bda1695bc154a08fa2c97b33bcd3afedf8a31910a445aff38a82c048b391d683
BLAKE2b-256 checksum
How to use checksums
8ba7649f1a40c449712361a8dabd41c5d4e293cffc52baaef4c058f040885ddc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

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