messages.search #

Search for messages.

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---
messages.search#29ee847a flags:# peer:InputPeer q:string from_id:flags.0?InputPeer saved_peer_id:flags.2?InputPeer saved_reaction:flags.3?Vector<Reaction> top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages;

Parameters #

NameTypeDescription
flags#Flags, see TL conditional fields
peerInputPeerUser or chat, histories with which are searched, or (inputPeerEmpty) constructor to search in all private chats and normal groups (not channels) ». Use messages.searchGlobal to search globally in all chats, groups, supergroups and channels.
qstringText search request
from_idflags.0?InputPeerOnly return messages sent by the specified user ID
saved_peer_idflags.2?InputPeerSearch within the saved message dialog » with this ID.
saved_reactionflags.3?Vector<Reaction>You may search for saved messages tagged » with one or more reactions using this flag.
top_msg_idflags.1?intThread ID
filterMessagesFilterFilter to return only specified message types
min_dateintIf a positive value was transferred, only messages with a sending date bigger than the transferred one will be returned
max_dateintIf a positive value was transferred, only messages with a sending date smaller than the transferred one will be returned
offset_idintOnly return messages starting from the specified message ID
add_offsetintAdditional offset
limitintNumber of results to return, can be 0 to only return the message counter.
max_idintMaximum message ID to return
min_idintMinimum message ID to return
hashlongHash

Result #

messages.Messages

Only users can use this method #

Possible errors #

CodeTypeDescription
400CHANNEL_INVALIDThe provided channel is invalid.
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
403CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this.
400CHAT_ID_INVALIDThe provided chat id is invalid.
400FROM_PEER_INVALIDThe specified from_id is invalid.
400INPUT_FILTER_INVALIDThe specified filter is invalid.
400INPUT_USER_DEACTIVATEDThe specified user was deleted.
400MSG_ID_INVALIDInvalid message ID provided.
400PEER_ID_INVALIDThe provided peer id is invalid.
400PEER_ID_NOT_SUPPORTEDThe provided peer ID is not supported.
400SEARCH_QUERY_EMPTYThe search query is empty.
400TAKEOUT_INVALIDThe specified takeout ID is invalid.
400USER_ID_INVALIDThe provided user ID is invalid.

inputPeerEmpty #

An empty constructor, no user or chat is defined.

Channels, supergroups, gigagroups and basic groups #

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

messages.searchGlobal #

Search for messages and peers globally

Saved messages #

The Saved Messages chat allows users to bookmark messages and media: it's a personal cloud storage for any messages or media you may want to send or forward there.

Message threads #

Telegram allows commenting on a channel post or on a generic supergroup message, thanks to message threads.

Pagination in the API #

How to fetch results from large lists of objects.