Skip to main content

DevHelm SDK for Python — typed client for monitors, incidents, alerting, and more

Project description

DevHelm Python SDK

Typed Python client for the DevHelm monitoring API — monitors, incidents, alerting, and more.

Installation

pip install devhelm

Quick Start

from devhelm import Devhelm

client = Devhelm(token="your-api-token")

# List all monitors
monitors = client.monitors.list()
for m in monitors:
    print(f"{m.name}{m.type}")

# Create a monitor
monitor = client.monitors.create({
    "name": "My API Health",
    "type": "HTTP",
    "config": {"url": "https://api.example.com/health", "method": "GET"},
    "frequencySeconds": 60,
    "regions": ["us-east"],
    # `managedBy` records who reconciles drift on this resource. Use
    # "DASHBOARD" (the default for one-off SDK scripts), "CLI" if the
    # monitor lives in a `devhelm.yml` you re-deploy, or "TERRAFORM"
    # if it lives in `.tf` you re-apply.
    "managedBy": "DASHBOARD",
})

# Get a single monitor
monitor = client.monitors.get(monitor.id)

# Pause / resume
client.monitors.pause(monitor.id)
client.monitors.resume(monitor.id)

# Delete
client.monitors.delete(monitor.id)

Configuration

from devhelm import Devhelm

client = Devhelm(
    token="your-api-token",            # required (or DEVHELM_API_TOKEN env var)
    org_id="1",                        # optional — see notes below
    workspace_id="1",                  # optional — see notes below
    base_url="https://api.devhelm.io", # optional, defaults to production
)

Environment variables are used as fallbacks when constructor arguments are not provided:

Parameter Required Env Variable Notes
token Yes DEVHELM_API_TOKEN Personal or workspace API token.
org_id No DEVHELM_ORG_ID Auto-resolved if your token is scoped to one org. Required only when the token has access to multiple.
workspace_id No DEVHELM_WORKSPACE_ID Auto-resolved if your token is scoped to one workspace. Required only when the token spans multiple.

Resources

The client exposes the following resource modules:

Resource Description
client.monitors HTTP, DNS, TCP, ICMP, MCP, and Heartbeat monitors
client.incidents Manual and auto-detected incidents
client.alert_channels Slack, email, webhook, and other alert channels
client.notification_policies Routing rules for alerts
client.environments Environment grouping (prod, staging, etc.)
client.secrets Encrypted secrets for monitor auth
client.tags Organize monitors with tags
client.resource_groups Logical resource groups
client.webhooks Outgoing webhook endpoints
client.api_keys API key management
client.dependencies Service dependency tracking
client.deploy_lock Deploy lock for safe deployments
client.status Dashboard overview

Pagination

List methods auto-paginate by default. For manual page control:

# Auto-paginate (fetches all pages)
all_monitors = client.monitors.list()

# Manual page control
page = client.monitors.list_page(page=0, size=20)
print(page.data)       # list of monitors
print(page.has_next)   # True if more pages
print(page.has_prev)   # True if previous page exists

# Cursor pagination (for check results)
results = client.monitors.results(monitor_id, limit=50)
print(results.data)
print(results.next_cursor)
print(results.has_more)

Error Handling

The SDK raises three top-level error types (see 040-codegen-policies.md):

  • DevhelmValidationError — local request/response shape validation failed.
  • DevhelmApiError — the API returned a non-2xx status. Subclassed by HTTP class for ergonomics: DevhelmAuthError (401/403), DevhelmNotFoundError (404), DevhelmConflictError (409), DevhelmRateLimitError (429), DevhelmServerError (5xx).
  • DevhelmTransportError — the request never reached a server response (connection refused, timeout, TLS failure, etc.).

Every DevhelmApiError carries:

  • status — the HTTP status code
  • code — coarse machine-readable category (e.g. NOT_FOUND, RATE_LIMITED); switch on this, not the human-readable message
  • request_id — the per-request id from the X-Request-Id response header; always include this in support tickets
from devhelm import Devhelm, DevhelmAuthError, DevhelmError

client = Devhelm(token="bad-token")

try:
    client.monitors.list()
except DevhelmAuthError as e:
    print(f"Auth failed: {e.message} (HTTP {e.status}, request_id={e.request_id})")
except DevhelmError as e:
    print(f"API error [{e.code}]: {e.message}")

Development

# Install dependencies
uv sync

# Run tests
make test

# Lint + format check
make lint

# Type check
make typecheck

# Regenerate types from OpenAPI spec
make typegen

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

devhelm-0.6.2.tar.gz (234.2 kB view details)

Uploaded Source

Built Distribution

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

devhelm-0.6.2-py3-none-any.whl (73.4 kB view details)

Uploaded Python 3

File details

Details for the file devhelm-0.6.2.tar.gz.

File metadata

  • Download URL: devhelm-0.6.2.tar.gz
  • Upload date:
  • Size: 234.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for devhelm-0.6.2.tar.gz
Algorithm Hash digest
SHA256 54e3d1d4562317a264439e9575602444b436eadf58a3b5826d8a8d1e1acb67e3
MD5 c3b801f704fa72f378fc1484e5c31dbc
BLAKE2b-256 70ec4c28282034451ef6cdfc8eff0b3b2f717fd421769ad36ee6585c7dcf11f0

See more details on using hashes here.

File details

Details for the file devhelm-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: devhelm-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 73.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for devhelm-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c9c7e4d3af9f1f7097b92082a2d91d2f252d2b6970767b29bc1c90a3971acff7
MD5 5e7b9b81f3029f30609089aca679c698
BLAKE2b-256 4c228a23256048e9357ccccf499c4763b5d7d96e04d4b2eeed134a51dea23874

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