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.5.0.tar.gz (70.2 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.5.0-py3-none-any.whl (53.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dexfather-0.5.0.tar.gz
  • Upload date:
  • Size: 70.2 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

Hashes for dexfather-0.5.0.tar.gz
Algorithm Hash digest
SHA256 f79768b3ea2b0fe3769e9c8f7f2ada797bbb2f714f3b393b4eeceb755ebf0318
MD5 925bea3908bdfb95832111d0253f9fb7
BLAKE2b-256 67b117aec0cb1b6bf49f9d9ad9d7e5691d02f95ad8cf859c5ccef564bb973e54

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dexfather-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 53.6 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

Hashes for dexfather-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f8f2a00b9f04c141aa4020434f7c015d56feb7fcef8fe1140d9038af619497e
MD5 acc24c856a2cd8e76a37d88581717d0c
BLAKE2b-256 858bcc5eab9b05c10591afd3ae78d338313da338defc43f7e57a1bf7ad454062

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