get_chat_history_count()#

Client.get_chat_history_count()#

Get the total count of messages in a chat.

Note

Due to Telegram latest internal changes, the server can’t reliably find anymore the total count of messages a private or a basic group chat has with a single method call. To overcome this limitation, Pyrogram has to iterate over all the messages. Channels and supergroups are not affected by this limitation.

Usable by Users Bots
Parameters:

chat_id (int | str) – Unique identifier (int) or username (str) of the target chat.

Returns:

int – On success, the chat history count is returned.

Example

await app.get_history_count(chat_id)