<p>When using <ahref="/method/messages.search">messages.search</a> or <ahref="/method/messages.searchGlobal">messages.searchGlobal</a>, a certain message filter may be applied.<br>
This allows the server to filter messages based on a text query, and even on their type, and this feature is often used by graphical clients to implement features like the chat gallery, chat profile pictures and more.
Available filters:</p>
<ul>
<li><ahref="/constructor/inputMessagesFilterPhotos">inputMessagesFilterPhotos</a> - Returns only photos, used for implementing the chat photo gallery, and when scrolling left or right while viewing a photo</li>
<li><ahref="/constructor/inputMessagesFilterVideo">inputMessagesFilterVideo</a> - Returns only videos, used for implementing the chat video gallery, and when scrolling left or right while viewing a video</li>
<li><ahref="/constructor/inputMessagesFilterPhotoVideo">inputMessagesFilterPhotoVideo</a> - Return only videos and photos, used for implementing the chat media gallery</li>
<li><ahref="/constructor/inputMessagesFilterDocument">inputMessagesFilterDocument</a> - Return only videos and photos, used for implementing the chat document gallery</li>
<li><ahref="/constructor/inputMessagesFilterUrl">inputMessagesFilterUrl</a> - Return only messages with links, used for implementing the chat link gallery</li>
<li><ahref="/constructor/inputMessagesFilterGif">inputMessagesFilterGif</a> - Return only GIFs, used for implementing the chat GIF gallery</li>
<li><ahref="/constructor/inputMessagesFilterVoice">inputMessagesFilterVoice</a> - Return only voice messages, used for implementing the chat voice message gallery, and to consecutively play voice messages in a chat</li>
<li><ahref="/constructor/inputMessagesFilterMusic">inputMessagesFilterMusic</a> - Return only music files, used for implementing the chat music gallery</li>
<li><ahref="/constructor/inputMessagesFilterChatPhotos">inputMessagesFilterChatPhotos</a> - Return only chat photos, used to allow scrolling through the profile picture history of a group</li>
<li><ahref="/constructor/inputMessagesFilterPhoneCalls">inputMessagesFilterPhoneCalls</a> - Return only phone calls, used with <ahref="/method/messages.searchGlobal">messages.searchGlobal</a> to implement the call tab, with the phone call history</li>
<li><ahref="/constructor/inputMessagesFilterRoundVoice">inputMessagesFilterRoundVoice</a> - Return only round videos and voice messages, used to consecutively play round videos and voice messages in a chat</li>
<li><ahref="/constructor/inputMessagesFilterRoundVideo">inputMessagesFilterRoundVideo</a> - Return only round videos, used to consecutively play round videos in a chat</li>
<li><ahref="/constructor/inputMessagesFilterMyMentions">inputMessagesFilterMyMentions</a> - Return only messages mentioning me, can be used to display the <ahref="/api/mentions">mention history</a> or, combined with another filter or query, return only messages that satisfy a certain criteria, and contain a mention.</li>
<li><ahref="/constructor/inputMessagesFilterGeo">inputMessagesFilterGeo</a> - Return only geolocations, is used to fetch all recent valid <ahref="/api/live-location">geolocations or live locations</a> sent in a group, to display them all in a single map</li>
<li><ahref="/constructor/inputMessagesFilterContacts">inputMessagesFilterContacts</a> - Return only contacts</li>
<li><ahref="/constructor/inputMessagesFilterPinned">inputMessagesFilterPinned</a> - Returns only <ahref="/api/pin">pinned messages</a>, used for implementing the pinned message list</li>
</ul>
<p>The returned <ahref="/type/messages.Messages">messages.Messages</a> constructors contain parameters for <ahref="/api/offsets">pagination</a>, the messages themselves and two <code>offset_id_offset</code>/<code>count</code> parameters that can be used to display a <code>progress/total</code> counter like <code>photo 134 of 200</code>.<br>
For example, when displaying the chat photo gallery, we could display a <code>photo ${offset_id_offset} of ${count}</code> indicator on top.</p>
<p>Contains results (peers and messages) from all private/secret chats, private/public groups, private/public channels, split in the following sections:</p>
<ul>
<li><code>Frequent contacts</code>: Contains avatars and names of the most frequently used users, sorted <ahref="/api/top-rating">as specified here»</a> (<ahref="/constructor/topPeerCategoryCorrespondents">topPeerCategoryCorrespondents</a> category). </li>
<li><code>Recent</code>: Contains avatars and names of the most frequently used peers (users+chats+channels), sorted <ahref="/api/top-rating">as specified here»</a> (<ahref="/constructor/topPeerCategoryCorrespondents">topPeerCategoryCorrespondents</a>, <ahref="/constructor/topPeerCategoryBotsPM">topPeerCategoryBotsPM</a>, <ahref="/constructor/topPeerCategoryGroups">topPeerCategoryGroups</a>, <ahref="/constructor/topPeerCategoryChannels">topPeerCategoryChannels</a> categories). </li>
</ul>
<p>Searching when in the "Chats" tab should invoke <ahref="/method/messages.searchGlobal">messages.searchGlobal</a>, replacing the previously mentioned sections with a list of peers (avatar+name) and messages (max one message per peer). </p>
<p>Contains results from private/public channels only, split in the following sections:</p>
<ul>
<li><code>Channels you joined</code>: Contains avatars and names of the most frequently used channels, sorted <ahref="/api/top-rating">as specified here»</a> (<ahref="/constructor/topPeerCategoryChannels">topPeerCategoryChannels</a> category).</li>
<li><code>Similar channels</code>: Contains avatars and names of recommended public channels, similar to the ones the current user has already joined, fetched using <ahref="/method/channels.getChannelRecommendations">channels.getChannelRecommendations</a> without setting the <code>channel</code> flag, see <ahref="/api/recommend">here»</a> for more info. </li>
</ul>
<p>Searching when in the "Channels" tab should invoke <ahref="/method/messages.searchGlobal">messages.searchGlobal</a> with the <code>broadcasts_only</code> flag set, replacing the previously mentioned sections with a list of peers (avatar+name+returned message, max one row per peer). </p>
<p>Used to implement the <ahref="https://telegram.org/blog/w3-browser-mini-app-store#mini-app-store">Mini App Store</a>. </p>
<p>Only contains bots with an associated <ahref="/api/bots/webapps#main-mini-apps">Main Mini App</a> (i.e. those with the <ahref="/constructor/user">user</a>.<code>bot_has_main_app</code> flag set), split in the following sections:</p>
<ul>
<li><code>Apps you use</code>: Contains avatars, names and MAU counters (from <ahref="/constructor/user">user</a>.<code>bot_active_users</code>) for <ahref="/api/bots/webapps#main-mini-apps">Main Mini Apps</a> of bots most frequently used by the user, sorted <ahref="/api/top-rating">as specified here»</a> (<ahref="/constructor/topPeerCategoryBotsApp">topPeerCategoryBotsApp</a> category). </li>
<li><code>Popular apps</code>: Contains avatars, names and MAU counters of the <ahref="/api/bots/webapps#main-mini-apps">Main Mini Apps</a> of the bots returned by <ahref="/method/bots.getPopularAppBots">bots.getPopularAppBots</a>. </li>
</ul>
<p>Searching when in the "Apps" tab should invoke <ahref="/method/messages.searchGlobal">messages.searchGlobal</a>, replacing the previously mentioned sections with a list of avatars, names and MAU counters (from <ahref="/constructor/user">user</a>.<code>bot_active_users</code>) for <ahref="/api/bots/webapps#main-mini-apps">Main Mini Apps</a> of the returned bots (clients should only use the returned <code>users</code> field, filtering for bots with the <ahref="/constructor/user">user</a>.<code>bot_has_main_app</code> flag set). </p>
<p>Searching should invoke <ahref="/method/messages.searchGlobal">messages.searchGlobal</a> with the <ahref="/constructor/inputMessagesFilterPhotoVideo">inputMessagesFilterPhotoVideo</a> filter, rendering the results as specified in the <ahref="#chats-tab">chats tab</a>. </p>
<p>Initially, the tab should be populated with the results returned by passing an empty string in <code>q</code>. </p>
<p>Searching should invoke <ahref="/method/messages.searchGlobal">messages.searchGlobal</a> with the <ahref="/constructor/inputMessagesFilterUrl">inputMessagesFilterUrl</a> filter, rendering the results as specified in the <ahref="#chats-tab">chats tab</a>. </p>
<p>Initially, the tab should be populated with the results returned by passing an empty string in <code>q</code>. </p>
<p>Searching should invoke <ahref="/method/messages.searchGlobal">messages.searchGlobal</a> with the <ahref="/constructor/inputMessagesFilterDocument">inputMessagesFilterDocument</a> filter, rendering the results as specified in the <ahref="#chats-tab">chats tab</a>. </p>
<p>Initially, the tab should be populated with the results returned by passing an empty string in <code>q</code>. </p>
<p>Searching should invoke <ahref="/method/messages.searchGlobal">messages.searchGlobal</a> with the <ahref="/constructor/inputMessagesFilterMusic">inputMessagesFilterMusic</a> filter, rendering the results as specified in the <ahref="#chats-tab">chats tab</a>. </p>
<p>Initially, the tab should be populated with the results returned by passing an empty string in <code>q</code>. </p>
<p>Searching should invoke <ahref="/method/messages.searchGlobal">messages.searchGlobal</a> with the <ahref="/constructor/inputMessagesFilterVoice">inputMessagesFilterVoice</a> filter, rendering the results as specified in the <ahref="#chats-tab">chats tab</a>. </p>
<p>Initially, the tab should be populated with the results returned by passing an empty string in <code>q</code>. </p>
<p>The special <ahref="/method/channels.searchPosts">channels.searchPosts</a> method may be used to globally search for posts from public channels (<em>including</em> those we aren't a member of) and stories from public users, channels and groups (<em>including</em> non-contacts and peers we've never seen before), containing a specific hashtag (which should be passed in the <code>hashtag</code> field without the <code>#</code>). </p>
<p>See <ahref="/api/stories#searching-stories">here»</a> for more info on global search for <em>stories</em> (which should <em>not</em> be triggered when using the global search bar, but rather only when clicking on story hashtags and location tags).</p></div>