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.

Layer 223

messages.messages#1d73e7ea messages:Vector<Message> topics:Vector<ForumTopic> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messagesSlice#5f206716 flags:# inexact:flags.1?true count:int next_rate:flags.0?int offset_id_offset:flags.2?int search_flood:flags.3?SearchPostsFlood messages:Vector<Message> topics:Vector<ForumTopic> 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#f2c4f24d flags:# hashtag:flags.0?string query:flags.1?string offset_rate:int offset_peer:InputPeer offset_id:int limit:int allow_paid_stars:flags.2?long = messages.Messages;

Parameters #

NameTypeDescription
flags#Flags, see TL conditional fields
hashtagflags.0?stringThe hashtag to search, without the # character.
queryflags.1?stringThe 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_rateintInitially 0, then set to the next_rate parameter of messages.messagesSlice, or if that is absent, the date of the last returned message.
offset_peerInputPeerOffsets for pagination, for more info click here
offset_idintOffsets for pagination, for more info click here
limitintMaximum number of results to return, see pagination
allow_paid_starsflags.2?longFor 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 #

CodeTypeDescription
420FROZEN_METHOD_INVALIDThe current account is frozen, and thus cannot execute the specified action.
400OFFSET_PEER_ID_INVALIDThe provided offset peer is invalid.
403PREMIUM_ACCOUNT_REQUIREDA premium account is required to execute this action.

Search and filters #

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.