Skip to main content

Raw updates

get_updates() returns Telegram’s raw update dictionaries and advances the internal offset for you:

Parsed updates

poll_updates() is a generator that parses each update into a Message object:
With long polling enabled (the default), Telegram holds the request for up to long_poll_timeout seconds, so polling_interval is only used when long_poll_timeout = 0. max_retries limits consecutive network or server failures. Permanent errors such as an invalid token or a webhook conflict are raised immediately.

Parsed message data

Common fields are available directly on the Message object: Media properties such as message.photo, message.document, message.audio, message.video, message.voice, message.animation, message.sticker, message.video_note, message.contact, and message.location are parsed objects with the fields Telegram provides.

Non-message updates

Updates such as callback queries are also returned as Message objects. Their update_type is set, and the untouched update is available in .raw:

Backwards-compatible aliases

Older names are still available:
  • message.id is message.message_id
  • sticker.type is sticker.sticker_type
  • video.unique_id is video.file_unique_id
  • video.video_size is video.file_size
A webhook and poll_updates() cannot be used at the same time. Call delete_webhook() before switching back to polling.