Skip to main content

Official Python SDK for ObservaMax API

Project description

observamax

Official Python SDK for the ObservaMax API.

Installation

pip install observamax

Quick Start

import os
from observamax import ObservaMax

client = ObservaMax(api_key=os.environ["OBSERVAMAX_API_KEY"])

# List all monitors
monitors = client.monitors.list()
print(f"You have {monitors.meta.total} monitors")

for monitor in monitors.data:
    print(f"{monitor.name}: {monitor.last_status}")

# Get a specific monitor
monitor = client.monitors.get("mon_abc123")
print(f"{monitor.name}: {monitor.last_status}")

# Create a new monitor
from observamax import CreateMonitorInput

new_monitor = client.monitors.create(
    CreateMonitorInput(
        url="https://api.example.com/health",
        name="Production API",
        check_interval=5,
    )
)

# Pause a monitor
client.monitors.pause(new_monitor.id)

# Resume a monitor
client.monitors.resume(new_monitor.id)

# Get uptime statistics
stats = client.uptime.get_stats("30d")

API Reference

Monitors

from observamax import CreateMonitorInput, UpdateMonitorInput

# List monitors
response = client.monitors.list(page=1, limit=50)
for monitor in response.data:
    print(monitor.name)

# Get a monitor
monitor = client.monitors.get("monitor_id")

# Create a monitor
monitor = client.monitors.create(
    CreateMonitorInput(
        url="https://example.com",
        name="My Website",
        check_interval=5,        # minutes
        expected_status_code=200,
        timeout_ms=30000,
        http_method="GET",
        tags=["production"],
    )
)

# Update a monitor
updated = client.monitors.update(
    "monitor_id",
    UpdateMonitorInput(
        name="New Name",
        check_interval=10,
    )
)

# Delete a monitor
client.monitors.delete("monitor_id")

# Pause/Resume
client.monitors.pause("monitor_id")
client.monitors.resume("monitor_id")

Alerts

# List alerts
alerts = client.alerts.list()

# Get an alert
alert = client.alerts.get("alert_id")

# Acknowledge an alert
client.alerts.acknowledge("alert_id")

# Resolve an alert
client.alerts.resolve("alert_id")

Uptime

# Get overall uptime stats
stats = client.uptime.get_stats("24h")  # or "7d", "30d"

# Get stats for a specific monitor
monitor_stats = client.uptime.get_monitor_stats("monitor_id", "7d")

Error Handling

from observamax import ObservaMax, ApiError, RateLimitError

try:
    monitor = client.monitors.get("invalid_id")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except ApiError as e:
    print(f"API Error: {e.message} (status: {e.status_code})")

Context Manager

with ObservaMax(api_key="om_live_...") as client:
    monitors = client.monitors.list()
    # Client is automatically closed when exiting the context

Configuration

client = ObservaMax(
    api_key="om_live_...",
    base_url="https://observamax.com/api/v1",  # default
    timeout=30.0,  # 30 seconds, default
)

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

observamax-1.0.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

observamax-1.0.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file observamax-1.0.0.tar.gz.

File metadata

  • Download URL: observamax-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for observamax-1.0.0.tar.gz
Algorithm Hash digest
SHA256 888a260b2135d5b47e5604531692c7648e0b3e18d58b2c3ebca3b295062741ee
MD5 070aa0a97399336a1d638a109fd1b32c
BLAKE2b-256 8a14143ffe792b01e4e98194ce58f5b6c95cbfd4b4697c619c476645316c055f

See more details on using hashes here.

File details

Details for the file observamax-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: observamax-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for observamax-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edf0145e9ef8a60ce29f373d6fc4b8b3475f04a11f9b0dbf13585fbe85286f80
MD5 6ac2385fffea652edb68b4d6b6b9ff37
BLAKE2b-256 c3011bb21ad291896933d677ee23c0c36c2755f9d22abfe3cb0ebe4aaeec014c

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