Skip to main content
TelegramAPI is a small, explicit client for the Telegram Bot API. It handles the repetitive parts of bot development: long polling, parsed message objects, file uploads, media groups, downloads, retries, and readable exceptions. It is designed for scripts and small bots that should be easy to read and easy to debug.

Quickstart

Create a bot, find your chat ID, and send your first message.

Send messages

Text, inline keyboards, contacts, locations, and chat actions.

Read updates

Poll Telegram and work with parsed message data.

Download files

Save attachments to disk or keep them in memory.

What it covers

  • Long polling with server-side long polling and configurable failure retries
  • Parsed Message objects alongside the untouched Telegram payload
  • Text, contact, location, photo, video, audio, voice, document, sticker, animation, and video note messages
  • Media groups from lists, including automatic chunking above Telegram’s 10-item limit
  • Files from disk, URLs, Telegram file IDs, in-memory bytes, and open file objects
  • Inline keyboards, callback answers, chat actions, and message edits
  • Forwarding, copying, deleting, pinning, and unpinning messages
  • Downloads to disk or memory with custom names
  • Webhooks and bot, chat, and file information
  • Typed exceptions for API, network, and timeout failures

Requirements

  • Python 3.10 or newer
  • requests
All sending methods return a parsed Message object. Media-group sends return a list of Message objects. copy_message returns a dictionary containing the new message_id, and methods that only confirm success return Telegram’s raw result, usually True.