Minimal Telegram alerting framework for bots and scripts.
Project description
Pingram
Send Telegram messages with one line of Python. No webhooks. No bloat. Just pings.
Pingram is an ultra-lightweight Python wrapper for sending outbound Telegram messages via your bot. It’s designed as a cost-free alternative to email and SMS, focused on one-way “ping”-style messaging — ideal for alerts, reports, logs, and automated notifications.
Looking for a minimal alternative to
python-telegram-bot? Pingram avoids the event loop, handlers, and 7.8MB install size, focusing solely on outbound pings with just one method per use case.
Lightweight by Design
Pingram prioritizes size, speed, and clarity. Designed to be imported and deployed instantly.
| Package | Size |
|---|---|
| Pingram (core) | ~20 KB |
| Pingram + httpx | ~800 KB |
| python-telegram-bot | ~7.8 MB |
Result:
- Pingram is over 9× smaller than PTB even with
httpxincluded. - Pingram core is ~390× smaller than PTB alone.
- That's a ~90% reduction with dependencies, and ~99.7% without.
Perfect for:
- Minimal Docker containers
- Constrained environments
- Clean, single-purpose automation
Features
- Send messages, photos, documents, audio, and video
- Direct method calls:
bot.message(),bot.send_photo(), etc. - Minimalistic architecture (single file, no listeners or webhooks)
- Built on
httpx(sync) - No webhook setup or event loop required
Who is it for?
- Developers who want zero-setup Telegram alerts
- Sysadmins replacing email/SMS for cron/CI jobs
- Raspberry Pi or IoT projects needing compact tooling
- Traders, scrapers, and bots that need lightweight push
Installation
pip install pingram
Quickstart
from pingram import Pingram
bot = Pingram(token="<BOT_TOKEN>")
bot.me()
A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object. https://core.telegram.org/bots/api#getme
Since every high-level api function returns a http.Response object, you can append the end of a function call using .text to show the raw HTTP response instead of the status code.
bot.message(chat_id=123456789, text="Hello Friend").text
This call returns a success or error message from the Telegram API.
Media Examples
All media-sending methods accept both local file paths and direct URLs.
Ensure URLs are direct links (i.e. ending in.jpg,.mp4,Content-Typeheaders.
Send Photo
bot.send_photo(
chat_id=123456789,
path="https://example.com/image.jpg",
caption="Test Photo"
)
From a local file:
bot.send_photo(
chat_id=123456789,
path="photo.jpg",
caption="Local Image"
)
Send Document
bot.send_doc(
chat_id=123456789,
path="https://example.com/file.pdf",
caption="Monthly Report"
)
From a local file:
bot.send_doc(
chat_id=123456789,
path="report.pdf",
caption="Monthly Report"
)
Send Audio
bot.send_audio(
chat_id=123456789,
path="https://www.myinstants.com//media/sounds/hello-friend-mr-robot.mp3",
caption="Greetings."
)
From a local file:
bot.send_audio(
chat_id=123456789,
path="audio.mp3",
caption="Shower Thoughts"
)
Send Video
bot.send_video(
chat_id=123456789,
path="https://yourdomain.com/video.mp4", # must be direct link to .mp4
caption="Security Footage"
)
From a local file:
bot.send_video(
chat_id=123456789,
path="stranger.mp4",
caption="Security Footage"
)
Additional Request Data
Including additional data such as a caption, description or any other key, value types supported by the Telegram API can be passed through any API call simply by including it in the params of the function.
bot.send_video(
chat_id=123456789,
path="hamsters.mp4",
caption="Playful Hamsters",
has_spoiler=True
)
The has_spoiler parameter is a native Telegram option. It must be passed as a bool.
Benefits
- Zero dependencies (core only) — optional httpx for HTTP transport
- Drop-in compatible with shell scripts, cron jobs, CI pipelines, and Python daemons
- Portable single-file design — easy to vendor or embed in other tools
- No auth handshakes or token refreshes — Telegram bots use static tokens
- Reliable delivery with near-instant notifications across devices
- Bypasses email blacklists and spam filters
- Built for automation — ideal for alerts, monitoring, backups, and trading systems
- Rich media support — send screenshots, logs, documents, audio, and video
- Predictable return values — inspect status_code, .text, or .json() directly
- Excellent replacement for SMTP, SMS, or third-party notification APIs
- Runs anywhere Python runs — from Raspberry Pi to cloud VMs
- No app approval or webhook infrastructure required
Tests
Pingram includes a real-world test suite (no mocks). Tests send actual messages to verify API behavior, which is useful for edge-case detection (e.g., rate limits, content type mismatches).
To run the tests:
# Ensure .env has BOT_TOKEN and CHAT_ID
# .env example:
# BOT_TOKEN=123456789:ABCDEF
# CHAT_ID=123456789
pytest
# To include test failure messages you can use:
pytest -rs
Planned features
- Retry and error handling
- Async mode (httpx.AsyncClient)
- Message templating engine
- Std input/message collectors
- Webhook-to-Telegram bridge
- Package tests and CI integration
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 pingram-0.3.4.tar.gz.
File metadata
- Download URL: pingram-0.3.4.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5708ad1a14c37f162d8fddce685d2dfba9aa9e35a41134e4a04ff633466973dc
|
|
| MD5 |
5f9ab42b962c731cb8b2d174a9b98c23
|
|
| BLAKE2b-256 |
dd5e872f701b49ead79a7f1a4af2f03452fc9edd2077df2f4478d32f54b1cae5
|
File details
Details for the file pingram-0.3.4-py3-none-any.whl.
File metadata
- Download URL: pingram-0.3.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.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a372edde4b786db4163695da27aff1bae4a044b928c962d5cf8294864088fdbd
|
|
| MD5 |
58d4fa8a441a5f57f0e934932237b53e
|
|
| BLAKE2b-256 |
4895989bf3fa2713474bddd94b020bb0c375e308f57e1e683b69646cb2d1cd07
|