Types & models
Thin, readable wrappers over the decoded protocol dicts. Each one keeps the raw
payload in .raw, so nothing is ever lost.
Message
57 public members. The ones you will actually use:
| Member | Returns |
|---|---|
id / message_id | Message id |
text | Plain text or "" |
content | Structured body dict |
chat / chat_id | Conversation |
from_user / sender / sender_id | Author |
is_outgoing / is_incoming | Direction |
is_reply / reply_to_message | Quoting |
photo, document, video, voice, audio, sticker, location, contact, poll | Typed media accessors or None |
media | Whatever media the message carries |
buttons | Inline keyboard rows |
command / command_args | "/start", "foo bar" |
matches | Regex groups when a pattern filter matched |
reply_to_message_id | int |
print(message.text)
print(message.is_outgoing)
print(message.command, message.command_args)
print(message.photo.width if message.photo else None)
Actions
| Method | Does |
|---|---|
answer(text) / reply(text) | Reply in the same chat |
reply_photo, reply_document, reply_voice, reply_video, reply_audio, reply_sticker | Reply with media |
edit_text(text) | Edit in place |
delete() | Delete for everyone |
forward(to_peer) / copy(to_peer) | Forward with or without an attribution header |
react(emoji) / remove_reaction() | Reactions |
pin() / unpin() / unpin_all() | Pinning |
seen() | Mark read |
download(path=None) | Save the attached file |
click(button) | Trigger an inline button |
load_history, clear_chat, delete_chat | Chat-level operations |
report(reason) / get_fsm_context() | Reporting, FSM access |
User
user.full_name
user.first_name / user.last_name
user.phone
user.mention() # "@username" or a display name
user.is_self
await user.send_message("hi")
await user.block()
await user.unblock()
Chat
chat.id # full peer string
chat.title / chat.full_name
chat.is_private / is_group / is_channel
chat.mention()
await chat.send("hi")
await chat.send_photo(...)
await chat.send_action("typing")
await chat.load_history(limit=50)
await chat.leave()
Dialog & DialogsList
dialogs = await client.get_dialogs()
item = dialogs.find_by_id("987654321|2")
item = dialogs.find_by_username("bale_team")
print(item.title)
Media
if message.photo:
print(message.photo.width, message.photo.height)
await message.photo.download("/tmp/out.jpg")
Peer
from balexyz import Peer
peer = Peer.parse("987654321|2")
peer.kind # "group"
peer.is_group # True
peer.to_dict() # {"id": 987654321, "type": 2}
Keyboards
from balexyz.keyboards import InlineKeyboardMarkup, InlineKeyboardButton
keyboard = InlineKeyboardMarkup()
keyboard.add(InlineKeyboardButton("Approve", callback_data="ok"))
keyboard.add(InlineKeyboardButton("Docs", url="https://example.com"))
keyboard.row(
InlineKeyboardButton("1", callback_data="1"),
InlineKeyboardButton("2", callback_data="2"),
)
doc = keyboard.to_dict()
Serialisation
Every model inherits from Serializable:
message.to_dict()
message.as_dict() # alias
message.to_json()
message.as_json()
bale xyz 1.0.0 · MIT licensed · unofficial client
© 2026 bale xyz contributors