📙
gramjs
  • Quick Start
  • Introduction
    • Advanced Installation
  • Concepts
    • Authentication
    • Updates (events)
    • Available methods
      • GetMessages
      • Uploading files
      • Downloading files
      • Getting participants of a group/channel
    • Handling Errors
    • Browser
  • FAQ
  • Raw Methods (Generated)
  • Accepting the Terms of Service
    • help.acceptTermsOfService
    • help.getTermsOfServiceUpdate
  • Dealing with spam and ToS violations
    • account.reportPeer
    • channels.reportSpam
    • messages.report
    • messages.reportEncryptedSpam
    • messages.reportSpam
  • Fetching configuration
    • help.dismissSuggestion
    • help.getAppChangelog
    • help.getAppConfig
    • help.getAppUpdate
    • help.getConfig
    • help.getCountriesList
    • help.getInviteText
    • help.getNearestDc
    • help.getSupport
    • help.getSupportName
  • Login via QR code
    • auth.acceptLoginToken
    • auth.exportLoginToken
    • auth.importLoginToken
  • Miscellaneous
    • help.saveAppLog
    • initConnection
    • invokeAfterMsg
    • invokeAfterMsgs
    • invokeWithLayer
    • invokeWithoutUpdates
  • Registration and Authorization
    • auth.bindTempAuthKey
    • auth.cancelCode
    • auth.checkPassword
    • auth.dropTempAuthKeys
    • auth.exportAuthorization
    • auth.importAuthorization
    • auth.importBotAuthorization
    • auth.logOut
    • auth.recoverPassword
    • auth.requestPasswordRecovery
    • auth.resendCode
    • auth.resetAuthorizations
    • auth.sendCode
    • auth.signIn
    • auth.signUp
  • Working with 2FA login
    • account.cancelPasswordEmail
    • account.confirmPasswordEmail
    • account.getPassword
    • account.getPasswordSettings
    • account.resendPasswordEmail
    • account.updatePasswordSettings
  • Working with bot inline queries and callback buttons
    • messages.editInlineBotMessage
    • messages.getBotCallbackAnswer
    • messages.getInlineBotResults
    • messages.sendInlineBotResult
    • messages.setBotCallbackAnswer
    • messages.setInlineBotResults
  • Working with bots (internal bot API use)
    • bots.answerWebhookJSONQuery
    • bots.sendCustomRequest
    • help.setBotUpdatesStatus
  • Working with bots
    • bots.setBotCommands
  • Working with channels and supergroups and geogroups
    • channels.createChannel
    • channels.deleteChannel
    • channels.deleteHistory
    • channels.deleteMessages
    • channels.deleteUserHistory
    • channels.editAdmin
    • channels.editBanned
    • channels.editCreator
    • channels.editLocation
    • channels.editPhoto
    • channels.editTitle
    • channels.exportMessageLink
    • channels.getAdminedPublicChannels
    • channels.getAdminLog
    • channels.getChannels
    • channels.getFullChannel
    • channels.getGroupsForDiscussion
    • channels.getInactiveChannels
    • channels.getMessages
    • channels.getParticipant
    • channels.getParticipants
    • channels.inviteToChannel
    • channels.joinChannel
    • channels.leaveChannel
    • channels.readHistory
    • channels.readMessageContents
    • channels.setDiscussionGroup
    • channels.setStickers
    • channels.togglePreHistoryHidden
    • channels.toggleSignatures
    • channels.toggleSlowMode
    • messages.getStatsURL
  • Working with chats and supergroups and channels
    • messages.addChatUser
    • messages.checkChatInvite
    • messages.createChat
    • messages.deleteChatUser
    • messages.editChatAbout
    • messages.editChatAdmin
    • messages.editChatDefaultBannedRights
    • messages.editChatPhoto
    • messages.editChatTitle
    • messages.exportChatInvite
    • messages.getAllChats
    • messages.getChats
    • messages.getCommonChats
    • messages.getFullChat
    • messages.importChatInvite
    • messages.migrateChat
  • Working with cloud themes
    • account.createTheme
    • account.getTheme
    • account.getThemes
    • account.installTheme
    • account.saveTheme
    • account.updateTheme
    • account.uploadTheme
  • Working with contacts and top peers
    • account.getContactSignUpNotification
    • account.setContactSignUpNotification
    • contacts.acceptContact
    • contacts.addContact
    • contacts.block
    • contacts.deleteByPhones
    • contacts.deleteContacts
    • contacts.getBlocked
    • contacts.getContactIDs
    • contacts.getContacts
    • contacts.getLocated
    • contacts.getSaved
    • contacts.getStatuses
    • contacts.getTopPeers
    • contacts.importContacts
    • contacts.resetSaved
    • contacts.resetTopPeerRating
    • contacts.search
    • contacts.toggleTopPeers
    • contacts.unblock
  • Working with credit cards
    • payments.getBankCardData
  • Working with deep links
    • help.getDeepLinkInfo
    • help.getRecentMeUrls
    • messages.startBot
  • Working with dialogs
    • messages.getDialogs
    • messages.getDialogUnreadMarks
    • messages.getOnlines
    • messages.getPeerDialogs
    • messages.getPeerSettings
    • messages.getPinnedDialogs
    • messages.hidePeerSettingsBar
    • messages.markDialogUnread
    • messages.reorderPinnedDialogs
    • messages.sendScreenshotNotification
    • messages.setTyping
    • messages.toggleDialogPin
  • Working with drafts
    • messages.clearAllDrafts
    • messages.getAllDrafts
    • messages.saveDraft
  • Working with emoji keywords
    • messages.getEmojiKeywords
    • messages.getEmojiKeywordsDifference
    • messages.getEmojiKeywordsLanguages
    • messages.getEmojiURL
  • Working with files
    • help.getCdnConfig
    • messages.getDocumentByHash
    • messages.uploadEncryptedFile
    • messages.uploadMedia
    • upload.getCdnFile
    • upload.getCdnFileHashes
    • upload.getFile
    • upload.getFileHashes
    • upload.getWebfile
    • upload.reuploadCdnFile
    • upload.saveBigFilePart
    • upload.saveFilePart
  • Working with folders
    • folders.deleteFolder
    • folders.editPeerFolders
    • messages.getDialogFilters
    • messages.getSuggestedDialogFilters
    • messages.updateDialogFilter
    • messages.updateDialogFiltersOrder
  • Working with games
    • messages.getGameHighScores
    • messages.getInlineGameHighScores
    • messages.setGameScore
    • messages.setInlineGameScore
  • Working with GDPR export
    • account.finishTakeoutSession
    • account.initTakeoutSession
    • channels.getLeftChannels
    • invokeWithMessagesRange
    • invokeWithTakeout
    • messages.getSplitRanges
  • Working with GIFs (actually MPEG4 GIFs)
    • messages.getSavedGifs
    • messages.saveGif
    • messages.searchGifs
  • Working with instant view pages
    • messages.getWebPage
    • messages.getWebPagePreview
  • Working with localization packs
    • langpack.getDifference
    • langpack.getLangPack
    • langpack.getLanguage
    • langpack.getLanguages
    • langpack.getStrings
  • Working with media autodownload settings
    • account.getAutoDownloadSettings
    • account.saveAutoDownloadSettings
  • Working with message reactions
    • messages.getMessageReactionsList
    • messages.getMessagesReactions
    • messages.sendReaction
  • Working with message threads
    • contacts.blockFromReplies
    • messages.getDiscussionMessage
    • messages.getReplies
    • messages.readDiscussion
  • Working with messages
    • messages.deleteHistory
    • messages.deleteMessages
    • messages.editMessage
    • messages.forwardMessages
    • messages.getHistory
    • messages.getMessageEditData
    • messages.getMessages
    • messages.getMessagesViews
    • messages.getRecentLocations
    • messages.getSearchCounters
    • messages.getUnreadMentions
    • messages.readHistory
    • messages.readMentions
    • messages.readMessageContents
    • messages.receivedMessages
    • messages.search
    • messages.searchGlobal
    • messages.sendMedia
    • messages.sendMessage
    • messages.sendMultiMedia
    • messages.unpinAllMessages
    • messages.updatePinnedMessage
  • Working with notification settings
    • account.getNotifyExceptions
    • account.getNotifySettings
    • account.registerDevice
    • account.resetNotifySettings
    • account.unregisterDevice
    • account.updateDeviceLocked
    • account.updateNotifySettings
  • Working with other users
    • users.getFullUser
    • users.getUsers
  • Working with payments
    • account.getTmpPassword
    • messages.setBotPrecheckoutResults
    • messages.setBotShippingResults
    • payments.clearSavedInfo
    • payments.getPaymentForm
    • payments.getPaymentReceipt
    • payments.getSavedInfo
    • payments.sendPaymentForm
    • payments.validateRequestedInfo
  • Working with polls
    • messages.getPollResults
    • messages.getPollVotes
    • messages.sendVote
  • Working with Public Service Announcement and MTProxy channels
    • help.getPromoData
    • help.hidePromoData
  • Working with scheduled messages
    • messages.deleteScheduledMessages
    • messages.getScheduledHistory
    • messages.getScheduledMessages
    • messages.sendScheduledMessages
  • Working with Seamless Telegram Login
    • account.getWebAuthorizations
    • account.resetWebAuthorization
    • account.resetWebAuthorizations
    • messages.acceptUrlAuth
    • messages.requestUrlAuth
  • Working with secret chats
    • messages.acceptEncryption
    • messages.discardEncryption
    • messages.getDhConfig
    • messages.readEncryptedHistory
    • messages.receivedQueue
    • messages.requestEncryption
    • messages.sendEncrypted
    • messages.sendEncryptedFile
    • messages.sendEncryptedService
    • messages.setEncryptedTyping
  • Working with sensitive content (NSFW)
    • account.getContentSettings
    • account.setContentSettings
  • Working with sponsored proxies
    • help.getProxyData
  • Working with stickers
    • messages.clearRecentStickers
    • messages.faveSticker
    • messages.getAllStickers
    • messages.getArchivedStickers
    • messages.getAttachedStickers
    • messages.getFavedStickers
    • messages.getFeaturedStickers
    • messages.getMaskStickers
    • messages.getOldFeaturedStickers
    • messages.getRecentStickers
    • messages.getStickers
    • messages.getStickerSet
    • messages.installStickerSet
    • messages.readFeaturedStickers
    • messages.reorderStickerSets
    • messages.saveRecentSticker
    • messages.searchStickerSets
    • messages.toggleStickerSets
    • messages.uninstallStickerSet
    • stickers.addStickerToSet
    • stickers.changeStickerPosition
    • stickers.createStickerSet
    • stickers.removeStickerFromSet
    • stickers.setStickerSetThumb
  • Working with telegram passport
    • account.acceptAuthorization
    • account.deleteSecureValue
    • account.getAllSecureValues
    • account.getAuthorizationForm
    • account.getAuthorizations
    • account.getSecureValue
    • account.saveSecureValue
    • account.sendVerifyEmailCode
    • account.sendVerifyPhoneCode
    • account.verifyEmail
    • account.verifyPhone
    • help.getPassportConfig
    • users.setSecureValueErrors
  • Working with the user's account
    • account.changePhone
    • account.confirmPhone
    • account.deleteAccount
    • account.getAccountTTL
    • account.getGlobalPrivacySettings
    • account.getPrivacy
    • account.resetAuthorization
    • account.sendChangePhoneCode
    • account.sendConfirmPhoneCode
    • account.setAccountTTL
    • account.setGlobalPrivacySettings
    • account.setPrivacy
    • account.updateProfile
    • account.updateStatus
  • Working with TSF (internal use only)
    • help.editUserInfo
    • help.getUserInfo
  • Working with updates
    • updates.getChannelDifference
    • updates.getDifference
    • updates.getState
  • Working with user profile pictures
    • photos.deletePhotos
    • photos.getUserPhotos
    • photos.updateProfilePhoto
    • photos.uploadProfilePhoto
  • Working with usernames
    • account.checkUsername
    • account.updateUsername
    • channels.checkUsername
    • channels.updateUsername
    • contacts.resolveUsername
  • Working with VoIP calls
    • phone.acceptCall
    • phone.confirmCall
    • phone.discardCall
    • phone.getCallConfig
    • phone.receivedCall
    • phone.requestCall
    • phone.saveCallDebug
    • phone.sendSignalingData
    • phone.setCallRating
  • Working with wallpapers
    • account.getMultiWallPapers
    • account.getWallPaper
    • account.getWallPapers
    • account.installWallPaper
    • account.resetWallPapers
    • account.saveWallPaper
    • account.uploadWallPaper
