Adstelo Python SDK
Monetize your Telegram bot with a single line of code.
Adstelo lets you earn revenue from ads displayed in your Telegram bot — just add two lines to your existing bot and start earning.
Table of Contents
- How It Works
- Installation
- Quick Start
- Supported Libraries
- Configuration Reference
- Getting Your Keys
- FAQ
- You register your bot on Adstelo and get a
bot_secret+api_key. - You call
adstelo.init(...)once at the top of your bot code. - The SDK records usage metrics to help Adstelo optimize ad delivery.
- No message content is ever read or transmitted to Adstelo or any third party. Only high-level usage metrics are sent in the background.
Security: Your Telegram bot token is never transmitted. Only an opaque
bot_secretis sent. All requests are HMAC-signed with your API key.
Installation
pip install adstelo
Requires Python 3.7+. The only dependency is aiohttp.
Quick Start
import adstelo
adstelo.init(
bot_secret="your-bot-secret", # From your Adstelo dashboard
api_key="your-api-key", # From your Adstelo dashboard
)
# ... rest of your bot code, completely unchanged
That's it. The SDK auto-detects whichever Telegram library you have installed and patches it transparently.
Supported Libraries
aiogram v3
import adstelo
from aiogram import Bot, Dispatcher
# ✅ Initialize Adstelo BEFORE creating the Dispatcher
adstelo.init(
bot_secret="your-bot-secret",
api_key="your-api-key",
)
bot = Bot(token="YOUR_BOT_TOKEN")
dp = Dispatcher()
@dp.message()
async def handle_message(message):
await message.answer("Hello!")
# Run your bot as usual
import asyncio
asyncio.run(dp.start_polling(bot))
python-telegram-bot v20+
import adstelo
from telegram.ext import Application, MessageHandler, filters
# ✅ Initialize Adstelo BEFORE building the Application
adstelo.init(
bot_secret="your-bot-secret",
api_key="your-api-key",
)
async def handle_message(update, context):
await update.message.reply_text("Hello!")
app = Application.builder().token("YOUR_BOT_TOKEN").build()
app.add_handler(MessageHandler(filters.TEXT, handle_message))
app.run_polling()
pyTelegramBotAPI (telebot)
Synchronous:
import adstelo
import telebot
# ✅ Initialize Adstelo BEFORE creating the TeleBot instance
adstelo.init(
bot_secret="your-bot-secret",
api_key="your-api-key",
)
bot = telebot.TeleBot("YOUR_BOT_TOKEN")
@bot.message_handler(func=lambda m: True)
def handle_message(message):
bot.send_message(message.chat.id, "Hello!")
bot.infinity_polling()
Async:
import adstelo
from telebot.async_telebot import AsyncTeleBot
import asyncio
adstelo.init(
bot_secret="your-bot-secret",
api_key="your-api-key",
)
bot = AsyncTeleBot("YOUR_BOT_TOKEN")
@bot.message_handler(func=lambda m: True)
async def handle_message(message):
await bot.send_message(message.chat.id, "Hello!")
asyncio.run(bot.polling())
Telethon
import adstelo
from telethon import TelegramClient, events
# ✅ Initialize Adstelo BEFORE creating the TelegramClient
adstelo.init(
bot_secret="your-bot-secret",
api_key="your-api-key",
)
client = TelegramClient("my_bot", api_id=12345, api_hash="your_api_hash")
client.start(bot_token="YOUR_BOT_TOKEN")
@client.on(events.NewMessage)
async def handle_message(event):
await event.reply("Hello!")
client.run_until_disconnected()
Configuration Reference
| Parameter | Type | Required | Description |
|---|---|---|---|
bot_secret |
str |
✅ Yes | Your bot's secret from the Adstelo dashboard. Identifies your bot server-side without exposing your Telegram token. |
api_key |
str |
✅ Yes | Your Adstelo API key. Used to authenticate requests and sign payloads. |
cooldown |
int | float |
❌ No | Per-user event cooldown in seconds. Default: 2. Prevents duplicate events from rapid interactions. |
Getting Your Keys
- Sign up at adstelo.com and log in to your dashboard
- Go to "Register Bot" and submit your bot's Telegram username
- Once approved, your dashboard will show:
bot_secret— unique to each registered botapi_key— tied to your account (used across all your bots)
- Copy both values and pass them to
adstelo.init()
Your
api_keyis like a password — keep it private and never commit it to version control. Use environment variables:import os, adstelo adstelo.init( bot_secret=os.environ["ADSTELO_BOT_SECRET"], api_key=os.environ["ADSTELO_API_KEY"], )
FAQ
Does this slow down my bot? No. Events are dispatched asynchronously in the background and never block your handlers. The timeout for each request is 3 seconds and errors are silently swallowed.
What if I use a library that isn't listed? The SDK currently supports aiogram v3, python-telegram-bot v20+, pyTelegramBotAPI (sync & async), and Telethon. More libraries are on the roadmap. Open an issue or email support@adstelo.com.
What exactly is tracked?
The SDK reports: user ID, chat ID, event type (message, button, photo, video, sticker, inline_query), a timestamp, and whether it was a /start command. No message content is ever read or transmitted.
What is the difference between bot_secret and api_key?
bot_secret— identifies which bot generated the event. One per bot.api_key— authenticates your account. One per publisher account.
Do I need to change anything else in my bot?
No. Call adstelo.init() once at startup before your Dispatcher/Application/Bot is created, and everything else stays exactly as-is.
When do I get paid? Earnings from ads displayed in your bot accumulate in your Adstelo dashboard. Withdrawals are processed on request. See adstelo.com for payout details.
License
Proprietary — © Adstelo. All rights reserved.
Metadata
Release files for adstelo 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| adstelo-0.2.2.tar.gz | 12.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| adstelo-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.9 kB
Release files / adstelo-0.2.2.tar.gz
| Download URL | adstelo-0.2.2.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e276a9fd064c0346bc57997f7c4dd7d1254fc51f5dc512508e654985803bb837
|
|
BLAKE2b-256 checksum How to use checksums |
8254badbaf53ca7f28646ec353fc78011eb6729aae0463aaf7d1f685fc284cf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / adstelo-0.2.2-py3-none-any.whl
| Download URL | adstelo-0.2.2-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c72225e7de0127c52c43684578ce18b0043fe2024b30dfe23ff3073d2b6a12f
|
|
BLAKE2b-256 checksum How to use checksums |
9640dc0635b2fce54f5e3af575da0a53e568320f10a38c165a7500b0cbe89641
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for adstelo 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.