Skip to main content

Official Python SDK for Notifox alerting API

Project description

notifox-py

Python SDK for Notifox.

Installation

pip install notifox

Usage

from notifox import NotifoxClient

client = NotifoxClient(api_key="your_api_key_here")
client.send_alert(audience="mike", alert="Database server is down!")

Or use the environment variable:

export NOTIFOX_API_KEY="your_api_key_here"
client = NotifoxClient()  # Reads from NOTIFOX_API_KEY
client.send_alert(audience="mike", alert="High CPU usage!")

Configuration

client = NotifoxClient(
    api_key="your_api_key",
    base_url="https://api.notifox.com",
    timeout=30.0,
    max_retries=3
)

Calculate parts

When you send a message, the length and characters dictate how many parts you will be charged for. You can read more about calculating the parts here.

The Notifox Alerts API exposes a route that lets you calculate the amount of parts a message will be without sending the alert.

from notifox import NotifoxClient

client = NotifoxClient()

# Calculate the parts of the alert
response = client.calculate_parts(
    alert="Hello, world!"
)

# {'parts': 1, 'cost': 0.025, 'currency': 'USD', 'encoding': 'GSM-7', 'characters': 22, 'message': 'Notifox: Hello, world!'}

Error Handling

from notifox import (
    NotifoxClient,
    NotifoxAuthenticationError,
    NotifoxRateLimitError,
    NotifoxAPIError,
    NotifoxConnectionError
)

client = NotifoxClient(api_key="your_api_key")

try:
    client.send_alert(audience="admin", alert="System is running low on memory")
except NotifoxAuthenticationError:
    print("Authentication failed. Check your API key.")
except NotifoxRateLimitError:
    print("Rate limit exceeded. Please wait before sending more alerts.")
except NotifoxAPIError as e:
    print(f"API error ({e.status_code}): {e.response_text}")
except NotifoxConnectionError as e:
    print(f"Connection failed: {e}")

Available exceptions:

  • NotifoxError - Base exception
  • NotifoxAuthenticationError - Authentication failed (401/403)
  • NotifoxRateLimitError - Rate limit exceeded (429)
  • NotifoxAPIError - General API errors
  • NotifoxConnectionError - Network errors

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

notifox-0.1.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

notifox-0.1.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file notifox-0.1.2.tar.gz.

File metadata

  • Download URL: notifox-0.1.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for notifox-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ac4b43f8a915ebfb97cd83872e786ad99d4b2288aa90c52df2ffdf7edcd412c0
MD5 a698c010a66630d7d8f3c27d16e6c740
BLAKE2b-256 e41fe2c864f21b9f376c307d8c540aa3afb5f78d3c299fa7bd36057fa04bd5af

See more details on using hashes here.

File details

Details for the file notifox-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: notifox-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for notifox-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ed5893f4ad006e76f9c65f37fa9822475dae6eab40d1093fcc91b1d59103c5ac
MD5 3ba0ac0d0c65446cd28708825a833056
BLAKE2b-256 2fdda8532664931edf7e194bdc3b3a2748cbf4b6110105616eee0d7e91047596

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