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 errorsNotifoxAuthenticationError- 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 errorsNotifoxConnectionError- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file notifox-0.1.5.tar.gz.
File metadata
- Download URL: notifox-0.1.5.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cbbdea54a8197aa08dd4a294b71dd2f5eecf5b6bc1cd15447cf4fb5e56b455b
|
|
| MD5 |
5d556c12e3024c44ce6956203f59c276
|
|
| BLAKE2b-256 |
58b9b130d145df37df89b7c9540dbed5081b68e85cdbe82a38a71c42f884c912
|
File details
Details for the file notifox-0.1.5-py3-none-any.whl.
File metadata
- Download URL: notifox-0.1.5-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4b6d0605719f399e5425476c4d5baff7e004fdb089a164665e47a7cb4bef4f5
|
|
| MD5 |
17c953049064b21322dde942bb411e4f
|
|
| BLAKE2b-256 |
cc2c3588bd84d734616d75ba2ec58cb5722fb88bdc8ffe42744b26888f3d7796
|