search_global_hashtag_messages()

Client.search_global_hashtag_messages()

Searches for public channel posts with the given hashtag. For optimal performance, the number of returned messages is chosen by Telegram Server and can be smaller than the specified limit.

If you want to get the posts count only, see search_public_hashtag_messages_count().

Usable by Users Bots
Parameters:
  • hashtag (str, optional) – Hashtag to search for.

  • offset_id (int, optional) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results.

  • offset_date (datetime, optional) – Pass a date as offset to retrieve only older messages starting from that date.

  • limit (int, optional) – The maximum number of messages to be returned. By default, no limit is applied and all posts are returned.

Returns:

Generator – A generator yielding Message objects.

Example

# Search for "#pyrogram". Get the first 50 results
async for message in app.search_public_hashtag_messages("#pyrogram"):
    print(message.text)