Python SDK for interacting with the Heimdall Power External API
Project description
Heimdall API SDK for Python
The official Python SDK for accessing the Heimdall Power External API.
Getting Started
Requirements
- Python 3.11+
- Poetry
Install dependencies:
curl -sSL https://install.python-poetry.org | python3 -
poetry install
Installing the SDK
The package is published to PyPI:
pip install heimdallpower-api-client
Alternatively, it can be downloaded and installed using the GitHub release artifacts:
pip install https://github.com/heimdallpower/api-sdk/releases/download/v1.2.3/heimdallpower_api_client-1.2.3-py3-none-any.whl
Replace the version and filename with the latest from Releases
Usage Example
from heimdall_api_client import HeimdallApiClient
import logging
import pprint
logging.basicConfig(level=logging.INFO)
client = HeimdallApiClient(
client_id="your_client_id",
client_secret="your_client_secret",
)
assets = client.get_assets()
pprint.pprint(assets)
More examples can be seen in the examples folder.
Error Handling and Retry
The SDK handles transient infrastructure errors automatically so your application does not have to.
Automatic retry
All methods on HeimdallApiClient retry up to 3 times with exponential backoff (1 s → 2 s → 4 s) on the following transient conditions:
| Condition | Description |
|---|---|
502 Bad Gateway |
Reverse proxy / Application Gateway could not reach the upstream server |
503 Service Unavailable |
Server temporarily unavailable |
504 Gateway Timeout |
Upstream server did not respond in time |
A WARNING log line is emitted for each retry attempt.
If all 3 retry attempts are exhausted, a HeimdallApiError is raised with the status code of the last failed response.
Note:
500 Internal Server Erroris not retried as it typically indicates a permanent application-level error.
Exceptions
All methods raise HeimdallApiError on non-transient errors. The status_code attribute holds the HTTP status code.
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("Line not found")
else:
print(f"API error {e.status_code}: {e}")
Timeouts
Pass a timeout (in seconds) to the constructor. It applies to every request, including each retry attempt.
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),
)
Note: Python synchronous code has no native cancellation equivalent to .NET's
CancellationToken. Usetimeoutto bound how long each request may take.httpx.TimeoutExceptionis raised if the timeout is exceeded.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file heimdallpower_api_client-3.10.0.tar.gz.
File metadata
- Download URL: heimdallpower_api_client-3.10.0.tar.gz
- Upload date:
- Size: 54.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd0ed5c24798c02f3ca7d1621005a092db43a83f560cfb99ee829e3bf181d8a1
|
|
| MD5 |
702762638c71d2e5bd023aa8e21ae6bc
|
|
| BLAKE2b-256 |
4adfdd053520f8800d492bd5d824320a0784cc730ed1bf69f73199a9790c3943
|
Provenance
The following attestation bundles were made for heimdallpower_api_client-3.10.0.tar.gz:
Publisher:
python-publish.yml on heimdallpower/api-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
heimdallpower_api_client-3.10.0.tar.gz -
Subject digest:
dd0ed5c24798c02f3ca7d1621005a092db43a83f560cfb99ee829e3bf181d8a1 - Sigstore transparency entry: 2189931801
- Sigstore integration time:
-
Permalink:
heimdallpower/api-sdk@897d7421184460aa9a428a0682ad4cc15f0f5094 -
Branch / Tag:
refs/tags/v3.10.0 - Owner: https://github.com/heimdallpower
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@897d7421184460aa9a428a0682ad4cc15f0f5094 -
Trigger Event:
release
-
Statement type:
File details
Details for the file heimdallpower_api_client-3.10.0-py3-none-any.whl.
File metadata
- Download URL: heimdallpower_api_client-3.10.0-py3-none-any.whl
- Upload date:
- Size: 184.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2bb1c7b30aef08f4b7f5d7b90985565ceaa298e58f44c1b0ecc6fbc781956f6
|
|
| MD5 |
9c9fdf6f7a4e4c18721d68dd9b6fc293
|
|
| BLAKE2b-256 |
6a53e22fc935362ceb35eca170ac6b1469d0c0af13ab88e0d51638e2277eebb1
|
Provenance
The following attestation bundles were made for heimdallpower_api_client-3.10.0-py3-none-any.whl:
Publisher:
python-publish.yml on heimdallpower/api-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
heimdallpower_api_client-3.10.0-py3-none-any.whl -
Subject digest:
f2bb1c7b30aef08f4b7f5d7b90985565ceaa298e58f44c1b0ecc6fbc781956f6 - Sigstore transparency entry: 2189931859
- Sigstore integration time:
-
Permalink:
heimdallpower/api-sdk@897d7421184460aa9a428a0682ad4cc15f0f5094 -
Branch / Tag:
refs/tags/v3.10.0 - Owner: https://github.com/heimdallpower
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@897d7421184460aa9a428a0682ad4cc15f0f5094 -
Trigger Event:
release
-
Statement type: