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.1.tar.gz (45.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.1-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

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

Hashes for dexfather-0.4.1.tar.gz
Algorithm Hash digest
SHA256 bea57e7d9b7f9e8d6cc044f97838db3ccce491a852e4cda47053c0566e002055
MD5 ee04f0412bc72d1fc183814ae3add409
BLAKE2b-256 1449fa738abf1a80291d3a138b61e91d7fb7f698d96a04877429d8e00d7d92b1

See more details on using hashes here.

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

Hashes for dexfather-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1086ac49291ffc24146f8d08ccc21d8bea2662d25718ddb7c7fd9e84e7ebea2
MD5 5e9d7b093c2b3a69450058e075e368db
BLAKE2b-256 9cb00f7fc3532cc19b800a04235e8f423fb096bfb7c27bba1d46badc7cdb8e1b

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