Skip to main content

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 httpx for 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, RateLimited for 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 -- InlineKeyboardBuilder with fluent chaining and adjust() layout
  • Conversation state machine -- ConversationHandler for multi-step flows with optional server-side persistence
  • Inline queries -- handle @botusername inline queries with 20+ result types (article, photo, gif, video, audio, document, location, venue, contact + 8 cached variants)
  • File uploads -- upload files via uploadFile API, get dxf_ file_ids, send by file_id with get_file()
  • Composable filters -- TEXT & ~COMMAND, PHOTO | VIDEO, ChatType.PRIVATE, Regex(r"pattern") with boolean algebra
  • Reactions -- handle incoming message_reaction updates with MessageReactionUpdated type
  • Live location -- send, update, and stop live locations with send_location(), edit_message_live_location(), stop_message_live_location()
  • Test utilities -- MockBot and TestClient for unit testing without a live server
  • Full type hints -- py.typed marker 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

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 + starlette for webhook mode (pip install dexfather[webhook])

License

MIT

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

dexfather-0.4.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dexfather-0.4.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file dexfather-0.4.0.tar.gz.

File metadata

  • Download URL: dexfather-0.4.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dexfather-0.4.0.tar.gz
Algorithm Hash digest
SHA256 cddb28a60612e101b4860cc6b2a854e769824f6de1ae9ab1a820e9576fada969
MD5 3a170d6cff50a058989d6981788fefa3
BLAKE2b-256 d56c9f8c258fc562885c6b2823c90f6fb47d8cf012e69fa2d67cfa504840a3eb

See more details on using hashes here.

File details

Details for the file dexfather-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: dexfather-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dexfather-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95c5ad5d411155a98e4ab9f0525b98ae43736957bbb81abf780604f44f3e16c3
MD5 e0a9093c26b10b59aef9d45de07dda94
BLAKE2b-256 4b89f3ec630159eedad3764ad66e96b6de8a76643921f91b06010b2195edd38d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page