The simplest way to send Telegram messages from Python
Project description
EzTelegramAPI
The simplest way to send Telegram messages from Python.
Four functions. One class. Zero boilerplate. Just send.
Not a bot framework — no receiving, no handlers, no polling.
🔗 GitHub: https://github.com/EmptyOverlord/EzTelegramAPI
📦 PyPI: https://pypi.org/project/eztelegramapi/
Installation
pip install EzTelegramAPI
Two ways to use it
1. Functions — quick and direct
No setup, just call and go. Perfect for one-off scripts and alerts.
from eztelegramapi import send_message, edit_message, delete_message, forward_message
TOKEN = "123456789:AABBCCDDEEFFaabbccddeeff-1234567890"
CHAT_ID = 987654321
msg_id = send_message(TOKEN, CHAT_ID, "Hello from EzTelegramAPI! 🚀")
edit_message(TOKEN, CHAT_ID, msg_id, "Updated message ✏️")
delete_message(TOKEN, CHAT_ID, msg_id)
forward_message(TOKEN, from_chat_id=CHAT_ID, to_chat_id=987654322, message_id=msg_id)
2. Class — no repetition
Set your token and chat_id once — every method uses them automatically.
Pass chat_id= to any method to override for that call only.
from eztelegramapi import EzTelegramBot
bot = EzTelegramBot(token="123456789:AABBCCDDEEFFaabbccddeeff-1234567890", chat_id=987654321)
msg_id = bot.send_message("Hello from EzTelegramAPI! 🚀") # → sends to 987654321
bot.edit_message(msg_id, "Updated message ✏️")
bot.delete_message(msg_id)
# forward_message uses bot.chat_id as to_chat_id by default
bot.forward_message(from_chat_id=987654322, message_id=msg_id) # → forwards to 987654321
# override chat_id for a single call
bot.send_message("Alert!", chat_id=OTHER_CHAT_ID)
That's it. Seriously.
Why EzTelegramAPI?
| EzTelegramAPI | Other libraries | |
|---|---|---|
| Setup | None | Config, classes, handlers... |
| Lines to send a message | 1 | 5–20+ |
| Dependencies | requests |
Multiple |
| Learning curve | Minutes | Hours |
API Reference
Functions
send_message(token, chat_id, text, *, return_message_id=True)
| Parameter | Type | Description |
|---|---|---|
token |
str |
Your bot token from @BotFather |
chat_id |
int |
Target chat or user ID |
text |
str |
Message text (supports emoji ✅) |
return_message_id |
bool |
True (default) → returns message_id; False → returns raw requests.Response |
Returns: int (message_id) or requests.Response
edit_message(token, chat_id, message_id, text)
| Parameter | Type | Description |
|---|---|---|
token |
str |
Your bot token from @BotFather |
chat_id |
int |
Target chat or user ID |
message_id |
int |
ID of the message to edit |
text |
str |
New message text |
Returns: requests.Response
delete_message(token, chat_id, message_id)
| Parameter | Type | Description |
|---|---|---|
token |
str |
Your bot token from @BotFather |
chat_id |
int |
Target chat or user ID |
message_id |
int |
ID of the message to delete |
Returns: requests.Response
forward_message(token, from_chat_id, to_chat_id, message_id)
| Parameter | Type | Description |
|---|---|---|
token |
str |
Your bot token from @BotFather |
from_chat_id |
int |
Chat to forward the message from |
to_chat_id |
int |
Chat to forward the message to |
message_id |
int |
ID of the message to forward |
Returns: int (message_id of the forwarded message)
Class
EzTelegramBot(token, chat_id=None)
| Parameter | Type | Description |
|---|---|---|
token |
str |
Your bot token from @BotFather |
chat_id |
int | None |
Default chat ID used by all methods — pass chat_id= to any method to override for that call |
All methods mirror the functions above but without token.
Examples
Live progress update:
import time
msg_id = bot.send_message("⏳ Job started...")
time.sleep(5)
bot.edit_message(msg_id, "✅ Job finished!")
Clean up after yourself:
msg_id = bot.send_message("⏳ Processing...")
do_work()
bot.delete_message(msg_id)
Alert on error:
try:
risky_operation()
except Exception as e:
bot.send_message(f"🔴 Error: {e}")
Cron job notification:
from datetime import datetime
now = datetime.now().strftime("%Y-%m-%d %H:%M")
bot.send_message(f"✅ Backup finished at {now}")
How to get your Chat ID
- Start a chat with @userinfobot
- Send
/start - It replies with your numeric ID — use that as
chat_id
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
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 eztelegramapi-1.0.3.tar.gz.
File metadata
- Download URL: eztelegramapi-1.0.3.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 |
dd34a60246b0ae1f37c83da84cf1b360e6db39240cbb1f07c3e024bd87180c48
|
|
| MD5 |
45145bbdb0a0fc0275ea7f46bcb8422c
|
|
| BLAKE2b-256 |
51db0773d42e22f88a026ed2e89071ee738f049520c41633b12123c280ead0cd
|
File details
Details for the file eztelegramapi-1.0.3-py3-none-any.whl.
File metadata
- Download URL: eztelegramapi-1.0.3-py3-none-any.whl
- Upload date:
- Size: 5.2 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 |
9862175f3adc3666eb74949c822668073bd3a4a3c31eff7f6bda2ef6aa560381
|
|
| MD5 |
10db9174d5793d7dce46c12e9ed58e9a
|
|
| BLAKE2b-256 |
fba18a2d0da7ff90884d27c829f40ad63c78866c5e10e6a97d52a34f5e9d8ab5
|