Powered by GitBook
On this page
  • Example
  • TL schema
  • Parameters
  • Result
  • Possible errors
  • Can bots use this methd ?
  • yes
  • Related pages
  • Folders
  • messages.messagesSlice
  • Pagination in the API

Was this helpful?

  1. Working with messages

messages.searchGlobal

Search for messages and peers globally

Example

const {Api, TelegramClient} = require('telegram');
const {StringSession} = require('telegram/sessions');

const session = new StringSession('');
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
    const result = await client.invoke(new Api.messages.searchGlobal({
        folderId: 9421634,
        q: 'random string here',
        filter: new Api.MessagesFilter({...}),
        minDate: 9329785,
        maxDate: 7418948,
        offsetRate: 6917823,
        offsetPeer: new Api.InputPeer({...}),
        offsetId: 9896393,
        limit: 6987313,
        }));
    console.log(result); // prints the result
})();
import {Api, TelegramClient} from 'telegram';
import {StringSession} from 'telegram/sessions';

const session = new StringSession('');
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
    const result: Api.messages.Messages = await client.invoke(new Api.messages.searchGlobal({
        folderId: 9421634,
        q: 'random string here',
        filter: new Api.MessagesFilter({...}),
        minDate: 9329785,
        maxDate: 7418948,
        offsetRate: 6917823,
        offsetPeer: new Api.InputPeer({...}),
        offsetId: 9896393,
        limit: 6987313,
        }));
    console.log(result); // prints the result
})();

