Layer 220
method Users
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

Name Type Description
Flags # Flags, see TL conditional fields
Peer InputPeer User or chat, histories with which are searched, or (input Peer Empty) constructor to search in all private chats and normal groups (not channels). Use messages. search Global to search globally in all chats, groups, supergroups and channels.
Q string Text search request
FromId flags.0?InputPeer Only return messages sent by the specified user ID
SavedPeerId flags.2?InputPeer Search within the saved message dialog with this ID.
SavedReaction Vector<Reaction> You may search for saved messages tagged with one or more reactions using this flag.
TopMsgId flags.1?int Thread ID
Filter MessagesFilter Filter to return only specified message types
MinDate int If a positive value was transferred, only messages with a sending date bigger than the transferred one will be returned
MaxDate int If a positive value was transferred, only messages with a sending date smaller than the transferred one will be returned
OffsetId int Only return messages starting from the specified message ID
AddOffset int Additional offset
Limit int Number of results to return, can be 0 to only return the message counter.
MaxId int Maximum message ID to return
MinId int Minimum message ID to return
Hash long Hash

Possible Errors

Code Type Description
400 CHANNEL_INVALID The provided channel is invalid.
400 CHANNEL_PRIVATE You haven't joined this channel/supergroup.
403 CHAT_ADMIN_REQUIRED You must be an admin in this chat to do this.
400 CHAT_ID_INVALID The provided chat id is invalid.
400 FROM_PEER_INVALID The specified from_id is invalid.
400 INPUT_FILTER_INVALID The specified filter is invalid.
400 INPUT_USER_DEACTIVATED The specified user was deleted.
400 MSG_ID_INVALID Invalid message ID provided.
400 PEER_ID_INVALID The provided peer id is invalid.
400 PEER_ID_NOT_SUPPORTED The provided peer ID is not supported.
400 SEARCH_QUERY_EMPTY The search query is empty.
400 TAKEOUT_INVALID The specified takeout ID is invalid.
400 USER_ID_INVALID The provided user ID is invalid.

Gogram Example

// MessagesSearch - using Params struct
result, err := client.MessagesSearch(&tg.MessagesSearchParams{
    Peer: &tg.InputPeerUser{UserID: int64(123456789)},
    Q: "...",
    Filter: &tg.MessagesFilter{},
    MinDate: 0,
    MaxDate: 0,
    OffsetId: 0,
    AddOffset: 0,
    Limit: 0,
    // ...

    // Optional fields:
    // FromId: &tg.InputPeerUser{UserID: int64(123456789)},
    // SavedPeerId: &tg.InputPeerUser{UserID: int64(123456789)},
    // SavedReaction: []tg.Reaction{&tg.Reaction{}},
    // TopMsgId: 0,
})
if err != nil {
    // handle error
}
// result is *tg.MessagesMessages