search_posts_count()

async Client.search_posts_count()

Get the number of public posts matching a hashtag or a text search.

Usable by Users Bots
Parameters:
  • hashtag (str, optional) – Hashtag to search for, with or without the leading “#”.

  • query (str, optional) – Text to search for instead of a hashtag. Searching by text requires a Premium account; Telegram answers [403 PREMIUM_ACCOUNT_REQUIRED] otherwise.

Returns:

int – On success, the posts count is returned.

Raises:

ValueError – In case neither hashtag nor query is given.

Example

count = await app.search_posts_count("wzgram")