Python SDK for Sentrygram - send alerts to your Telegram
Project description
Sentrygram Python SDK
Send alerts to your Telegram with one line of code.
Installation
pip install sentrygram
Quick Start
from sentrygram import Sentrygram
# Initialize with your API key
client = Sentrygram("sk_your_api_key")
# Send a simple alert
client.alert("Deployment completed successfully!")
# Send with severity level
client.alert("Database connection failed", level="error")
# Send with context
client.alert(
"New user signup",
level="info",
context={"user_id": 123, "plan": "pro"}
)
Alert Levels
info- Informational messages (blue)warning- Warning messages (yellow)error- Error messages (red)critical- Critical alerts (red)
from sentrygram import Sentrygram, AlertLevel
client = Sentrygram("sk_your_api_key")
client.alert("Server is down!", level=AlertLevel.CRITICAL)
Error Handling
from sentrygram import Sentrygram
from sentrygram.client import RateLimitError, NotificationsPausedError, SentrygramError
client = Sentrygram("sk_your_api_key")
try:
client.alert("Hello!")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except NotificationsPausedError:
print("Notifications paused. Reactivate at sentrygram.com")
except SentrygramError as e:
print(f"Error: {e}")
Rate Limits
- Burst limit: 10 alerts per minute
- Hourly limit: 200 alerts per hour
If you exceed the burst limit repeatedly, notifications will be automatically paused to prevent spam.
Get Your API Key
- Sign up at sentrygram.com
- Link your Telegram account
- Create an API key in the dashboard
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sentrygram-0.1.0.tar.gz
(4.4 kB
view details)
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 sentrygram-0.1.0.tar.gz.
File metadata
- Download URL: sentrygram-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c75430cdff67c7dc9fd5e4bb189f593b83605123d246b73f3a3710222ca7d048
|
|
| MD5 |
8ae3a783cd6cf2d263a32bfe080ba9c6
|
|
| BLAKE2b-256 |
a3707bd106c00063e96fcf1a71bdfe02b12cb6f54ec3f231fab0f3fd3aa28c84
|
File details
Details for the file sentrygram-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sentrygram-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc0625af96f5cd8ad8264b6accce25b4c901b6b5ae5fce073f9d813c90d03ca0
|
|
| MD5 |
886bdad713cbdbaf09cfe7c5223eddfe
|
|
| BLAKE2b-256 |
ecea104121f9391f22b2e974919cb9a28c4f728a5f8b915c73caf54339da2c76
|