Skip to main content

Heimdall API SDK for Python

Official Python SDK for the Heimdall Power External API.

Documentation

Installation

Requires Python 3.11+.

pip install heimdallpower-api-client

Wheels are also attached to each GitHub release, e.g.:

pip install https://github.com/heimdallpower/api-sdk/releases/download/python-v1.2.3/heimdallpower_api_client-1.2.3-py3-none-any.whl

Quick start

from heimdall_api_client import HeimdallApiClient

client = HeimdallApiClient(client_id="your_client_id", client_secret="your_client_secret")
assets = client.get_assets()

Iterate over instrumented lines

Not every line has Neurons installed. Data endpoints return 404 or no data for lines without active measurement points. get_instrumented_lines() returns only lines with at least one active measurement point, with their facility.

for instrumented in client.get_instrumented_lines():
    current = client.get_latest_current(instrumented.line.id)
    print(instrumented.facility.name, instrumented.line.name, current.data.current.value, current.data.unit)

Already have the assets? Use instrumented_lines(assets.data) from heimdall_api_client.assets.

Error handling and retry

Automatic retry

All methods retry up to 3 times with exponential backoff (1 s → 2 s → 4 s) on these transient errors:

Condition Description
502 Bad Gateway The gateway could not reach the upstream server
503 Service Unavailable Server temporarily unavailable
504 Gateway Timeout Upstream server did not respond in time
  • Each retry logs a WARNING.
  • After 3 failed retries, the last HeimdallApiError is raised.
  • 500 Internal Server Error is not retried.

Exceptions

All methods raise HeimdallApiError on non-transient errors. status_code holds the HTTP status.

from heimdall_api_client import HeimdallApiClient, HeimdallApiError

client = HeimdallApiClient(client_id="...", client_secret="...")

try:
    dlr = client.get_latest_heimdall_dlr(line_id=line_id)
except HeimdallApiError as e:
    if e.status_code == 404:
        print("No data for the line in the requested window, or unknown line")
    else:
        print(f"API error {e.status_code}: {e}")

Timeouts

Pass timeout (seconds) to the constructor. It applies to every request and each retry.

import httpx
from heimdall_api_client import HeimdallApiClient

# Simple: abort any request that takes longer than 10 s
client = HeimdallApiClient(client_id="...", client_secret="...", timeout=10.0)

# Fine-grained: separate connect and read timeouts
client = HeimdallApiClient(
    client_id="...",
    client_secret="...",
    timeout=httpx.Timeout(connect=5.0, read=30.0),
)
  • There is no cancellation token; use timeout to bound each request.
  • httpx.TimeoutException is raised when the timeout is exceeded.

License

This SDK is licensed under the Apache License 2.0.

Metadata

Release files for heimdallpower-api-client 5.1.0

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

Source distribution (sdist)

Source distribution for heimdallpower-api-client 5.1.0
File Size Uploaded
heimdallpower_api_client-5.1.0.tar.gz 70.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for heimdallpower-api-client 5.1.0
File Interpreter ABI Platform
heimdallpower_api_client-5.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 307.5 kB

Release files / heimdallpower_api_client-5.1.0.tar.gz

Download URL heimdallpower_api_client-5.1.0.tar.gz
Size 70.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c56523e6b95f20e2c56e44930d60c76f3d95dce31ae072ff3bb5ac15ce13381b
BLAKE2b-256 checksum
How to use checksums
246faf4e31f71d33b7afa656e76d049d493e576bd5daf56e5820234b96246272
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 13, 2026.

Transparency log

Release files / heimdallpower_api_client-5.1.0-py3-none-any.whl

Download URL heimdallpower_api_client-5.1.0-py3-none-any.whl
Size 236.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eeb1866070f95f4e1c7350e464caf2b2432bffdf6f99fb1ae0a44026d0ee8e6f
BLAKE2b-256 checksum
How to use checksums
4a8680a2db1723bdb7ccba807dec92d5205d884696b46884a1b8e6df433c2e7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

5.1.0 This release

2 release files

5.0.0

2 release files

4.0.0

2 release files

3.10.0

2 release files

3.9.2

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