📙
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
  • Pagination in the API

Was this helpful?

  1. Working with contacts and top peers

contacts.getTopPeers

Get most used peers

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.contacts.getTopPeers({
        correspondents: true,
        botsPm: true,
        botsInline: true,
        phoneCalls: true,
        forwardUsers: true,
        forwardChats: true,
        groups: true,
        channels: true,
        offset: 5972771,
        limit: 6658168,
        hash: 1575713,
        }));
    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.contacts.TopPeers = await client.invoke(new Api.contacts.getTopPeers({
        correspondents: true,
        botsPm: true,
        botsInline: true,
        phoneCalls: true,
        forwardUsers: true,
        forwardChats: true,
        groups: true,
        channels: true,
        offset: 5972771,
        limit: 6658168,
        hash: 1575713,
        }));
    console.log(result); // prints the result
})();

TL schema

contacts.topPeersNotModified#de266ef5 = contacts.TopPeers;
contacts.topPeers#70b772a8 categories:Vector<TopPeerCategoryPeers> chats:Vector<Chat> users:Vector<User> = contacts.TopPeers;
contacts.topPeersDisabled#b52c939d = contacts.TopPeers;
---functions---
contacts.getTopPeers#d4982db5 flags:# correspondents:flags.0?true bots_pm:flags.1?true bots_inline:flags.2?true phone_calls:flags.3?true forward_users:flags.4?true forward_chats:flags.5?true groups:flags.10?true channels:flags.15?true offset:int limit:int hash:int = contacts.TopPeers;

Parameters

Name

Type

Description

flags

correspondents

Users we've chatted most frequently with

bots_pm

Most used bots

bots_inline

Most used inline bots

phone_calls

Most frequently called users

forward_users

Users to which the users often forwards messages to

forward_chats

Chats to which the users often forwards messages to

groups

Often-opened groups and supergroups

channels

Most frequently visited channels

offset

limit

hash

Result

Possible errors

Code

Type

Description

400

TYPES_EMPTY

No top peer type was provided

Can bots use this methd ?

yes

Related pages

How to fetch results from large lists of objects.

Previouscontacts.getStatusesNextcontacts.importContacts

Last updated 4 years ago

Was this helpful?

Flags, see

.0?

.1?

.2?

.3?

.4?

.5?

.10?

.15?

Offset for

Maximum number of results to return,

contacts.TopPeers
Pagination in the API
#
TL conditional fields
flags
true
flags
true
flags
true
flags
true
flags
true
flags
true
flags
true
flags
true
int
pagination
int
see pagination
int
Hash for pagination, for more info click here