channels.searchPosts

Globally search for posts from public channels » (including those we aren't a member of) containing either a specific hashtag, or a full text query.

Exactly one of query and hashtag must be set.

messages.messages#8c718e87 messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messagesSlice#3a54685e flags:# inexact:flags.1?true count:int next_rate:flags.0?int offset_id_offset:flags.2?int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.channelMessages#c776ba4e flags:# inexact:flags.1?true pts:int count:int offset_id_offset:flags.2?int messages:Vector<Message> topics:Vector<ForumTopic> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messagesNotModified#74535f21 count:int = messages.Messages;
---functions---
channels.searchPosts#d19f987b hashtag:string offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;

Parameters

Name Type Description
flags # Flags, see TL conditional fields
hashtag flags.0?string The hashtag to search, without the # character.
query flags.1?string The full text query: each user has a limited amount of free full text search slots, after which payment is required, see here » for more info on the full flow.
offset_rate int Initially 0, then set to the next_rate parameter of messages.messagesSlice, or if that is absent, the date of the last returned message.
offset_peer InputPeer Offsets for pagination, for more info click here
offset_id int Offsets for pagination, for more info click here
limit int Maximum number of results to return, see pagination
allow_paid_stars flags.2?long For full text post searches (query), allows payment of the specified amount of Stars for the search, see here » for more info on the full flow.

Result

messages.Messages

Only users can use this method

Possible errors

Code Type Description
420 FROZEN_METHOD_INVALID The current account is frozen, and thus cannot execute the specified action.

Related pages

Search

Telegram allows applying detailed message filters while looking for messages in chats.

messages.messagesSlice

Incomplete list of messages and auxiliary data.

Pagination in the API

How to fetch results from large lists of objects.

Channels, supergroups, gigagroups and basic groups

How to handle channels, supergroups, gigagroups, basic groups, and what's the difference between them.

User Authorization

How to register a user's phone to start using the API.