Python SDK for the DexFather Bot API — build bots for the Dexster platform
Project description
DexFather
Python SDK for the Dexster Bot API
Build bots for the Dexster social trading platform with an async-first, fully typed Python SDK.
Install
pip install dexfather
Quick Start
import os
from dexfather import DexFatherBot
bot = DexFatherBot(os.environ["DEXSTER_BOT_TOKEN"])
@bot.command("start")
async def on_start(update, bot):
await bot.send_message(
update.message.chat.id,
"Hello! I'm alive.",
)
@bot.on_message()
async def on_echo(update, bot):
await bot.send_message(
update.message.chat.id,
f"You said: {update.message.text}",
)
bot.run_polling()
Features
- Async/await -- built on
httpxfor non-blocking I/O - Rich object models -- Pydantic v2 models for every API type (messages, users, chats, polls, etc.)
- Exception hierarchy --
BadRequest,Unauthorized,Forbidden,NotFound,RateLimitedfor precise error handling - Automatic retries -- exponential backoff with jitter via
tenacity - Middleware pipeline -- plug in logging, timing, rate limiting, or custom pre/post processing
- Keyboard builders --
InlineKeyboardBuilderwith fluent chaining andadjust()layout - Conversation state machine --
ConversationHandlerfor multi-step flows with optional server-side persistence - Inline queries -- handle
@botusernameinline queries with 20+ result types (article, photo, gif, video, audio, document, location, venue, contact + 8 cached variants) - File uploads -- upload files via
uploadFileAPI, getdxf_file_ids, send by file_id withget_file() - Composable filters --
TEXT & ~COMMAND,PHOTO | VIDEO,ChatType.PRIVATE,Regex(r"pattern")with boolean algebra - Reactions -- handle incoming
message_reactionupdates withMessageReactionUpdatedtype - Live location -- send, update, and stop live locations with
send_location(),edit_message_live_location(),stop_message_live_location() - Test utilities --
MockBotandTestClientfor unit testing without a live server - Full type hints --
py.typedmarker for mypy/pyright support - Multiple transports -- polling, WebSocket, and webhook (with Starlette/Uvicorn)
Token Format
Bot tokens use the dxt_<base64url> format. You receive one when creating a bot through @DexFather on Dexster.
Documentation
- Getting Started -- 5-minute tutorial from zero to working bot
- Examples -- Echo bot, keyboard bot, conversation bot, inline bot, admin bot, polls, webhooks
- API Reference -- Generated pdoc HTML covering all public classes and methods
Guides
- Keyboards & Buttons -- Inline keyboards, reply keyboards, button styling
- Inline Mode -- Handle @botusername inline queries
- Callbacks -- Callback query handling and patterns
- Chat Management -- Banning, promoting, permissions
- Conversations -- Multi-step conversation state machine
- Middleware -- Custom pre/post processing pipeline
- File Uploads -- Upload files, file_id system, send by file_id
- Reactions & Updates -- Reactions API and new update types
- Composable Filters -- Boolean filter composition for message handlers
- Live Location -- Real-time location sharing
- Testing -- Unit test your bot with MockBot and TestClient
- Migration from Telegram -- Side-by-side porting guide with 75+ method mappings
Examples
| Example | Description |
|---|---|
| echo_bot.py | Minimal echo bot |
| keyboard_bot.py | Inline and reply keyboards |
| conversation_bot.py | Multi-step conversation state machine |
| inline_bot.py | Inline query handler |
| poll_bot.py | Creating and managing polls |
| admin_bot.py | Chat administration commands |
| menu_bot.py | Bot menu and commands |
| webhook_bot.py | Webhook mode with Starlette |
| file_upload_bot.py | File upload and file_id usage |
| reaction_bot.py | Reactions and reaction updates |
| filter_bot.py | Composable filter expressions |
| live_location_bot.py | Live location tracking |
| demo_bot.py | Full-featured demo covering all SDK capabilities |
Requirements
- Python 3.9+
- Dependencies:
httpx,pydantic,tenacity,structlog - Optional:
uvicorn+starlettefor webhook mode (pip install dexfather[webhook])
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 dexfather-0.4.1.tar.gz.
File metadata
- Download URL: dexfather-0.4.1.tar.gz
- Upload date:
- Size: 45.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bea57e7d9b7f9e8d6cc044f97838db3ccce491a852e4cda47053c0566e002055
|
|
| MD5 |
ee04f0412bc72d1fc183814ae3add409
|
|
| BLAKE2b-256 |
1449fa738abf1a80291d3a138b61e91d7fb7f698d96a04877429d8e00d7d92b1
|
File details
Details for the file dexfather-0.4.1-py3-none-any.whl.
File metadata
- Download URL: dexfather-0.4.1-py3-none-any.whl
- Upload date:
- Size: 41.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1086ac49291ffc24146f8d08ccc21d8bea2662d25718ddb7c7fd9e84e7ebea2
|
|
| MD5 |
5e9d7b093c2b3a69450058e075e368db
|
|
| BLAKE2b-256 |
9cb00f7fc3532cc19b800a04235e8f423fb096bfb7c27bba1d46badc7cdb8e1b
|