Skip to main content

Official Python SDK for Notifox alerting API

Project description

notifox-py

Python SDK for Notifox.

Installation

pip install notifox

Usage

import notifox

client = notifox.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"
import notifox

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

Channel Selection

You can optionally specify a channel (SMS or email):

import notifox

client = notifox.NotifoxClient()

# Send via SMS
response = client.send_alert(
    audience="mike",
    alert="Server is down!",
    channel=notifox.SMS
)

# Send via email
response = client.send_alert(
    audience="mike",
    alert="Server is down!",
    channel=notifox.Email
)

# If channel is not specified, it will be left blank
response = client.send_alert(
    audience="mike",
    alert="Server is down!"
)

Configuration

import notifox

client = notifox.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.

import notifox

client = notifox.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

import notifox

client = notifox.NotifoxClient(api_key="your_api_key")

try:
    response = client.send_alert(audience="admin", alert="System is running low on memory")
    print(f"Alert sent! Message ID: {response.get('message_id')}")
except notifox.NotifoxAuthenticationError:
    print("Authentication failed. Check your API key.")
except notifox.NotifoxRateLimitError:
    print("Rate limit exceeded. Please wait before sending more alerts.")
except notifox.NotifoxAPIError as e:
    print(f"API error ({e.status_code}): {e.response_text}")
except notifox.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.3.tar.gz (5.1 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.3-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: notifox-0.1.3.tar.gz
  • Upload date:
  • Size: 5.1 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.3.tar.gz
Algorithm Hash digest
SHA256 c1032ef433f1a9e366c541b915c0b8c03764640ba0aed77c6f42268c14a7485f
MD5 a41f3a8fad4da8be9c5a6dade6e0a9fc
BLAKE2b-256 ee85a22b8aef0b567fb3f26b304cf2fda37aaae117062caa60cdd76e8f3ec87f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: notifox-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ad7414fccf3ffc25f78fa7702f456548eae586d2d72b4c8dae767fc8537de8f0
MD5 315f27fe224c55e20afc0592781492cb
BLAKE2b-256 a4d3262f5777709a49d630680e4aeee6eaf82e56ea62234cb26c3365a0338dc1

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