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 as e:
    print(f"Authentication failed: {e}")
except notifox.NotifoxValidationError as e:
    print(f"Validation error: {e}")
    if e.error:
        print(f"Error type: {e.error}")
except notifox.NotifoxInsufficientBalanceError:
    print("Insufficient balance. Please add funds to your account.")
except notifox.NotifoxRateLimitError:
    print("Rate limit exceeded. Please wait before sending more alerts.")
except notifox.NotifoxServerError as e:
    print(f"Server error: {e}")
except notifox.NotifoxAPIError as e:
    print(f"API error ({e.status_code}): {e}")
except notifox.NotifoxConnectionError as e:
    print(f"Connection failed: {e}")

Available exceptions:

  • NotifoxError - Base exception for all Notifox errors
  • NotifoxAuthenticationError - Authentication failed (401/403)
  • NotifoxValidationError - Request validation failed (400)
  • NotifoxInsufficientBalanceError - Insufficient balance (402)
  • NotifoxRateLimitError - Rate limit exceeded (429)
  • NotifoxServerError - Server errors (500)
  • NotifoxAPIError - General API errors
  • NotifoxConnectionError - Network/connection 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.4.tar.gz (5.9 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.4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: notifox-0.1.4.tar.gz
  • Upload date:
  • Size: 5.9 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.4.tar.gz
Algorithm Hash digest
SHA256 ac4b7f72631e4baccdbe61b5aa17ec2d7457ab453b25a9a13632b0e51e3b9f02
MD5 fc1737dcdf938d44f10f96d2ac5326c3
BLAKE2b-256 5b72b8f456b16d726ddbdb1b76ca79f59ce30014011683a66239fdf817c6909a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: notifox-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f500dea8e715af4fd0d64e3dd7bc963d20b7feb012005d6c9bb0bfabd7f1f1ce
MD5 59db4af7b2448eab206edfb645d40785
BLAKE2b-256 dfdf608f174a0b6dd8bb34e6ae22db455563f30e11e1a481929be05daeb315d4

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