messages.search

Search for messages.

API section: Working with messages

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 # Bit mask: a field written flags.N?T is present only when bit N is set.
peer InputPeer The user or chat the request is about.
q string Search query.
from_id flags.0?InputPeer Sender.
saved_peer_id flags.2?InputPeer Section of Saved Messages the request is about.
saved_reaction flags.3?Vector<Reaction>
top_msg_id flags.1?int Forum topic identifier.
filter MessagesFilter Selection filter.
min_date int
max_date int
offset_id int Identifier to continue the selection from.
add_offset int Extra shift relative to offset_id.
limit int Maximum number of records to return.
max_id int Upper bound on the identifier.
min_id int Lower bound on the identifier.
hash long Hash of what the client already has. If it matches, the server answers "not modified" and sends nothing again.

Result

messages.Messages

Possible errors

This method has no errors of its own: it either answers or fails on the shared checks below.

Common to every call

CodeTypeWhat it means
401 AUTH_KEY_UNREGISTERED The server does not know this session: the key was revoked, expired, or the call was made before authorisation.
401 API_ID_INVALID This api_id was never issued or has been blocked. Keys come from my.ansible.su.
400 CONNECTION_LAYER_INVALID The client did not declare a layer, or declared one the server does not know.
420 FLOOD_WAIT_X Too often. Do not retry for X seconds — the number arrives in the error text.
500 INTERNAL A failure on our side. The request may be retried; if it keeps failing, it is a bug of ours.

This call counts as expensive: its cost grows with the amount of data, so under peak load it goes through admission control and may answer FLOOD_WAIT where cheap calls always pass. Build retries with a backoff.

Related pages

Types used here