English فارسی

Chats, groups and users

Listing dialogs, reading history, and the handful of group-management RPCs that have convenience wrappers. Everything else is one raw call away.

Dialogs

page = await client.get_dialogs(limit=100)

for dialog in page.get("dialogs", []):
    print(dialog["peer"], dialog.get("title"))

Each entry carries the peer, the last message, unread counters and pin state.

A single chat

chat = await client.get_chat("987654321|2")

chat.title
chat.is_private / chat.is_group / chat.is_channel
chat.full_name
chat.mention()                # "@..." for usernames
await chat.send("hello")
await chat.send_action("typing")
await chat.load_history(limit=50)
await chat.leave()
async get_chat(chat_id) → dict

Resolves any peer form into a chat record. Returns the decoded bale.groups / bale.users response as a dict.

History

page = await client.get_history("987654321|2", limit=50)

for msg in page.get("messages", []):
    print(msg.get("id"), msg.get("text", "")[:60])

# older pages: pass the smallest id you already have
older = await client.get_history("987654321|2", limit=50, before=minimum_id)
Keys are snake_case.

Every dict returned by get_history, get_chat and friends is normalised to snake_case at every nesting level. This is deliberate: the recovered protocol AST uses webpack's camelCase, and mixing the two spellings silently broke link generation in early builds.

Groups

MethodDoes
create_group(title, members=())Creates a group, optionally seeding members
get_group_info(chat_id)Full group record: members, permissions, invite link
add_group_member(chat_id, user)Adds one member
remove_group_member(chat_id, user)Kicks one member
group = await client.create_group("Deploy alerts", members=["111|1", "222|1"])
info = await client.get_group_info("987654321|2")
await client.add_group_member("987654321|2", "333|1")
await client.remove_group_member("987654321|2", "333|1")

The full bale.groups.v1.Groups service has 50 methods (title editing, invite links, permissions, banning, admin rights…). List them with:

bale-xyz methods -s bale.groups.v1.Groups

Users

me = await client.get_me()

found = await client.search_users("sara", limit=10)
for user in found.get("users", []):
    print(user["id"], user.get("firstName") or user.get("first_name"))

A User object exposes full_name, mention(), phone, is_self, and the actions send_message, block, unblock.

await client.search_messages("987654321|2", "invoice", limit=20)
await client.search_users("+98912", limit=5)
await client.resolve_username("@bale_team")

Your own account

client.user_id      # int
client.me           # dict from GetMe
client.is_user      # True for sessions
client.is_bot       # True for bot tokens
await client.send_message("me", "saved message")
bale xyz 1.0.0 · MIT licensed · unofficial client © 2026 bale xyz contributors