Retrieve a chunk of the history of a chat.
You can get up to 100 messages at once. For a more convenient way of getting a chat history see
str) – Unique identifier (int) or username (str) of the target chat. For your personal cloud (Saved Messages) you can simply use “me” or “self”. For a contact that exists in your Telegram address book you can use his phone number (str).
int, optional) – Limits the number of messages to be retrieved. By default, the first 100 messages are returned.
int, optional) – Sequential number of the first message to be returned. Defaults to 0 (most recent message). Negative values are also accepted and become useful in case you set offset_id or offset_date.
int, optional) – Pass a message identifier as offset to retrieve only older messages starting from that message.
int, optional) – Pass a date in Unix time as offset to retrieve only older messages starting from that date.
bool, optional) – Pass True to retrieve the messages in reversed order (from older to most recent).
Message- On success, a list of the retrieved messages is returned.
# Get the last 100 messages of a chat app.get_history("pyrogramchat") # Get the last 3 messages of a chat app.get_history("pyrogramchat", limit=3) # Get 3 messages after skipping the first 5 app.get_history("pyrogramchat", offset=5, limit=3)