TL schema

messages.messages#8c718e87 messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messagesSlice#3a54685e flags:# inexact:flags.1?true count:int next_rate:flags.0?int offset_id_offset:flags.2?int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.channelMessages#64479808 flags:# inexact:flags.1?true pts:int count:int offset_id_offset:flags.2?int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messagesNotModified#74535f21 count:int = messages.Messages;
---functions---
messages.searchGlobal#4bc6589a flags:# folder_id:flags.0?int q:string filter:MessagesFilter min_date:int max_date:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;

Parameters

Name

Type

Description

flags

folder_id

q

Query

filter

Global search filter

min_date

If a positive value was specified, the method will return only messages with date bigger than min_date

max_date

If a positive value was transferred, the method will return only messages with date smaller than max_date

offset_rate

offset_peer

offset_id

limit

Result

Possible errors

Code

Type

Description

400

FOLDER_ID_INVALID

Invalid folder ID

400

SEARCH_QUERY_EMPTY

The search query is empty

Can bots use this methd ?

yes

Related pages

Telegram allows placing chats into folders, based on their type, mute status, or other custom criteria, thanks to folder blacklists and whitelists.

Incomplete list of messages and auxiliary data.

How to fetch results from large lists of objects.

Previousmessages.searchNextmessages.sendMedia

Last updated 4 years ago

Was this helpful?

Flags, see

.0?

Initially 0, then set to the

messages.Messages
Folders
messages.messagesSlice
Pagination in the API
#
TL conditional fields
flags
int
Peer folder ID, for more info click here
string
MessagesFilter
int
int
int
next_rate parameter of messages.messagesSlice
InputPeer
Offsets for pagination, for more info click here
int
Offsets for pagination, for more info click here
int
Offsets for pagination, for more info click here