Telegram client for use in Node.js

Hierarchy (View Summary)

Constructors

Properties

Methods

_normalizeInputFile _normalizeInputMedia _normalizePrivacyRules acceptStarGift addChatMembers addContact addStickerToSet answerCallbackQuery answerInlineQuery answerMedia answerMediaGroup answerPreCheckoutQuery answerText applyBoost archiveChats banChatMember blockUser call canApplyBoost cancelPasswordEmail canSendStory changeCloudPassword changePrimaryDc checkPassword close closeChat closePoll closeWebview commentMedia commentMediaGroup commentText computeNewPasswordHash computeSrpParams connect createBusinessChatLink createChannel createFolder createForumTopic createGroup createInviteLink createStickerSet createSupergroup deleteBusinessChatLink deleteChannel deleteChatPhoto deleteContacts deleteFolder deleteForumTopicHistory deleteGroup deleteHistory deleteMessages deleteMessagesById deleteMyCommands deleteProfilePhotos deleteScheduledMessages deleteStickerFromSet deleteStories deleteSupergroup deleteUserHistory downloadAsBuffer downloadAsIterable downloadAsNodeStream downloadAsStream downloadToFile editAdminRights editBusinessChatLink editCloseFriends editCloseFriendsRaw editFolder editForumTopic editInlineMessage editInviteLink editMessage editStory enableCloudPassword exportInviteLink exportSession findDialogs findFolder forwardMessages forwardMessagesById getAllScheduledMessages getAllStories getApiCredentials getAvailableMessageEffects getBoosts getBoostStats getBotInfo getBotMenuButton getBusinessChatLinks getBusinessConnection getCallbackAnswer getCallbackQueryMessage getChat getChatEventLog getChatlistPreview getChatMember getChatMembers getChatPreview getCollectibleInfo getCommonChats getContacts getCustomEmojis getCustomEmojisFromMessages getDiscussionMessage getFactCheck getFolders getForumTopics getForumTopicsById getFullChat getFullUser getGameHighScores getGlobalTtl getHistory getInlineGameHighScores getInstalledStickers getInviteLink getInviteLinkMembers getInviteLinks getMe getMessageByLink getMessageGroup getMessageReactions getMessageReactionsById getMessages getMessagesUnsafe getMtprotoMessageId getMyBoostSlots getMyCommands getMyStickerSets getMyUsername getNearbyChats getPasswordHint getPeerDialogs getPeerStories getPoolSize getPrimaryDcId getPrimaryInviteLink getProfilePhoto getProfilePhotos getProfileStories getReactionUsers getReplyTo getScheduledMessages getSimilarChannels getStarGiftOptions getStarGifts getStarsTransactions getStickerSet getStoriesById getStoriesInteractions getStoryLink getStoryViewers getUser getUsers handleClientUpdate hideAllJoinRequests hideJoinRequest hideMyStoriesViews importContacts importSession incrementStoriesViews initTakeoutSession isPeerAvailable isSelfPeer iterAllStories iterBoosters iterChatEventLog iterChatMembers iterDialogs iterForumTopics iterHistory iterInviteLinkMembers iterInviteLinks iterProfilePhotos iterProfileStories iterReactionUsers iterSearchGlobal iterSearchHashtag iterSearchMessages iterStarGifts iterStarsTransactions iterStoryViewers joinChat joinChatlist kickChatMember leaveChat logOut markChatUnread moveStickerInSet notifyChannelClosed notifyChannelOpened notifyLoggedIn notifyLoggedOut openChat openWebview pinMessage prepare prepareInlineMessage quoteWithMedia quoteWithMediaGroup quoteWithText readHistory readReactions readStories recoverPassword recreateDc removeCloudPassword reorderPinnedForumTopics reorderUsernames replaceStickerInSet replyMedia replyMediaGroup replyText resendCode resendPasswordEmail resolveChannel resolvePeer resolvePeerMany resolveUser restrictChatMember revokeInviteLink run saveDraft searchGlobal searchHashtag searchMessages sendCode sendCopy sendCopyGroup sendMedia sendMediaGroup sendOnline sendPaidReaction sendReaction sendRecoveryCode sendScheduled sendStarGift sendStory sendStoryReaction sendText sendTyping sendVote setBotInfo setBotMenuButton setBusinessIntro setBusinessWorkHours setChatColor setChatDefaultPermissions setChatDescription setChatPhoto setChatStickerSet setChatTitle setChatTtl setChatUsername setEmojiStatus setFoldersOrder setGameScore setGlobalTtl setInlineGameScore setMyBirthday setMyCommands setMyDefaultRights setMyEmojiStatus setMyProfilePhoto setMyUsername setOnline setSlowMode setStickerSetThumb setTyping signIn signInBot signInQr start startTest startUpdatesLoop stopUpdatesLoop toggleContentProtection toggleEmojiStatusPermission toggleForum toggleForumTopicClosed toggleForumTopicPinned toggleFragmentUsername toggleGeneralTopicHidden toggleJoinRequests toggleJoinToSend togglePeerStoriesArchived toggleStoriesPinned transferStarGift translateMessage translateText unarchiveChats unbanChatMember unblockUser unpinAllMessages unpinMessage unrestrictChatMember updateProfile upgradeStarGift uploadFile uploadMedia verifyPasswordEmail withParams

Constructors

Properties

appConfig: PublicPart<AppConfigManager>
log: Logger
onBotChatJoinRequest: Emitter<BotChatJoinRequestUpdate>

a bot chat join request handler

onBotReactionCountUpdate: Emitter<BotReactionCountUpdate>

a bot reaction count update handler

onBotReactionUpdate: Emitter<BotReactionUpdate>

a bot reaction update handler

onBotStopped: Emitter<BotStoppedUpdate>

a bot stopped handler

onBusinessCallbackQuery: Emitter<BusinessCallbackQuery>

a business callback query handler

onBusinessConnectionUpdate: Emitter<BusinessConnection>

a business connection update handler

onBusinessMessageGroup: Emitter<BusinessMessage[]>

a business message group handler

onCallbackQuery: Emitter<CallbackQuery>

a callback query handler

onChatJoinRequest: Emitter<ChatJoinRequestUpdate>

a chat join request handler

onChatMemberUpdate: Emitter<ChatMemberUpdate>

a chat member update handler

onChosenInlineResult: Emitter<ChosenInlineResult>

a chosen inline result handler

onConnectionState: Emitter<ConnectionState>
onDeleteBusinessMessage: Emitter<DeleteBusinessMessageUpdate>

a delete business message handler

onDeleteMessage: Emitter<DeleteMessageUpdate>

a delete message handler

onDeleteStory: Emitter<DeleteStoryUpdate>

a delete story handler

onEditBusinessMessage: Emitter<BusinessMessage>

an edit business message handler

onEditMessage: Emitter<Message>

an edit message handler

onError: Emitter<Error>
onHistoryRead: Emitter<HistoryReadUpdate>

a history read handler

onInlineCallbackQuery: Emitter<InlineCallbackQuery>

an inline callback query handler

onInlineQuery: Emitter<InlineQuery>

an inline query handler

onMessageGroup: Emitter<Message[]>

a message group handler

onNewBusinessMessage: Emitter<BusinessMessage>

a new business message handler

onNewMessage: Emitter<Message>
onPollUpdate: Emitter<PollUpdate>

a poll update handler

onPollVote: Emitter<PollVoteUpdate>

a poll vote handler

onPreCheckoutQuery: Emitter<PreCheckoutQuery>

a pre checkout query handler

onRawUpdate: Emitter<RawUpdateInfo>

Raw update emitter

onServerUpdate: Emitter<TypeUpdates>
onStoryUpdate: Emitter<StoryUpdate>

a story update handler

onUpdate: Emitter<ParsedUpdate>

Parsed update emitter

onUserStatusUpdate: Emitter<UserStatusUpdate>

an user status update handler

onUserTyping: Emitter<UserTypingUpdate>

an user typing handler

platform: ICorePlatform
stopSignal: AbortSignal
timers: Pick<TimersManager, "cancel" | "create" | "exists">

Methods

  • Normalize a InputFileLike to InputFile, uploading it if needed. Available: ✅ both users and bots

    Parameters

    • input: InputFileLike
    • params: {
          fileMime?: string;
          fileName?: string;
          fileSize?: number;
          progressCallback?: (uploaded: number, total: number) => void;
      }

    Returns Promise<TypeInputFile>

  • Normalize an InputMediaLike to InputMedia, uploading the file if needed. Available: ✅ both users and bots

    Parameters

    • media: InputMediaLike
    • Optionalparams: {
          businessConnectionId?: string;
          progressCallback?: (uploaded: number, total: number) => void;
          uploadPeer?: TypeInputPeer;
      }
    • OptionaluploadMedia: boolean

    Returns Promise<TypeInputMedia>

  • Accept, hide or convert a star gift.

    Available: 👤 users only

    Parameters

    • params: InputMessageId & { action: "save" | "hide" | "convert" }
      • action: "save" | "hide" | "convert"

        Action to perform on the gift.

        • save - save the gift to your profile
        • hide - hide the gift from your profile
        • convert - convert the gift to stars (can't be undone)

    Returns Promise<boolean>

    Whether the action was successful

  • Add one or more new members to a group, supergroup or channel.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      ID of the chat or its username

    • users: MaybeArray<InputPeerLike>

      ID(s) of the user(s) to add

    • params: { forwardCount?: number }
      • OptionalforwardCount?: number

        Number of old messages to be forwarded (0-100). Only applicable to legacy groups, ignored for supergroups and channels

        100
        

    Returns Promise<RawMissingInvitee[]>

    List of users that were failed to be invited (may be empty)

  • Add an existing Telegram user as a contact Available: 👤 users only

    Parameters

    • params: {
          firstName: string;
          lastName?: string;
          phone?: string;
          sharePhone?: boolean;
          userId: InputPeerLike;
      }
      • firstName: string

        First name of the contact

      • OptionallastName?: string

        Last name of the contact

      • Optionalphone?: string

        Phone number of the contact, if available

      • OptionalsharePhone?: boolean

        Whether to share your own phone number with the newly created contact

        false
        
      • userId: InputPeerLike

        User ID, username or phone number

    Returns Promise<User>

  • Add a sticker to a sticker set.

    For bots the sticker set must have been created by this bot.

    Available: ✅ both users and bots

    Parameters

    • setId: InputStickerSet

      Sticker set short name or TL object with input sticker set

    • sticker: InputStickerSetItem

      Sticker to be added

    • Optionalparams: { progressCallback?: (uploaded: number, total: number) => void }
      • OptionalprogressCallback?: (uploaded: number, total: number) => void

        Upload progress callback

    Returns Promise<StickerSet>

    Modfiied sticker set

  • Send an answer to a callback query.

    Available: 🤖 bots only

    Parameters

    • queryId: Long | CallbackQuery

      ID of the callback query, or the query itself

    • Optionalparams: { alert?: boolean; cacheTime?: number; text?: string; url?: string }

      Parameters of the answer

      • Optionalalert?: boolean

        Whether to show an alert in the middle of the screen instead of a notification at the top of the screen.

        false
        
      • OptionalcacheTime?: number

        Maximum amount of time in seconds for which this result can be cached by the client (not server!).

        0
        
      • Optionaltext?: string

        Text of the notification (0-200 chars).

        If not set, nothing will be displayed

      • Optionalurl?: string

        URL that the client should open.

        If this was a button containing a game, you can provide arbitrary link to your game. Otherwise, you can only use links in the format t.me/your_bot?start=... that open your bot with a deep-link parameter.

    Returns Promise<void>

  • Answer an inline query.

    Available: 🤖 bots only

    Parameters

    • queryId: Long | InlineQuery

      Inline query ID

    • results: InputInlineResult[]

      Results of the query

    • Optionalparams: {
          cacheTime?: number;
          gallery?: boolean;
          nextOffset?: string;
          private?: boolean;
          switchPm?: { parameter: string; text: string };
          switchWebview?: { text: string; url: string };
      }

      Additional parameters

      • OptionalcacheTime?: number

        Maximum number of time in seconds that the results of the query may be cached on the server for.

        300
        
      • Optionalgallery?: boolean

        Whether the results should be displayed as a gallery instead of a vertical list. Only applicable to some media types.

        In some cases changing this may lead to the results not being displayed by the client.

        Default is derived automatically based on result types

      • OptionalnextOffset?: string

        Next pagination offset (up to 64 bytes).

        When user has reached the end of the current results, the client will re-send the inline query with the same text, but with offset set to this value.

        If omitted or empty string is provided, it is assumed that there are no more results.

      • Optionalprivate?: boolean

        Whether the results should only be cached on the server for the user who sent the query.

        false
        
      • OptionalswitchPm?: { parameter: string; text: string }

        If passed, clients will display a button before any other results, that when clicked switches the user to a private chat with the bot and sends the bot /start ${parameter}.

        An example from the Bot API docs:

        An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a "Connect your YouTube account" button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an oauth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities

        • parameter: string

          Parameter for /start command

        • text: string

          Text of the button

      • OptionalswitchWebview?: { text: string; url: string }

        If passed, clients will display a button on top of the remaining inline result list with the specified text, that switches the user to the specified bot web app.

        • text: string

          Text of the button

        • url: string

          URL to open

    Returns Promise<void>

  • Send a media to the same chat (and topic, if applicable) as a given message

    Parameters

    • message: Message
    • ...params: [
          media: string
          | InputMediaLike,
          params?: CommonSendParams & {
              caption?: InputText;
              invert?: boolean;
              progressCallback?: (uploaded: number, total: number) => void;
              replyMarkup?: ReplyMarkup;
          },
      ]

    Returns Promise<Message>

  • Send a media group to the same chat (and topic, if applicable) as a given message

    Parameters

    • message: Message
    • ...params: [
          medias: (string | InputMediaLike)[],
          params?: CommonSendParams & {
              invertMedia?: boolean;
              progressCallback?: (
                  index: number,
                  uploaded: number,
                  total: number,
              ) => void;
          },
      ]

    Returns Promise<Message[]>

  • Answer a pre-checkout query.

    Available: 🤖 bots only

    Parameters

    • queryId: Long | PreCheckoutQuery

      Pre-checkout query ID

    • Optionalparams: { error?: string }
      • Optionalerror?: string

        If pre-checkout is rejected, error message to show to the user

    Returns Promise<void>

  • Send a text to the same chat (and topic, if applicable) as a given message

    Parameters

    • message: Message
    • ...params: [
          text: InputText,
          params?: CommonSendParams & {
              disableWebPreview?: boolean;
              invertMedia?: boolean;
              replyMarkup?: ReplyMarkup;
          },
      ]

    Returns Promise<Message>

  • Boost a given channel

    Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Ban a user/channel from a legacy group, a supergroup or a channel. They will not be able to re-join the group on their own, manual administrator's action will be required.

    When banning a channel, the user won't be able to use any of their channels to post until the ban is lifted.

    Available: ✅ both users and bots

    Parameters

    • params: {
          chatId: InputPeerLike;
          participantId: InputPeerLike;
          shouldDispatch?: true;
          untilDate?: number | Date;
      }
      • chatId: InputPeerLike

        Chat ID

      • participantId: InputPeerLike

        ID of the user/channel to ban

      • OptionalshouldDispatch?: true

        Whether to dispatch the returned service message (if any) to the client's update handler.

      • OptionaluntilDate?: number | Date

    Returns Promise<null | Message>

    Service message about removed user, if one was generated.

  • Block a user

    Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Type Parameters

    • T extends RpcMethod

    Parameters

    Returns Promise<RpcCallReturn[T["_"]]>

  • Check if the current user can apply boost to some channel

    Available: ✅ both users and bots

    Returns Promise<CanApplyBoostResult>

    • { can: true } if the user can apply boost
      • .replace - Chats that can be replaced with the current one. If the user can apply boost without replacing any chats, this field will be undefined.
      • { can: false } if the user can't apply boost
        • .reason == "no_slots" if the user has no available slots
        • .reason == "need_premium" if the user needs Premium to boost
      • In all cases, slots will contain all the current user's boost slots
  • Cancel the code that was sent to verify an email to use as 2FA recovery method Available: 👤 users only

    Returns Promise<void>

  • Check if the current user can post stories as a given peer

    Available: 👤 users only

    Parameters

    Returns Promise<CanSendStoryResult>

    • true if the user can post stories
      • "need_admin" if the user is not an admin in the chat
      • "need_boosts" if the channel doesn't have enough boosts
  • Change your 2FA password Available: 👤 users only

    Parameters

    • params: { currentPassword: string; hint?: string; newPassword: string }
      • currentPassword: string

        Current password as plaintext

      • Optionalhint?: string

        Hint for the new password

      • newPassword: string

        New password as plaintext

    Returns Promise<void>

  • Parameters

    • newDc: number

    Returns Promise<void>

  • Check your Two-Step verification password and log in

    Available: 👤 users only

    Parameters

    • password: string

      Your Two-Step verification password

    Returns Promise<User>

    The authorized user

    BadRequestError In case the password is invalid

  • Returns Promise<void>

  • Inform the library that the user has closed a chat. Un-does the effect of openChat.

    Some library logic depends on this, for example, the library will periodically ping the server to keep the updates flowing.

    Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Close a poll sent by you.

    Once closed, poll can't be re-opened, and nobody will be able to vote in it Available: ✅ both users and bots

    Parameters

    • params: InputMessageId & { shouldDispatch?: true }
      • OptionalshouldDispatch?: true

        Whether to dispatch the edit message event to the client's update handler.

    Returns Promise<Poll>

  • Send a text comment to a given message.

    If this is a normal message (not a channel post), a simple reply will be sent.

    Available: ✅ both users and bots

    Parameters

    • message: Message
    • ...params: [
          media: string
          | InputMediaLike,
          params?: CommonSendParams & {
              caption?: InputText;
              invert?: boolean;
              progressCallback?: (uploaded: number, total: number) => void;
              replyMarkup?: ReplyMarkup;
          },
      ]

    Returns Promise<Message>

    MtArgumentError If this is a channel post which does not have comments section. To check if a post has comments, use Message#replies.hasComments

  • Send a text comment to a given message.

    If this is a normal message (not a channel post), a simple reply will be sent.

    Available: ✅ both users and bots

    Parameters

    • message: Message
    • ...params: [
          medias: (string | InputMediaLike)[],
          params?: CommonSendParams & {
              invertMedia?: boolean;
              progressCallback?: (
                  index: number,
                  uploaded: number,
                  total: number,
              ) => void;
          },
      ]

    Returns Promise<Message[]>

    MtArgumentError If this is a channel post which does not have comments section. To check if a post has comments, use Message#replies.hasComments

  • Send a text comment to a given message.

    If this is a normal message (not a channel post), a simple reply will be sent.

    Available: ✅ both users and bots

    Parameters

    • message: Message
    • ...params: [
          text: InputText,
          params?: CommonSendParams & {
              disableWebPreview?: boolean;
              invertMedia?: boolean;
              replyMarkup?: ReplyMarkup;
          },
      ]

    Returns Promise<Message>

    MtArgumentError If this is a channel post which does not have comments section. To check if a post has comments, use Message#replies.hasComments

  • Returns Promise<void>

  • Create a new business chat link

    Available: 👤 users only

    Parameters

    • text: InputText

      Text to be inserted into the message input

    • Optionalparams: { title?: string }
      • Optionaltitle?: string

        Custom title for the link

    Returns Promise<BusinessChatLink>

  • Create a new broadcast channel

    Available: 👤 users only

    Parameters

    • params: { description?: string; title: string }
      • Optionaldescription?: string

        Channel description

      • title: string

        Channel title

    Returns Promise<Chat>

    Newly created channel

  • Create a topic in a forum

    Only admins with manageTopics permission can do this.

    Available: ✅ both users and bots

    Parameters

    • params: {
          chatId: InputPeerLike;
          icon?: number | Long;
          sendAs?: InputPeerLike;
          shouldDispatch?: true;
          title: string;
      }
      • chatId: InputPeerLike

        Chat ID or username

      • Optionalicon?: number | Long

        Icon of the topic.

        Can be a number (color in RGB, see ForumTopic static members for allowed values) or a custom emoji ID.

        Icon color can't be changed after the topic is created.

      • OptionalsendAs?: InputPeerLike

        Send as a specific channel

      • OptionalshouldDispatch?: true

        Whether to dispatch the returned service message (if any) to the client's update handler.

      • title: string

        Topic title

    Returns Promise<Message>

    Service message for the created topic

  • Create a legacy group chat

    If you want to create a supergroup, use createSupergroup instead. Available: 👤 users only

    Parameters

    • params: { title: string; ttlPeriod?: number; users: MaybeArray<InputPeerLike> }
      • title: string

        Group title

      • OptionalttlPeriod?: number

        TTL period (in seconds) for the newly created chat

        0 (i.e. messages don't expire)
        
      • users: MaybeArray<InputPeerLike>

        User(s) to be invited in the group (ID(s), username(s) or phone number(s)). Due to Telegram limitations, you can't create a legacy group with just yourself.

    Returns Promise<CreateGroupResult>

  • Create an additional invite link for the chat.

    You must be an administrator and have appropriate rights.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • Optionalparams: {
          expires?: number | Date;
          subscriptionPricing?: RawStarsSubscriptionPricing;
          usageLimit?: number;
          withApproval?: boolean;
      }
      • Optionalexpires?: number | Date

        Date when this link will expire. If number is passed, UNIX time in ms is expected.

      • OptionalsubscriptionPricing?: RawStarsSubscriptionPricing

        When a pricing plan is passed, this link will become a paid subscription link

        Currently the only allowed .period is 1 month, i.e. 2592000

      • OptionalusageLimit?: number

        Maximum number of users that can be members of this chat at the same time after joining using this link.

        Integer in range [1, 99999] or Infinity

        Infinity

      • OptionalwithApproval?: boolean

        Whether users to be joined via this link need to be approved by an admin

    Returns Promise<ChatInviteLink>

  • Create a new sticker set.

    Available: ✅ both users and bots

    Parameters

    • params: {
          adaptive?: boolean;
          owner: InputPeerLike;
          progressCallback?: (idx: number, uploaded: number, total: number) => void;
          shortName: string;
          stickers: InputStickerSetItem[];
          thumb?: InputFileLike;
          title: string;
          type?: StickerType;
      }
      • Optionaladaptive?: boolean

        Whether to create "adaptive" emoji set.

        Color of the emoji will be changed depending on the text color. Only works for TGS-based emoji stickers

      • owner: InputPeerLike

        Owner of the sticker set (must be user).

        If this pack is created from a user account, can only be "self"

      • OptionalprogressCallback?: (idx: number, uploaded: number, total: number) => void

        Upload progress callback.

      • shortName: string

        Short name of the sticker set. Can only contain English letters, digits and underscores (i.e. must match /^[a-zA-Z0-9_]+$/), and (for bots) must end with by (` is case-insensitive).

      • stickers: InputStickerSetItem[]

        List of stickers to be immediately added into the pack. There must be at least one sticker in this list.

      • Optionalthumb?: InputFileLike

        Thumbnail for the set.

        The file must be either a .png file up to 128kb, having size of exactly 100x100 px, or a .tgs file up to 32kb.

        If not set, Telegram will use the first sticker in the sticker set as the thumbnail

      • title: string

        Title of the sticker set (1-64 chars)

      • Optionaltype?: StickerType

        Type of the stickers in this set.

        sticker, i.e. regular stickers.

    Returns Promise<StickerSet>

    Newly created sticker set

  • Create a new supergroup

    Available: 👤 users only

    Parameters

    • params: { description?: string; forum?: boolean; title: string; ttlPeriod?: number }
      • Optionaldescription?: string

        Supergroup description

      • Optionalforum?: boolean

        Whether to create a forum

      • title: string

        Supergroup title

      • OptionalttlPeriod?: number

        TTL period (in seconds) for the newly created supergroup

        0 (i.e. messages don't expire)
        

    Returns Promise<Chat>

    Newly created supergroup

  • Delete a channel or a supergroup

    Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Delete a chat photo

    You must be an administrator and have the appropriate permissions.

    Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Delete one or more contacts from your Telegram contacts list

    Returns deleted contact's profiles. Does not return profiles of users that were not in your contacts list

    Available: 👤 users only

    Parameters

    Returns Promise<User[]>

  • Delete a folder by its ID

    Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Delete a forum topic and all its history

    Available: ✅ both users and bots

    Parameters

    • chat: InputPeerLike

      Chat or user ID, username, phone number, "me" or "self"

    • topicId: number | ForumTopic

      ID of the topic (i.e. its top message ID)

    • Optionalparams: { shouldDispatch?: true }
      • OptionalshouldDispatch?: true

        Whether to dispatch updates that will be generated by this call. Doesn't follow disableNoDispatch

    Returns Promise<void>

  • Delete a legacy group chat for all members

    Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Delete communication history (for private chats and legacy groups) Available: 👤 users only

    Parameters

    • chat: InputPeerLike
    • Optionalparams: { maxId?: number; mode: "delete" | "revoke" | "clear" }
      • OptionalmaxId?: number

        Maximum ID of message to delete.

        0, i.e. remove all messages
        
      • mode: "delete" | "revoke" | "clear"

        Deletion mode. Can be:

        • delete: delete messages (only for yourself) AND the dialog itself
        • clear: delete messages (only for yourself), but keep the dialog in the list
        • revoke: delete messages for all users
        'delete'
        

    Returns Promise<void>

  • Delete messages by their IDs

    Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Delete scheduled messages by their IDs.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat's marked ID, its username, phone or "me" or "self".

    • ids: number[]

      Message(s) ID(s) to delete.

    Returns Promise<void>

  • Delete a story

    Available: 👤 users only

    Parameters

    Returns Promise<number[]>

    IDs of stories that were removed

  • Delete a channel or a supergroup

    Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Delete all messages of a user (or channel) in a supergroup Available: 👤 users only

    Parameters

    • params: { chatId: InputPeerLike; participantId: InputPeerLike; shouldDispatch?: true }
      • chatId: InputPeerLike

        Chat ID

      • participantId: InputPeerLike

        User/channel ID whose messages to delete

      • OptionalshouldDispatch?: true

        Whether to dispatch the updates that will be generated by this call. Doesn't follow disableNoDispatch

    Returns Promise<void>

  • Download a remote file to a local file (only for Node.js). Promise will resolve once the download is complete.

    Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Edit supergroup/channel admin rights of a user. Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Edit "close friends" list using InputPeerLikes

    Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Edit "close friends" list directly using user IDs

    Available: 👤 users only

    Parameters

    • ids: number[]

      User IDs

    Returns Promise<void>

  • Edit a folder with given modification

    Available: 👤 users only

    Parameters

    • params: {
          folder: string | number | RawDialogFilter;
          modification: Partial<Omit<RawDialogFilter, "_" | "id">>;
      }
      • folder: string | number | RawDialogFilter

        Folder, folder ID or name. Note that passing an ID or name will require re-fetching all folders, and passing name might affect not the right folder if you have multiple with the same name.

      • modification: Partial<Omit<RawDialogFilter, "_" | "id">>

        Modification to be applied to this folder

    Returns Promise<RawDialogFilter>

    Modified folder

  • Modify a topic in a forum

    Only admins with manageTopics permission can do this.

    Available: ✅ both users and bots

    Parameters

    • params: {
          chatId: InputPeerLike;
          icon?: null | Long;
          shouldDispatch?: true;
          title?: string;
          topicId: number | ForumTopic;
      }
      • chatId: InputPeerLike

        Chat ID or username

      • Optionalicon?: null | Long

        New icon of the topic.

        Can be a custom emoji ID, or null to remove the icon and use static color instead

      • OptionalshouldDispatch?: true

        Whether to dispatch the returned service message (if any) to the client's update handler.

      • Optionaltitle?: string

        New topic title

      • topicId: number | ForumTopic

        ID of the topic (i.e. its top message ID)

    Returns Promise<Message>

    Service message about the modification

  • Edit sent inline message text, media and reply markup.

    Available: ✅ both users and bots

    Parameters

    • params: {
          disableWebPreview?: boolean;
          invertMedia?: boolean;
          media?: InputMediaLike;
          messageId: string | TypeInputBotInlineMessageID;
          progressCallback?: (uploaded: number, total: number) => void;
          replyMarkup?: ReplyMarkup;
          text?: InputText;
      }
      • OptionaldisableWebPreview?: boolean

        Whether to disable links preview in this message

      • OptionalinvertMedia?: boolean

        Whether to invert media position.

        Currently only supported for web previews and makes the client render the preview above the caption and not below.

      • Optionalmedia?: InputMediaLike

        New message media

      • messageId: string | TypeInputBotInlineMessageID

        Inline message ID, either as a TL object, or as a TDLib and Bot API compatible string

      • OptionalprogressCallback?: (uploaded: number, total: number) => void

        For media, upload progress callback.

      • OptionalreplyMarkup?: ReplyMarkup

        For bots: new reply markup. If omitted, existing markup will be removed.

      • Optionaltext?: InputText

        New message text

        When media is passed, media.caption is used instead

    Returns Promise<void>

  • Edit an invite link. You can only edit non-primary invite links.

    Only pass the fields that you want to modify.

    Available: ✅ both users and bots

    Parameters

    • params: {
          chatId: InputPeerLike;
          expires?: number | Date;
          link: string | ChatInviteLink;
          usageLimit?: number;
          withApproval?: boolean;
      }
      • chatId: InputPeerLike

        Chat ID

      • Optionalexpires?: number | Date

        Date when this link will expire. If number is passed, UNIX time in ms is expected.

      • link: string | ChatInviteLink

        Invite link to edit

      • OptionalusageLimit?: number

        Maximum number of users that can be members of this chat at the same time after joining using this link.

        Integer in range [1, 99999] or Infinity,

      • OptionalwithApproval?: boolean

        Whether users to be joined via this link need to be approved by an admin

    Returns Promise<ChatInviteLink>

    Modified invite link

  • Edit message text, media, reply markup and schedule date.

    Available: ✅ both users and bots

    Parameters

    • params: InputMessageId & {
          businessConnectionId?: string;
          disableWebPreview?: boolean;
          invertMedia?: boolean;
          media?: InputMediaLike | undefined;
          progressCallback?: (uploaded: number, total: number) => void;
          replyMarkup?: ReplyMarkup | undefined;
          scheduleDate?: number | Date;
          shouldDispatch?: true;
          text?: InputText | undefined;
      }
      • OptionalbusinessConnectionId?: string
      • OptionaldisableWebPreview?: boolean

        Whether to disable links preview in this message

      • OptionalinvertMedia?: boolean

        Whether to invert media position.

        Currently only supported for web previews and makes the client render the preview above the caption and not below.

      • Optionalmedia?: InputMediaLike | undefined

        New message media

      • OptionalprogressCallback?: (uploaded: number, total: number) => void

        For media, upload progress callback.

      • OptionalreplyMarkup?: ReplyMarkup | undefined

        For bots: new reply markup. If omitted, existing markup will be removed.

      • OptionalscheduleDate?: number | Date

        To re-schedule a message: new schedule date. When passing a number, a UNIX time in ms is expected.

      • OptionalshouldDispatch?: true

        Whether to dispatch the edit message event to the client's update handler.

      • Optionaltext?: InputText | undefined

        New message text

        When media is passed, media.caption is used instead

    Returns Promise<Message>

  • Edit a sent story

    Available: 👤 users only

    Parameters

    • params: {
          caption?: InputText;
          id: number;
          interactiveElements?: TypeMediaArea[];
          media?: InputMediaLike;
          peer?: InputPeerLike;
          privacyRules?: InputPrivacyRule[];
      }
      • Optionalcaption?: InputText

        Override caption for media

      • id: number

        Story ID to edit

      • OptionalinteractiveElements?: TypeMediaArea[]

        Interactive elements to add to the story

      • Optionalmedia?: InputMediaLike

        Media contained in a story. Currently can only be a photo or a video.

      • Optionalpeer?: InputPeerLike

        Peer ID to whose story to edit

        self

      • OptionalprivacyRules?: InputPrivacyRule[]

        Privacy rules to apply to the story

        "Everyone"
        

    Returns Promise<Story>

    Edited story

  • Enable 2FA password on your account

    Note that if you pass email, EmailUnconfirmedError may be thrown, and you should use verifyPasswordEmail, resendPasswordEmail or cancelPasswordEmail, and the call this method again Available: 👤 users only

    Parameters

    • params: { email?: string; hint?: string; password: string }
      • Optionalemail?: string

        Recovery email

      • Optionalhint?: string

        Hint for the new password

      • password: string

        2FA password as plaintext

    Returns Promise<void>

  • Generate a new primary invite link for a chat, old primary link is revoked.

    Note: each administrator has their own primary invite link, and bots by default don't have one.

    Available: ✅ both users and bots

    Parameters

    Returns Promise<ChatInviteLink>

  • Returns Promise<string>

  • Try to find a dialog (dialogs) with a given peer (peers) by their ID, username or phone number.

    This might be an expensive call, as it will potentially iterate over all dialogs to find the one with the given peer

    Available: 👤 users only

    Parameters

    Returns Promise<Dialog[]>

    If a dialog with any of the given peers was not found

  • Find a folder by its parameter.

    Note: Searching by title and/or emoji might not be accurate since you can set the same title and/or emoji to multiple folders.

    Available: ✅ both users and bots

    Parameters

    • params: { emoji?: string; id?: number; title?: string }

      Search parameters. At least one must be set.

      • Optionalemoji?: string

        Folder emoji

      • Optionalid?: number

        Folder ID

      • Optionaltitle?: string

        Folder title

    Returns Promise<null | RawDialogFilter>

  • Forward one or more messages by their IDs. You can forward no more than 100 messages at once.

    Available: ✅ both users and bots

    Parameters

    Returns Promise<Message[]>

    Newly sent, forwarded messages in the destination chat.

  • Get all stories (e.g. to load the top bar) Available: 👤 users only

    Parameters

    • Optionalparams: { archived?: boolean; offset?: string }
      • Optionalarchived?: boolean

        Whether to fetch stories from "archived" (or "hidden") peers

      • Optionaloffset?: string

        Offset from which to fetch stories

    Returns Promise<AllStories>

  • Returns Promise<{ hash: string; id: number }>

  • Get boosts of a channel Available: 👤 users only

    Parameters

    • peerId: InputPeerLike
    • Optionalparams: { limit?: number; offset?: string }
      • Optionallimit?: number

        Maximum number of boosters to fetch

        100
        
      • Optionaloffset?: string

        Offset for pagination

    Returns Promise<ArrayPaginated<Boost, string>>

  • Gets information about a bot the current uzer owns (or the current bot) Available: ✅ both users and bots

    Parameters

    • params: { bot?: InputPeerLike; langCode?: string }
      • Optionalbot?: InputPeerLike

        When called by a user, a bot the user owns must be specified. When called by a bot, must be empty

      • OptionallangCode?: string

        If passed, will retrieve the bot's description in the given language. If left empty, will retrieve the fallback description.

    Returns Promise<RawBotInfo>

  • Get information about the connection of the bot with a business account

    Available: 🤖 bots only

    Parameters

    • connectionId: string

      ID of the business connection

    Returns Promise<BusinessConnection>

  • Request a callback answer from a bot, i.e. click an inline button that contains data.

    Available: 👤 users only

    Parameters

    • params: InputMessageId & {
          data: string | Uint8Array;
          fireAndForget?: boolean;
          game?: boolean;
          password?: string;
          timeout?: number;
      }
      • data: string | Uint8Array

        Data contained in the button

      • OptionalfireAndForget?: boolean

        Whether to "fire and forget" this request, in which case the promise will resolve as soon as the request is sent with an empty response.

        Useful for interacting with bots that don't correctly answer to callback queries and the request always times out.

        Note: any errors will be silently ignored.

      • Optionalgame?: boolean

        Whether this is a "play game" button

      • Optionalpassword?: string

        If the button requires password entry, your 2FA password.

        Your password is never exposed to the bot, it is checked by Telegram.

      • Optionaltimeout?: number

        Timeout for the query in ms.

        10000 (10 sec)

    Returns Promise<RawBotCallbackAnswer>

  • Get basic information about a chat.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      ID of the chat, its username or invite link

    Returns Promise<Chat>

    MtArgumentError In case you are trying to get info about private chat that you haven't joined. Use getChatPreview instead.

  • Get chat event log ("Recent actions" in official clients).

    Only available for supergroups and channels, and requires (any) administrator rights.

    Results are returned in reverse chronological order (i.e. newest first) and event IDs are in direct chronological order (i.e. newer events have bigger event ID)

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike
    • Optionalparams: {
          filters?: InputChatEventFilters;
          limit?: number;
          maxId?: Long;
          minId?: Long;
          query?: string;
          users?: InputPeerLike[];
      }
      • Optionalfilters?: InputChatEventFilters

        Event filters. Can be a TL object, or one or more action types.

        Note that some filters are grouped in TL (i.e. info=true will return title_changed, username_changed and many more), and when passing one or more action types, they will be filtered locally.

      • Optionallimit?: number

        Limit the number of events returned.

        Note: when using filters, there will likely be less events returned than specified here. This limit is only used to limit the number of events to fetch from the server.

        If you need to limit the number of events returned, use iterChatEventLog instead.

        100
        
      • OptionalmaxId?: Long

        Maximum event ID to return, can be used as a base offset

      • OptionalminId?: Long

        Minimum event ID to return

      • Optionalquery?: string

        Search query

      • Optionalusers?: InputPeerLike[]

        List of users whose actions to return

    Returns Promise<ChatEvent[]>

  • Get a chunk of members of some chat.

    You can retrieve up to 200 members at once

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • Optionalparams: {
          limit?: number;
          offset?: number;
          query?: string;
          type?:
              | "restricted"
              | "contacts"
              | "bots"
              | "banned"
              | "admins"
              | "mention"
              | "all"
              | "recent";
      }

      Additional parameters

      • Optionallimit?: number

        Maximum number of members to be retrieved.

        Note: Telegram currently only allows you to ever retrieve at most 200 members, regardless of offset/limit. I.e. when passing offset=201 nothing will ever be returned.

        200
        
      • Optionaloffset?: number

        Sequential number of the first member to be returned.

      • Optionalquery?: string

        Search query to filter members by their display names and usernames

        Note: Only used for these values of filter: all, banned, restricted, mention, contacts

        '' (empty string)

      • Optionaltype?:
            | "restricted"
            | "contacts"
            | "bots"
            | "banned"
            | "admins"
            | "mention"
            | "all"
            | "recent"

        Type of the query. Can be:

        • all: get all members
        • banned: get only banned members
        • restricted: get only restricted members
        • bots: get only bots
        • recent: get recent members
        • admins: get only administrators (and creator)
        • contacts: get only contacts
        • mention: get users that can be mentioned (see tl.RawChannelParticipantsMentions)

        Only used for channels and supergroups.

        recent

    Returns Promise<ArrayWithTotal<ChatMember>>

  • Get preview information about a private chat.

    Available: 👤 users only

    Parameters

    • inviteLink: string

      Invite link

    Returns Promise<ChatPreview>

    MtArgumentError In case invite link has invalid format

    MtPeerNotFoundError In case you are trying to get info about private chat that you have already joined. Use getChat or getFullChat instead.

  • Get information about a fragment collectible Available: 👤 users only

    Parameters

    • kind: "username" | "phone"
    • item: string

    Returns Promise<CollectibleInfo>

  • Get a list of common chats you have with a given user

    Available: 👤 users only

    Parameters

    Returns Promise<Chat[]>

    MtInvalidPeerTypeError

  • Get list of contacts from your Telegram contacts list. Available: 👤 users only

    Returns Promise<User[]>

  • Get custom emoji stickers by their IDs

    Available: ✅ both users and bots

    Parameters

    • ids: Long[]

      IDs of the stickers (as defined in MessageEntity.emojiId)

    Returns Promise<Sticker[]>

  • Get discussion message for some channel post.

    Returns null if the post does not have a discussion message.

    This method might throw FLOOD_WAIT_X error in case the discussion message was not yet created. Error is usually handled by the client, but if you disabled that, you'll need to handle it manually.

    Available: 👤 users only

    Parameters

    Returns Promise<null | Message>

  • Get fact check information for one or more messages in a chat

    Available: 👤 users only

    Parameters

    Returns Promise<(null | FactCheck)[]>

  • Get full information about a chat.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      ID of the chat, its username or invite link

    Returns Promise<FullChat>

    MtArgumentError In case you are trying to get info about private chat that you haven't joined. Use getChatPreview instead.

  • Get high scores of a game Available: 🤖 bots only

    Parameters

    • params: InputMessageId & { userId?: InputPeerLike | undefined }
      • OptionaluserId?: InputPeerLike | undefined

        ID of the user to find high scores for

    Returns Promise<GameHighScore[]>

  • Gets the current default value of the Time-To-Live setting, applied to all new chats. Available: 👤 users only

    Returns Promise<number>

  • Get chat history.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat's marked ID, its username, phone or "me" or "self".

    • Optionalparams: {
          addOffset?: number;
          limit?: number;
          maxId?: number;
          minId?: number;
          offset?: GetHistoryOffset;
          reverse?: boolean;
      }

      Additional fetch parameters

      • OptionaladdOffset?: number

        Additional offset from offset, in resulting messages.

        This can be used for advanced use cases, like:

        • Loading 20 messages newer than message with ID MSGID: offset = MSGID, addOffset = -20, limit = 20
        • Loading 20 messages around message with ID MSGID: offset = MSGID, addOffset = -10, limit = 20

        0 (disabled)

      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        100
        
      • OptionalmaxId?: number

        Maximum message ID to return.

        0 (disabled).

      • OptionalminId?: number

        Minimum message ID to return

        0 (disabled).

      • Optionaloffset?: GetHistoryOffset

        Offset for pagination

      • Optionalreverse?: boolean

        Whether to retrieve messages in reversed order (from older to recent), starting from offset (inclusive).

        Note: Using reverse=true requires you to pass offset from which to start fetching the messages "downwards". If you call getHistory with reverse=true and without any offset, it will return an empty array.

        false
        

    Returns Promise<ArrayPaginated<Message, GetHistoryOffset>>

  • Get a list of all installed sticker packs

    Note: This method returns brief meta information about the packs, that does not include the stickers themselves. Use getStickerSet to get a stickerset that will include the stickers Available: 👤 users only

    Returns Promise<StickerSet[]>

  • Iterate over users who have joined the chat with the given invite link.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • Optionalparams: {
          limit?: number;
          link?: string | ChatInviteLink;
          offsetDate?: number | Date;
          offsetUser?: TypeInputUser;
          requested?: boolean;
          requestedSearch?: string;
      }

      Additional params

      • Optionallimit?: number

        Maximum number of users to return

        100
        
      • Optionallink?: string | ChatInviteLink

        Invite link for which to get members

      • OptionaloffsetDate?: number | Date

        Offset request/join date used as an anchor for pagination.

      • OptionaloffsetUser?: TypeInputUser

        Offset user used as an anchor for pagination

      • Optionalrequested?: boolean

        Whether to get users who have requested to join the chat but weren't accepted yet

      • OptionalrequestedSearch?: string

        Search for a user in the pending join requests list (if passed, requested is assumed to be true)

        Doesn't work when link is set (Telegram limitation)

    Returns Promise<
        ArrayPaginated<
            ChatInviteLinkMember,
            { date: number; user: TypeInputUser },
        >,
    >

  • Get invite links created by some administrator in the chat.

    As an administrator you can only get your own links (i.e. adminId = "self"), as a creator you can get any other admin's links.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • Optionalparams: {
          admin?: InputPeerLike;
          limit?: number;
          offset?: GetInviteLinksOffset;
          revoked?: boolean;
      }
      • Optionaladmin?: InputPeerLike

        Only return this admin's links.

        "self"

      • Optionallimit?: number

        Limit the number of invite links to be fetched.

        100
        
      • Optionaloffset?: GetInviteLinksOffset

        Offset for pagination.

      • Optionalrevoked?: boolean

        Whether to fetch revoked invite links

    Returns Promise<ArrayPaginated<ChatInviteLink, GetInviteLinksOffset>>

  • Get currently authorized user's full information Available: ✅ both users and bots

    Returns Promise<User>

  • Given a message link (e.g. t.me/durov/1), fetch the relevant message. Available: ✅ both users and bots

    Parameters

    • link: string

    Returns Promise<null | Message>

  • Get reactions to Messages.

    Note: messages must all be from the same chat.

    Apps should short-poll reactions for visible messages (that weren't sent by the user) once every 15-30 seconds, but only if message.reactions is set

    Available: ✅ both users and bots

    Parameters

    Returns Promise<(null | MessageReactions)[]>

    Reactions to corresponding messages, or null if there are none

  • Get reactions to messages by their IDs.

    Apps should short-poll reactions for visible messages (that weren't sent by the user) once every 15-30 seconds, but only if message.reactions is set

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      ID of the chat with messages

    • messages: number[]

      Message IDs

    Returns Promise<(null | MessageReactions)[]>

    Reactions to corresponding messages, or null if there are none

  • Get messages in chat by their IDs

    Fot messages that were not found, null will be returned at that position.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat's marked ID, its username, phone or "me" or "self"

    • messageIds: MaybeArray<number>

      Messages IDs

    • OptionalfromReply: boolean

      Whether the reply to a given message should be fetched (i.e. getMessages(msg.chat.id, msg.id, true).id === msg.replyToMessageId)

    Returns Promise<(null | Message)[]>

  • Get messages from PM or legacy group by their IDs. For channels, use getMessages.

    Unlike getMessages, this method does not check if the message belongs to some chat.

    Fot messages that were not found, null will be returned at that position.

    Available: ✅ both users and bots

    Parameters

    • messageIds: MaybeArray<number>

      Messages IDs

    • OptionalfromReply: boolean

      Whether the reply to a given message should be fetched (i.e. getMessages(msg.chat.id, msg.id, true).id === msg.replyToMessageId)

    Returns Promise<(null | Message)[]>

  • Get boost slots information of the current user.

    Includes information about the currently boosted channels, as well as the slots that can be used to boost other channels. Available: 👤 users only

    Returns Promise<BoostSlot[]>

  • Get the list of sticker sets that were created by the current user Available: 👤 users only

    Parameters

    • Optionalparams: { limit?: number; offset?: Long }
      • Optionallimit?: number

        Limit for pagination

      • Optionaloffset?: Long

        Offset for pagination

    Returns Promise<ArrayPaginated<StickerSet, Long>>

  • Get currently authorized user's username.

    This method uses locally available information and does not call any API methods. Available: ✅ both users and bots

    Returns Promise<null | string>

  • Get nearby chats

    Available: 👤 users only

    Parameters

    • latitude: number

      Latitude of the location

    • longitude: number

      Longitude of the location

    Returns Promise<Chat[]>

  • Get your Two-Step Verification password hint.

    Available: 👤 users only

    Returns Promise<null | string>

    The password hint as a string, if any

  • Returns Promise<number>

  • Get a single profile picture of a user by its ID

    Available: ✅ both users and bots

    Parameters

    • userId: InputPeerLike

      User ID, username, phone number, "me" or "self"

    • photoId: Long

      ID of the photo to fetch

    Returns Promise<Photo>

  • Get a list of profile pictures of a user

    Available: ✅ both users and bots

    Parameters

    • userId: InputPeerLike

      User ID, username, phone number, "me" or "self"

    • Optionalparams: { limit?: number; offset?: number }
      • Optionallimit?: number

        Maximum number of items to fetch (up to 100)

        100

      • Optionaloffset?: number

        Offset from which to fetch.

        0

    Returns Promise<ArrayPaginated<Photo, number>>

  • Get profile stories Available: 👤 users only

    Parameters

    • peerId: InputPeerLike
    • Optionalparams: { kind?: "pinned" | "archived"; limit?: number; offsetId?: number }
      • Optionalkind?: "pinned" | "archived"

        Kind of stories to fetch

        • pinned - stories pinned to the profile and visible to everyone
        • archived - "archived" stories that can later be pinned, only visible to the owner

        pinned

      • Optionallimit?: number

        Maximum number of stories to fetch

        100
        
      • OptionaloffsetId?: number

        Offset ID for pagination

    Returns Promise<ArrayPaginated<Story, number>>

  • Get users who have reacted to the message.

    Available: 👤 users only

    Parameters

    • params: InputMessageId & {
          emoji?: InputReaction | undefined;
          limit?: number;
          offset?: string;
      }
      • Optionalemoji?: InputReaction | undefined

        Get only reactions with the specified emoji

      • Optionallimit?: number

        Limit the number of users returned.

        100
        
      • Optionaloffset?: string

        Offset for pagination

    Returns Promise<ArrayPaginated<PeerReaction, string>>

  • For messages containing a reply, fetch the message that is being replied.

    Note that even if a message has replyToMessage, the message itself may have been deleted, in which case this method will also return null. Available: ✅ both users and bots

    Parameters

    Returns Promise<null | Message>

  • Get scheduled messages in chat by their IDs

    Fot messages that were not found, null will be returned at that position.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat's marked ID, its username, phone or "me" or "self"

    • messageIds: MaybeArray<number>

      Scheduled messages IDs

    Returns Promise<(null | Message)[]>

  • Get channels that are similar to a given channel

    Note: This method only returns the channels that the current user is not subscribed to. For non-premium users, this method will only return a few channels (with the total number of similar channels being specified in .total)

    Returns empty array in case there are no similar channels available. Available: 👤 users only

    Parameters

    Returns Promise<ArrayWithTotal<Chat>>

  • Get a list of gifts sent to a user.

    Available: 👤 users only

    Parameters

    • userId: InputPeerLike

      User whose gifts to fetch

    • Optionalparams: { limit?: number; offset?: string }
      • Optionallimit?: number

        Maximum number of gifts to fetch.

        100
        
      • Optionaloffset?: string

        Offset for pagination.

    Returns Promise<ArrayPaginated<UserStarGift, string>>

    Gifts sent to the user

  • Get Telegram Stars transactions for a given peer.

    You can either pass self to get your own transactions, or a chat/bot ID to get transactions of that peer.

    Available: ✅ both users and bots

    Parameters

    • peerId: InputPeerLike

      Peer ID

    • Optionalparams: {
          direction?: "incoming" | "outgoing";
          limit?: number;
          offset?: string;
          sort?: "asc" | "desc";
          subscriptionId?: string;
      }

      Additional parameters

      • Optionaldirection?: "incoming" | "outgoing"

        If passed, only transactions of this direction will be returned

      • Optionallimit?: number

        Pagination limit

        100
        
      • Optionaloffset?: string

        Pagination offset

      • Optionalsort?: "asc" | "desc"

        Direction to sort transactions date by (default: desc)

      • OptionalsubscriptionId?: string

        If passed, will only return transactions related to this subscription ID

    Returns Promise<StarsStatus>

  • Generate a link to a story.

    Basically the link format is t.me/<username>/s/<story_id>, and if the user doesn't have a username, USER_PUBLIC_MISSING is thrown.

    I have no idea why is this an RPC call, but whatever Available: 👤 users only

    Parameters

    Returns Promise<string>

  • Get viewers list of a story Available: 👤 users only

    Parameters

    • peerId: InputPeerLike
    • storyId: number
    • Optionalparams: {
          limit?: number;
          offset?: string;
          onlyContacts?: boolean;
          query?: string;
          sortBy?: "date" | "reaction";
      }
      • Optionallimit?: number

        Maximum number of viewers to fetch

        100
        
      • Optionaloffset?: string

        Offset ID for pagination

      • OptionalonlyContacts?: boolean

        Whether to only fetch viewers from contacts

      • Optionalquery?: string

        Search query

      • OptionalsortBy?: "date" | "reaction"

        How to sort the results?

        • reaction - by reaction (viewers who has reacted are first), then by date (newest first)
        • date - by date, newest first

        reaction

    Returns Promise<StoryViewersList>

  • Get basic information about a user.

    Available: ✅ both users and bots

    Parameters

    • userId: InputPeerLike

      ID of the user or their username or invite link

    Returns Promise<User>

  • Get information about multiple users. You can retrieve up to 200 users at once.

    Note that order is not guaranteed.

    Available: ✅ both users and bots

    Parameters

    Returns Promise<(null | User)[]>

  • Approve or decline multiple join requests to a chat. Available: 👤 users only

    Parameters

    • params: {
          action: "approve" | "decline";
          chatId: InputPeerLike;
          link?: string | ChatInviteLink;
      }
      • action: "approve" | "decline"

        Whether to approve or decline the join requests

      • chatId: InputPeerLike

        Chat/channel ID

      • Optionallink?: string | ChatInviteLink

        Invite link to target

    Returns Promise<void>

  • Approve or decline join request to a chat. Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Hide own stories views (activate so called "stealth mode")

    Currently has a cooldown of 1 hour, and throws FLOOD_WAIT error if it is on cooldown. Available: 👤 users only

    Parameters

    • Optionalparams: { future?: boolean; past?: boolean }
      • Optionalfuture?: boolean

        Whether to hide views for the next 25 minutes

        true
        
      • Optionalpast?: boolean

        Whether to hide views from the last 5 minutes

        true
        

    Returns Promise<StoriesStealthMode>

  • Increment views of one or more stories.

    This should be used for pinned stories, as they can't be marked as read when the user sees them (Story#isActive == false)

    Available: 👤 users only

    Parameters

    • peerId: InputPeerLike

      Peer ID whose stories to mark as read

    • ids: MaybeArray<number>

      ID(s) of the stories to increment views of (max 200)

    Returns Promise<void>

  • Check whether a given peer ID can be used to actually interact with the Telegram API. This method checks the internal peers cache for the given input peer, and returns true if it is available there.

    You can think of this method as a stripped down version of resolvePeer, which only returns true or false.

    Note: This method works offline and never sends any requests. This means that when passing a username or phone number, it will only return true if the user with that username/phone number is cached in the storage, and will not try to resolve the peer by calling the API, which may lead to false negatives.

    Available: ✅ both users and bots

    Parameters

    Returns Promise<boolean>

  • Iterate over all stories (e.g. to load the top bar)

    Wrapper over getAllStories Available: ✅ both users and bots

    Parameters

    • Optionalparams: { archived?: boolean; offset?: string } & { limit?: number }
      • Optionalarchived?: boolean

        Whether to fetch stories from "archived" (or "hidden") peers

      • Optionaloffset?: string

        Offset from which to fetch stories

      • Optionallimit?: number

        Maximum number of stories to fetch

        Infinity
        

    Returns AsyncIterableIterator<PeerStories>

  • Iterate over boosters of a channel.

    Wrapper over getBoosters Available: ✅ both users and bots

    Parameters

    • peerId: InputPeerLike
    • Optionalparams: { limit?: number; offset?: string } & { chunkSize?: number; limit?: number }
      • Optionallimit?: number

        Maximum number of boosters to fetch

        100
        
      • Optionaloffset?: string

        Offset for pagination

      • OptionalchunkSize?: number

        Number of boosters to fetch per request Usually you don't need to change this

        100
        
      • Optionallimit?: number

        Total number of boosters to fetch

        Infinity, i.e. fetch all boosters
        

    Returns AsyncIterableIterator<Boost>

  • Iterate over chat event log.

    Small wrapper over getChatEventLog

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • Optionalparams: {
          filters?: InputChatEventFilters;
          limit?: number;
          maxId?: Long;
          minId?: Long;
          query?: string;
          users?: InputPeerLike[];
      } & { chunkSize?: number; limit?: number }
      • Optionalfilters?: InputChatEventFilters

        Event filters. Can be a TL object, or one or more action types.

        Note that some filters are grouped in TL (i.e. info=true will return title_changed, username_changed and many more), and when passing one or more action types, they will be filtered locally.

      • Optionallimit?: number

        Limit the number of events returned.

        Note: when using filters, there will likely be less events returned than specified here. This limit is only used to limit the number of events to fetch from the server.

        If you need to limit the number of events returned, use iterChatEventLog instead.

        100
        
      • OptionalmaxId?: Long

        Maximum event ID to return, can be used as a base offset

      • OptionalminId?: Long

        Minimum event ID to return

      • Optionalquery?: string

        Search query

      • Optionalusers?: InputPeerLike[]

        List of users whose actions to return

      • OptionalchunkSize?: number

        Chunk size, passed as limit to getChatEventLog. Usually you don't need to touch this.

        100
        
      • Optionallimit?: number

        Total number of events to return.

        Infinity
        

    Returns AsyncIterableIterator<ChatEvent>

  • Iterate through chat members

    This method is a small wrapper over getChatMembers, which also handles duplicate entries (i.e. does not yield the same member twice)

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • Optionalparams: {
          limit?: number;
          offset?: number;
          query?: string;
          type?:
              | "restricted"
              | "contacts"
              | "bots"
              | "banned"
              | "admins"
              | "mention"
              | "all"
              | "recent";
      } & { chunkSize?: number }

      Additional parameters

      • Optionallimit?: number

        Maximum number of members to be retrieved.

        Note: Telegram currently only allows you to ever retrieve at most 200 members, regardless of offset/limit. I.e. when passing offset=201 nothing will ever be returned.

        200
        
      • Optionaloffset?: number

        Sequential number of the first member to be returned.

      • Optionalquery?: string

        Search query to filter members by their display names and usernames

        Note: Only used for these values of filter: all, banned, restricted, mention, contacts

        '' (empty string)

      • Optionaltype?:
            | "restricted"
            | "contacts"
            | "bots"
            | "banned"
            | "admins"
            | "mention"
            | "all"
            | "recent"

        Type of the query. Can be:

        • all: get all members
        • banned: get only banned members
        • restricted: get only restricted members
        • bots: get only bots
        • recent: get recent members
        • admins: get only administrators (and creator)
        • contacts: get only contacts
        • mention: get users that can be mentioned (see tl.RawChannelParticipantsMentions)

        Only used for channels and supergroups.

        recent

      • OptionalchunkSize?: number

        Chunk size, which will be passed as limit parameter to getChatMembers. Usually you shouldn't care about this.

        200

    Returns AsyncIterableIterator<ChatMember>

  • Iterate over dialogs.

    Note that due to Telegram API limitations, ordering here can only be anti-chronological (i.e. newest - first), and draft update date is not considered when sorting.

    Available: 👤 users only

    Parameters

    • Optionalparams: {
          archived?: "exclude" | "only" | "keep";
          chunkSize?: number;
          filter?: Partial<Omit<RawDialogFilter, "_" | "id" | "title">>;
          folder?: InputDialogFolder;
          limit?: number;
          offsetDate?: number | Date;
          offsetId?: number;
          offsetPeer?: TypeInputPeer;
          pinned?: "include" | "exclude" | "only" | "keep";
      }

      Fetch parameters

      • Optionalarchived?: "exclude" | "only" | "keep"

        How to handle archived chats?

        Whether to keep them among other dialogs, exclude them from the list, or only return archived dialogs

        Ignored for folders, since folders themselves contain information about archived chats.

        Note: when pinned=only, archived=keep will act as only because of Telegram API limitations.

        exclude

      • OptionalchunkSize?: number

        Chunk size which will be passed to messages.getDialogs. You shouldn't usually care about this.

        100.
        
      • Optionalfilter?: Partial<Omit<RawDialogFilter, "_" | "id" | "title">>

        Additional filtering for the dialogs.

        If folder is not provided, this filter is used instead. If folder is provided, fields from this object are used to override filters inside the folder.

      • Optionalfolder?: InputDialogFolder

        Folder from which the dialogs will be fetched.

        You can pass folder object, id or title

        Note that passing anything except object will cause the list of the folders to be fetched, and passing a title may fetch from a wrong folder if you have multiple with the same title.

        Also note that fetching dialogs in a folder is orders of magnitudes* slower than normal because of Telegram API limitations - we have to fetch all dialogs and filter the ones we need manually. If possible, use Dialog.filterFolder instead.

        When a folder with given ID or title is not found, MtArgumentError is thrown

        <empty> (fetches from "All" folder)
        
      • Optionallimit?: number

        Limits the number of dialogs to be received.

        Infinity, i.e. all dialogs are fetched

      • OptionaloffsetDate?: number | Date

        Offset message date used as an anchor for pagination.

      • OptionaloffsetId?: number

        Offset message ID used as an anchor for pagination

      • OptionaloffsetPeer?: TypeInputPeer

        Offset peer used as an anchor for pagination

      • Optionalpinned?: "include" | "exclude" | "only" | "keep"

        How to handle pinned dialogs?

        Whether to include them at the start of the list, exclude them at all, or only return pinned dialogs.

        Additionally, for folders you can specify keep, which will return pinned dialogs ordered by date among other non-pinned dialogs.

        Note: When using include mode with folders, pinned dialogs will only be fetched if all offset parameters are unset.

        include.

    Returns AsyncIterableIterator<Dialog>

  • Iterate over forum topics. Wrapper over getForumTopics.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • Optionalparams: { limit?: number; offset?: GetForumTopicsOffset; query?: string } & {
          chunkSize?: number;
          limit?: number;
      }
      • Optionallimit?: number

        Maximum number of topics to return.

        100
        
      • Optionaloffset?: GetForumTopicsOffset

        Offset for pagination

      • Optionalquery?: string

        Search query

      • OptionalchunkSize?: number

        Chunk size. Usually you shouldn't care about this.

      • Optionallimit?: number

        Maximum number of topics to return.

        Infinity, i.e. return all topics

    Returns AsyncIterableIterator<ForumTopic>

  • Iterate over chat history. Wrapper over getHistory

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat's marked ID, its username, phone or "me" or "self".

    • Optionalparams: {
          addOffset?: number;
          limit?: number;
          maxId?: number;
          minId?: number;
          offset?: GetHistoryOffset;
          reverse?: boolean;
      } & { chunkSize?: number; limit?: number }

      Additional fetch parameters

      • OptionaladdOffset?: number

        Additional offset from offset, in resulting messages.

        This can be used for advanced use cases, like:

        • Loading 20 messages newer than message with ID MSGID: offset = MSGID, addOffset = -20, limit = 20
        • Loading 20 messages around message with ID MSGID: offset = MSGID, addOffset = -10, limit = 20

        0 (disabled)

      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        100
        
      • OptionalmaxId?: number

        Maximum message ID to return.

        0 (disabled).

      • OptionalminId?: number

        Minimum message ID to return

        0 (disabled).

      • Optionaloffset?: GetHistoryOffset

        Offset for pagination

      • Optionalreverse?: boolean

        Whether to retrieve messages in reversed order (from older to recent), starting from offset (inclusive).

        Note: Using reverse=true requires you to pass offset from which to start fetching the messages "downwards". If you call getHistory with reverse=true and without any offset, it will return an empty array.

        false
        
      • OptionalchunkSize?: number

        Chunk size. Usually you shouldn't care about this.

        100
        
      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        Infinity, i.e. all messages
        

    Returns AsyncIterableIterator<Message>

  • Iterate over users who have joined the chat with the given invite link.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • Optionalparams: {
          limit?: number;
          link?: string | ChatInviteLink;
          offsetDate?: number | Date;
          offsetUser?: TypeInputUser;
          requested?: boolean;
          requestedSearch?: string;
      } & { chunkSize?: number; limit?: number }

      Additional params

      • Optionallimit?: number

        Maximum number of users to return

        100
        
      • Optionallink?: string | ChatInviteLink

        Invite link for which to get members

      • OptionaloffsetDate?: number | Date

        Offset request/join date used as an anchor for pagination.

      • OptionaloffsetUser?: TypeInputUser

        Offset user used as an anchor for pagination

      • Optionalrequested?: boolean

        Whether to get users who have requested to join the chat but weren't accepted yet

      • OptionalrequestedSearch?: string

        Search for a user in the pending join requests list (if passed, requested is assumed to be true)

        Doesn't work when link is set (Telegram limitation)

      • OptionalchunkSize?: number

        Chunk size which will be passed to messages.getChatInviteImporters. You shouldn't usually care about this.

        100.
        
      • Optionallimit?: number

        Maximum number of users to return

        Infinity, i.e. all users are fetched

    Returns AsyncIterableIterator<ChatInviteLinkMember>

  • Iterate over invite links created by some administrator in the chat.

    As an administrator you can only get your own links (i.e. adminId = "self"), as a creator you can get any other admin's links.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • Optionalparams: {
          admin?: InputPeerLike;
          limit?: number;
          offset?: GetInviteLinksOffset;
          revoked?: boolean;
      } & { chunkSize?: number; limit?: number }
      • Optionaladmin?: InputPeerLike

        Only return this admin's links.

        "self"

      • Optionallimit?: number

        Limit the number of invite links to be fetched.

        100
        
      • Optionaloffset?: GetInviteLinksOffset

        Offset for pagination.

      • Optionalrevoked?: boolean

        Whether to fetch revoked invite links

      • OptionalchunkSize?: number

        Size of chunks which are fetched. Usually not needed.

        100

      • Optionallimit?: number

        Limit the number of invite links to be fetched. By default, all links are fetched.

    Returns AsyncIterableIterator<ChatInviteLink>

  • Iterate over profile photos

    Available: ✅ both users and bots

    Parameters

    • userId: InputPeerLike

      User ID, username, phone number, "me" or "self"

    • Optionalparams: { limit?: number; offset?: number } & { chunkSize?: number; limit?: number }
      • Optionallimit?: number

        Maximum number of items to fetch (up to 100)

        100

      • Optionaloffset?: number

        Offset from which to fetch.

        0

      • OptionalchunkSize?: number

        Size of chunks which are fetched. Usually not needed.

        100
        
      • Optionallimit?: number

        Maximum number of items to fetch

        Infinity, i.e. all items are fetched

    Returns AsyncIterableIterator<Photo>

  • Iterate over profile stories. Wrapper over getProfileStories Available: ✅ both users and bots

    Parameters

    • peerId: InputPeerLike
    • Optionalparams: { kind?: "pinned" | "archived"; limit?: number; offsetId?: number } & {
          chunkSize?: number;
          limit?: number;
      }
      • Optionalkind?: "pinned" | "archived"

        Kind of stories to fetch

        • pinned - stories pinned to the profile and visible to everyone
        • archived - "archived" stories that can later be pinned, only visible to the owner

        pinned

      • Optionallimit?: number

        Maximum number of stories to fetch

        100
        
      • OptionaloffsetId?: number

        Offset ID for pagination

      • OptionalchunkSize?: number

        Number of stories to fetch per request. Usually you shouldn't care about this.

        100
        
      • Optionallimit?: number

        Total number of stories to fetch

        Infinity, i.e. fetch all stories

    Returns AsyncIterableIterator<Story>

  • Iterate over users who have reacted to the message.

    Wrapper over getReactionUsers.

    Available: ✅ both users and bots

    Parameters

    • params: (
          InputMessageId & { emoji?: InputReaction | undefined; limit?: number | undefined; offset?: string | undefined; }
      ) & { chunkSize?: number; limit?: number }
      • OptionalchunkSize?: number

        Chunk size, usually not needed.

        100
        
      • Optionallimit?: number

        Limit the number of events returned.

        Infinity, i.e. all events are returned

    Returns AsyncIterableIterator<PeerReaction>

  • Search for messages globally from all of your chats.

    Iterable version of searchGlobal

    Note: Due to Telegram limitations, you can only get up to ~10000 messages

    Available: ✅ both users and bots

    Parameters

    • Optionalparams: {
          filter?: TypeMessagesFilter;
          limit?: number;
          maxDate?: number | Date;
          minDate?: number | Date;
          offset?: SearchGlobalOffset;
          onlyChannels?: boolean;
          query?: string;
      } & { chunkSize?: number; limit?: number }

      Search parameters

      • Optionalfilter?: TypeMessagesFilter

        Filter the results using some filter. (see SearchFilters)

        SearchFilters.Empty (i.e. will return all messages)

      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        100
        
      • OptionalmaxDate?: number | Date

        Only return messages older than this date

      • OptionalminDate?: number | Date

        Only return messages newer than this date

      • Optionaloffset?: SearchGlobalOffset

        Offset data used for pagination

      • OptionalonlyChannels?: boolean

        Whether to only search across broadcast channels

      • Optionalquery?: string

        Text query string. Use "@" to search for mentions.

        "" (empty string)

      • OptionalchunkSize?: number

        Chunk size, which will be passed as limit parameter for messages.search. Usually you shouldn't care about this.

        100
        
      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        Infinity, i.e. all messages are returned

    Returns AsyncIterableIterator<Message>

  • Perform a global hashtag search, across the entire Telegram

    Iterable version of searchHashtag

    Available: ✅ both users and bots

    Parameters

    • hashtag: string

      Hashtag to search for

    • Optionalparams: { limit?: number; offset?: SearchHashtagOffset } & {
          chunkSize?: number;
          limit?: number;
      }

      Additional parameters

      • Optionallimit?: number

        Limit the number of results

      • Optionaloffset?: SearchHashtagOffset

        Offset for the search

      • OptionalchunkSize?: number

        Chunk size, which will be passed as limit parameter for messages.search. Usually you shouldn't care about this.

        100
        
      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        Infinity, i.e. all messages are returned

    Returns AsyncIterableIterator<Message>

  • Search for messages inside a specific chat

    Iterable version of searchMessages

    Available: ✅ both users and bots

    Parameters

    • Optionalparams: {
          addOffset?: number;
          chatId?: InputPeerLike;
          filter?: TypeMessagesFilter;
          fromUser?: InputPeerLike;
          limit?: number;
          maxDate?: number | Date;
          maxId?: number;
          minDate?: number | Date;
          minId?: number;
          offset?: number;
          query?: string;
          threadId?: number;
      } & { chunkSize?: number; limit?: number }

      Additional search parameters

      • OptionaladdOffset?: number

        Additional offset from offset, in resulting messages.

        This can be used for advanced use cases, like:

        • Loading 20 results newer than message with ID MSGID: offset = MSGID, addOffset = -20, limit = 20
        • Loading 20 results around message with ID MSGID: offset = MSGID, addOffset = -10, limit = 20

        When offset is not set, this will be relative to the last message

        0 (disabled)

      • OptionalchatId?: InputPeerLike

        Chat where to search for messages.

        When empty, will search across common message box (i.e. private messages and legacy chats)

      • Optionalfilter?: TypeMessagesFilter

        Filter the results using some filter (see SearchFilters)

        SearchFilters.Empty (i.e. will return all messages)

      • OptionalfromUser?: InputPeerLike

        Search only for messages sent by a specific user.

        You can pass their marked ID, username, phone or "me" or "self"

      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        100
        
      • OptionalmaxDate?: number | Date

        Maximum message date to return

        0 (disabled).

      • OptionalmaxId?: number

        Maximum message ID to return.

        Unless addOffset is used, this will work the same as offset.

        0 (disabled).

      • OptionalminDate?: number | Date

        Minimum message date to return

        0 (disabled).

      • OptionalminId?: number

        Minimum message ID to return

        0 (disabled).

      • Optionaloffset?: number

        Offset ID for the search. Only messages earlier than this ID will be returned.

        0 (starting from the latest message).

      • Optionalquery?: string

        Text query string. Required for text-only messages, optional for media.

        "" (empty string)

      • OptionalthreadId?: number

        Thread ID to return only messages from this thread.

      • OptionalchunkSize?: number

        Chunk size, which will be passed as limit parameter for messages.search. Usually you shouldn't care about this.

        100

      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        Infinity, i.e. all messages are returned

    Returns AsyncIterableIterator<Message>

  • Iterate over gifts sent to a given user.

    Wrapper over getStarGifts

    Available: 👤 users only

    Parameters

    • peerId: InputPeerLike

      Peer ID

    • Optionalparams: { limit?: number; offset?: string } & { chunkSize?: number; limit?: number }

      Additional parameters

      • Optionallimit?: number

        Maximum number of gifts to fetch.

        100
        
      • Optionaloffset?: string

        Offset for pagination.

      • OptionalchunkSize?: number

        Number of gifts to fetch per request Usually you don't need to change this

        100
        
      • Optionallimit?: number

        Total number of gifts to fetch

        Infinity, i.e. fetch all gifts
        

    Returns AsyncIterableIterator<UserStarGift>

  • Iterate over Telegram Stars transactions for a given peer.

    You can either pass self to get your own transactions, or a chat/bot ID to get transactions of that peer.

    Wrapper over getStarsTransactions

    Available: ✅ both users and bots

    Parameters

    • peerId: InputPeerLike

      Peer ID

    • Optionalparams: {
          direction?: "incoming" | "outgoing";
          limit?: number;
          offset?: string;
          sort?: "asc" | "desc";
          subscriptionId?: string;
      } & { chunkSize?: number; limit?: number }

      Additional parameters

      • Optionaldirection?: "incoming" | "outgoing"

        If passed, only transactions of this direction will be returned

      • Optionallimit?: number

        Pagination limit

        100
        
      • Optionaloffset?: string

        Pagination offset

      • Optionalsort?: "asc" | "desc"

        Direction to sort transactions date by (default: desc)

      • OptionalsubscriptionId?: string

        If passed, will only return transactions related to this subscription ID

      • OptionalchunkSize?: number

        Number of boosters to fetch per request Usually you don't need to change this

        100
        
      • Optionallimit?: number

        Total number of boosters to fetch

        Infinity, i.e. fetch all boosters
        

    Returns AsyncIterableIterator<StarsTransaction>

  • Iterate over viewers list of a story. Wrapper over getStoryViewers Available: ✅ both users and bots

    Parameters

    • peerId: InputPeerLike
    • storyId: number
    • Optionalparams: {
          limit?: number;
          offset?: string;
          onlyContacts?: boolean;
          query?: string;
          sortBy?: "date" | "reaction";
      } & { chunkSize?: number; limit?: number }
      • Optionallimit?: number

        Maximum number of viewers to fetch

        100
        
      • Optionaloffset?: string

        Offset ID for pagination

      • OptionalonlyContacts?: boolean

        Whether to only fetch viewers from contacts

      • Optionalquery?: string

        Search query

      • OptionalsortBy?: "date" | "reaction"

        How to sort the results?

        • reaction - by reaction (viewers who has reacted are first), then by date (newest first)
        • date - by date, newest first

        reaction

      • OptionalchunkSize?: number

        Number of viewers to fetch per request. Usually you don't need to change this.

        100
        
      • Optionallimit?: number

        Total number of viewers to fetch

        Infinity, i.e. fetch all viewers
        

    Returns AsyncIterableIterator<StoryViewer>

  • Join a channel or supergroup

    When using with invite links, this method may throw RPC error INVITE_REQUEST_SENT, which means that you need to wait for admin approval. You will get into the chat once they do so.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat identifier. Either an invite link (t.me/joinchat/*), a username (@username) or ID of the linked supergroup or channel.

    Returns Promise<Chat>

  • Leave a group chat, supergroup or channel

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • Optionalparams: { clear?: boolean }
      • Optionalclear?: boolean

        Whether to clear history after leaving (only for legacy group chats)

    Returns Promise<void>

  • Log out from Telegram account and optionally reset the session storage.

    When you log out, you can immediately log back in using the same TelegramClient instance.

    Available: ✅ both users and bots

    Returns Promise<LogOutResult>

    On success, true is returned

  • Parameters

    • channelId: number

    Returns Promise<boolean>

  • Parameters

    • channelId: number
    • Optionalpts: number

    Returns Promise<boolean>

  • Returns Promise<void>

  • Inform the library that the user has opened a chat.

    Some library logic depends on this, for example, the library will periodically ping the server to keep the updates flowing.

    Warning: Opening a chat with openChat method will make the library make additional requests every so often. Which means that you should avoid opening more than 5-10 chats at once, as it will probably trigger server-side limits and you might start getting transport errors or even get banned.

    Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Open a webview. Available: 👤 users only

    Parameters

    • params: {
          bot: InputPeerLike;
          chat?: InputPeerLike;
          platform:
              | string & {}
              | "android"
              | "ios"
              | "tdesktop"
              | "macos"
              | "unigram";
          theme?: | RawDataJSON
          | {
              accent_text_color?: string;
              bg_color?: string;
              button_color?: string;
              button_text_color?: string;
              destructive_text_color?: string;
              header_bg_color?: string;
              hint_color?: string;
              link_color?: string;
              secondary_bg_color?: string;
              section_bg_color?: string;
              section_header_text_color?: string;
              section_separator_color?: string;
              subtitle_text_color?: string;
              text_color?: string;
          };
          webview: InputWebview;
      }
      • bot: InputPeerLike

        Bot whose webview to open

      • Optionalchat?: InputPeerLike

        Chat to report to the server as the "currently open chat", also the chat to which the message will be sent in case of from_inline_keyboard, from_bot_menu and from_attach_menu webviews

      • platform: string & {} | "android" | "ios" | "tdesktop" | "macos" | "unigram"

        Webview platform to use in the init data

        Some of the known values:

        • android - Android clients
        • ios - iOS clients
        • tdesktop - Telegram Desktop
        • macos - Telegram for macOS
        • unigram - Unigram
      • Optionaltheme?:
            | RawDataJSON
            | {
                accent_text_color?: string;
                bg_color?: string;
                button_color?: string;
                button_text_color?: string;
                destructive_text_color?: string;
                header_bg_color?: string;
                hint_color?: string;
                link_color?: string;
                secondary_bg_color?: string;
                section_bg_color?: string;
                section_header_text_color?: string;
                section_separator_color?: string;
                subtitle_text_color?: string;
                text_color?: string;
            }

        Theme parameters to pass to the mini app

        Each value should be a string (hex-encoded RGB, no alpha)

      • webview: InputWebview

        Information about the webview to open

    Returns Promise<WebviewResult>

  • Pin a message in a group, supergroup, channel or PM.

    For supergroups/channels, you must have appropriate permissions, either as an admin, or as default permissions

    Available: ✅ both users and bots

    Parameters

    • params: InputMessageId & {
          bothSides?: boolean;
          notify?: boolean;
          shouldDispatch?: true;
      }
      • OptionalbothSides?: boolean

        Whether to pin for both sides (only for private chats)

      • Optionalnotify?: boolean

        Whether to send a notification (only for legacy groups and supergroups)

      • OptionalshouldDispatch?: true

        Whether to dispatch the returned service message (if any) to the client's update handler.

    Returns Promise<null | Message>

    Service message about pinned message, if one was generated.

  • Returns Promise<void>

  • Prepare an inline message result to be sent later via the shareMessage mini-app api method. Available: 🤖 bots only

    Parameters

    • params: {
          filter?:
              | TypeInlineQueryPeerType[]
              | {
                  bots?: boolean;
                  botSelf?: boolean;
                  channels?: boolean;
                  chats?: boolean;
                  private?: boolean;
                  supergroups?: boolean;
              };
          result: InputInlineResult;
          userId: InputPeerLike;
      }
      • Optionalfilter?:
            | TypeInlineQueryPeerType[]
            | {
                bots?: boolean;
                botSelf?: boolean;
                channels?: boolean;
                chats?: boolean;
                private?: boolean;
                supergroups?: boolean;
            }

        Filters for the client to use when prompting the user for the chat to send the inline message to.

        Note that this is just a hint for the client, and the client is free to ignore it.

      • result: InputInlineResult
      • userId: InputPeerLike

    Returns Promise<RawBotPreparedInlineMessage>

  • Send a media in reply to a given quote

    Parameters

    • message: Message
    • params: Omit<
          CommonSendParams & {
              caption?: InputText;
              invert?: boolean;
              progressCallback?: (uploaded: number, total: number) => void;
              replyMarkup?: ReplyMarkup;
          },
          "quoteText"
          | "quoteEntities",
      > & { end: number; start: number; toChatId?: InputPeerLike } & {
          media: string | InputMediaLike;
      }
      • end: number

        Index of the last character to quote (exclusive)

      • start: number

        Index of the first character to quote (inclusive)

      • OptionaltoChatId?: InputPeerLike

        Destination chat ID, username, phone, "me" or "self"

        message.chat

    Returns Promise<Message>

  • Send a media group in reply to a given quote

    Parameters

    • message: Message
    • params: Omit<
          CommonSendParams & {
              invertMedia?: boolean;
              progressCallback?: (
                  index: number,
                  uploaded: number,
                  total: number,
              ) => void;
          },
          "quoteText"
          | "quoteEntities",
      > & { end: number; start: number; toChatId?: InputPeerLike } & {
          medias: (string | InputMediaLike)[];
      }
      • end: number

        Index of the last character to quote (exclusive)

      • start: number

        Index of the first character to quote (inclusive)

      • OptionaltoChatId?: InputPeerLike

        Destination chat ID, username, phone, "me" or "self"

        message.chat

    Returns Promise<Message[]>

  • Send a text in reply to a given quote

    Parameters

    • message: Message
    • params: Omit<
          CommonSendParams & {
              disableWebPreview?: boolean;
              invertMedia?: boolean;
              replyMarkup?: ReplyMarkup;
          },
          "quoteText"
          | "quoteEntities",
      > & { end: number; start: number; toChatId?: InputPeerLike } & {
          text: InputText;
      }
      • end: number

        Index of the last character to quote (exclusive)

      • start: number

        Index of the first character to quote (inclusive)

      • OptionaltoChatId?: InputPeerLike

        Destination chat ID, username, phone, "me" or "self"

        message.chat

    Returns Promise<Message>

  • Mark chat history as read.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • Optionalparams: { clearMentions?: boolean; maxId?: number; shouldDispatch?: true }
      • OptionalclearMentions?: boolean

        Whether to also clear all mentions in the chat

      • OptionalmaxId?: number

        Message up until which to read history

        0, i.e. read everything
        
      • OptionalshouldDispatch?: true

        Whether to dispatch updates that will be generated by this call. Doesn't follow disableNoDispatch

    Returns Promise<void>

  • Mark all reactions in chat as read.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • Optionalparams: { shouldDispatch?: true }
      • OptionalshouldDispatch?: true

        Whether to dispatch updates that will be generated by this call. Doesn't follow disableNoDispatch

    Returns Promise<void>

  • Mark all stories up to a given ID as read

    This should only be used for "active" stories (Story#isActive == false)

    Available: 👤 users only

    Parameters

    • peerId: InputPeerLike

      Peer ID whose stories to mark as read

    • maxId: number

    Returns Promise<number[]>

    IDs of the stores that were marked as read

  • Recover your password with a recovery code and log in.

    Available: 👤 users only

    Parameters

    • params: { recoveryCode: string }
      • recoveryCode: string

        The recovery code sent via email

    Returns Promise<User>

    The authorized user

    BadRequestError In case the code is invalid

  • Parameters

    • dcId: number

    Returns Promise<void>

  • Remove 2FA password from your account

    Available: 👤 users only

    Parameters

    • password: string

      2FA password as plaintext

    Returns Promise<void>

  • Reorder pinned forum topics

    Only admins with manageTopics permission can do this. Available: 👤 users only

    Parameters

    • params: { chatId: InputPeerLike; force?: boolean; order: (number | ForumTopic)[] }
      • chatId: InputPeerLike

        Chat ID or username

      • Optionalforce?: boolean

        Whether to un-pin topics not present in the order

      • order: (number | ForumTopic)[]

        Order of the pinned topics

    Returns Promise<void>

  • Reorder usernames

    Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Replace a sticker in a sticker set with another sticker

    For bots the sticker set must have been created by this bot.

    Available: ✅ both users and bots

    Parameters

    • sticker: string | RawFullRemoteFileLocation | TypeInputDocument

      TDLib and Bot API compatible File ID, or a TL object representing a sticker to be removed

    • newSticker: InputStickerSetItem

      New sticker to replace the old one with

    • Optionalparams: { progressCallback?: (uploaded: number, total: number) => void }
      • OptionalprogressCallback?: (uploaded: number, total: number) => void

        Upload progress callback

    Returns Promise<StickerSet>

    Modfiied sticker set

  • Send a media in reply to a given message

    Parameters

    • message: Message
    • ...params: [
          media: string
          | InputMediaLike,
          params?: CommonSendParams & {
              caption?: InputText;
              invert?: boolean;
              progressCallback?: (uploaded: number, total: number) => void;
              replyMarkup?: ReplyMarkup;
          },
      ]

    Returns Promise<Message>

  • Send a media group in reply to a given message

    Parameters

    • message: Message
    • ...params: [
          medias: (string | InputMediaLike)[],
          params?: CommonSendParams & {
              invertMedia?: boolean;
              progressCallback?: (
                  index: number,
                  uploaded: number,
                  total: number,
              ) => void;
          },
      ]

    Returns Promise<Message[]>

  • Send a text in reply to a given message

    Parameters

    • message: Message
    • ...params: [
          text: InputText,
          params?: CommonSendParams & {
              disableWebPreview?: boolean;
              invertMedia?: boolean;
              replyMarkup?: ReplyMarkup;
          },
      ]

    Returns Promise<Message>

  • Re-send the confirmation code using a different type.

    The type of the code to be re-sent is specified in the nextType attribute of SentCode object returned by sendCode Available: 👤 users only

    Parameters

    • params: { abortSignal?: AbortSignal; phone: string; phoneCodeHash: string }
      • OptionalabortSignal?: AbortSignal

        Abort signal

      • phone: string

        Phone number in international format

      • phoneCodeHash: string

        Confirmation code identifier from SentCode

    Returns Promise<SentCode>

  • Resend the code to verify an email to use as 2FA recovery method. Available: 👤 users only

    Returns Promise<void>

  • Get the InputPeer of a known peer id. Useful when an InputPeer is needed in Raw API.

    Available: ✅ both users and bots

    Parameters

    • peerId: InputPeerLike

      The peer identifier that you want to extract the InputPeer from.

    • Optionalforce: boolean

      Whether to force re-fetch the peer from the server (only for usernames and phone numbers)

    Returns Promise<TypeInputPeer>

  • Restrict a user in a supergroup. Available: ✅ both users and bots

    Parameters

    • params: {
          chatId: InputPeerLike;
          restrictions: Omit<RawChatBannedRights, "_" | "untilDate">;
          until?: number | Date;
          userId: InputPeerLike;
      }
      • chatId: InputPeerLike

        Chat ID

      • restrictions: Omit<RawChatBannedRights, "_" | "untilDate">

        Restrictions for the user. Note that unlike Bot API, this object contains the restrictions, and not the permissions, i.e. passing sendMessages=true will disallow the user to send messages, and passing {} (empty object) will lift any restrictions

      • Optionaluntil?: number | Date

        Date when the user will be unrestricted. When number is passed, UNIX time in ms is expected. If this value is less than 30 seconds or more than 366 days in the future, user will be restricted forever.

        0, i.e. forever

      • userId: InputPeerLike

        User ID

    Returns Promise<void>

  • Revoke an invite link.

    If link is a primary invite link, a new invite link will be generated automatically by Telegram

    Available: ✅ both users and bots

    Parameters

    Returns Promise<ChatInviteLink>

    If link is a primary invite, newly generated invite link, otherwise the revoked link

  • Simple wrapper that calls start and then provided callback function (if any) without the need to introduce a main() function manually.

    Errors that were encountered while calling start and then will be emitted as usual, and can be caught with onError

    Available: ✅ both users and bots

    Parameters

    • params: {
          abortSignal?: AbortSignal;
          botToken?: MaybeDynamic<string>;
          code?: MaybeDynamic<string>;
          codeSentCallback?: (code: SentCode) => MaybePromise<void>;
          codeSettings?: Omit<RawCodeSettings, "_" | "logoutTokens">;
          forceSms?: boolean;
          futureAuthTokens?: Uint8Array[];
          invalidCodeCallback?: (type: "code" | "password") => MaybePromise<void>;
          password?: MaybeDynamic<string>;
          phone?: MaybeDynamic<string>;
          qrCodeHandler?: (url: string, expires: Date) => void;
          session?: string | InputStringSessionData;
          sessionForce?: boolean;
      }

      Parameters to be passed to start

      • OptionalabortSignal?: AbortSignal

        Abort signal

      • OptionalbotToken?: MaybeDynamic<string>

        Bot token to use. Ignored if phone is supplied.

      • Optionalcode?: MaybeDynamic<string>

        Code sent to the phone (either sms, call, flash call or other). Ignored if botToken is supplied, must be present if phone is supplied.

      • OptionalcodeSentCallback?: (code: SentCode) => MaybePromise<void>

        Custom method that is called when a code is sent. Can be used to show a GUI alert of some kind.

        This method is called before start.params.code.

        console.log.

      • OptionalcodeSettings?: Omit<RawCodeSettings, "_" | "logoutTokens">

        Additional code settings to pass to the server

      • OptionalforceSms?: boolean

        Whether to force code delivery through SMS

      • OptionalfutureAuthTokens?: Uint8Array[]

        Saved future auth tokens, if any

      • OptionalinvalidCodeCallback?: (type: "code" | "password") => MaybePromise<void>

        If passed, this function will be called if provided code or 2FA password was invalid. New code/password will be requested later.

        If provided code/password is a constant string, providing an invalid one will interrupt authorization flow.

      • Optionalpassword?: MaybeDynamic<string>

        2FA password. Ignored if botToken is supplied

      • Optionalphone?: MaybeDynamic<string>

        Phone number of the account. If account does not exist, it will be created

      • OptionalqrCodeHandler?: (url: string, expires: Date) => void

        When passed, QR login flow will be used instead of the regular login flow.

        This function will be called whenever the login URL is changed, and the app is expected to display it as a QR code to the user.

      • Optionalsession?: string | InputStringSessionData

        String session exported using TelegramClient.exportSession.

        This simply calls TelegramClient.importSession before anything else.

        Note that passed session will be ignored in case storage already contains authorization.

      • OptionalsessionForce?: boolean

        Whether to overwrite existing session.

    • Optionalthen: (user: User) => void | Promise<void>

      Function to be called after start returns

    Returns void

    This method provides no real value over start, please use it instead

  • Save or delete a draft message associated with some chat

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      ID of the chat, its username, phone or "me" or "self"

    • draft: null | Omit<RawDraftMessage, "_" | "date">

      Draft message, or null to delete.

    Returns Promise<void>

  • Search for messages globally from all of your chats

    Note: Due to Telegram limitations, you can only get up to ~10000 messages

    Available: 👤 users only

    Parameters

    • Optionalparams: {
          filter?: TypeMessagesFilter;
          limit?: number;
          maxDate?: number | Date;
          minDate?: number | Date;
          offset?: SearchGlobalOffset;
          onlyChannels?: boolean;
          query?: string;
      }

      Search parameters

      • Optionalfilter?: TypeMessagesFilter

        Filter the results using some filter. (see SearchFilters)

        SearchFilters.Empty (i.e. will return all messages)

      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        100
        
      • OptionalmaxDate?: number | Date

        Only return messages older than this date

      • OptionalminDate?: number | Date

        Only return messages newer than this date

      • Optionaloffset?: SearchGlobalOffset

        Offset data used for pagination

      • OptionalonlyChannels?: boolean

        Whether to only search across broadcast channels

      • Optionalquery?: string

        Text query string. Use "@" to search for mentions.

        "" (empty string)

    Returns Promise<ArrayPaginated<Message, SearchGlobalOffset>>

  • Search for messages inside a specific chat

    Available: 👤 users only

    Parameters

    • Optionalparams: {
          addOffset?: number;
          chatId?: InputPeerLike;
          filter?: TypeMessagesFilter;
          fromUser?: InputPeerLike;
          limit?: number;
          maxDate?: number | Date;
          maxId?: number;
          minDate?: number | Date;
          minId?: number;
          offset?: number;
          query?: string;
          threadId?: number;
      }

      Additional search parameters

      • OptionaladdOffset?: number

        Additional offset from offset, in resulting messages.

        This can be used for advanced use cases, like:

        • Loading 20 results newer than message with ID MSGID: offset = MSGID, addOffset = -20, limit = 20
        • Loading 20 results around message with ID MSGID: offset = MSGID, addOffset = -10, limit = 20

        When offset is not set, this will be relative to the last message

        0 (disabled)

      • OptionalchatId?: InputPeerLike

        Chat where to search for messages.

        When empty, will search across common message box (i.e. private messages and legacy chats)

      • Optionalfilter?: TypeMessagesFilter

        Filter the results using some filter (see SearchFilters)

        SearchFilters.Empty (i.e. will return all messages)

      • OptionalfromUser?: InputPeerLike

        Search only for messages sent by a specific user.

        You can pass their marked ID, username, phone or "me" or "self"

      • Optionallimit?: number

        Limits the number of messages to be retrieved.

        100
        
      • OptionalmaxDate?: number | Date

        Maximum message date to return

        0 (disabled).

      • OptionalmaxId?: number

        Maximum message ID to return.

        Unless addOffset is used, this will work the same as offset.

        0 (disabled).

      • OptionalminDate?: number | Date

        Minimum message date to return

        0 (disabled).

      • OptionalminId?: number

        Minimum message ID to return

        0 (disabled).

      • Optionaloffset?: number

        Offset ID for the search. Only messages earlier than this ID will be returned.

        0 (starting from the latest message).

      • Optionalquery?: string

        Text query string. Required for text-only messages, optional for media.

        "" (empty string)

      • OptionalthreadId?: number

        Thread ID to return only messages from this thread.

    Returns Promise<ArrayPaginated<Message, number>>

  • Send the confirmation code to the given phone number

    Available: 👤 users only

    Parameters

    • params: {
          abortSignal?: AbortSignal;
          codeSettings?: Omit<RawCodeSettings, "_" | "logoutTokens">;
          futureAuthTokens?: Uint8Array[];
          phone: string;
      }
      • OptionalabortSignal?: AbortSignal

        Abort signal

      • OptionalcodeSettings?: Omit<RawCodeSettings, "_" | "logoutTokens">

        Additional code settings to pass to the server

      • OptionalfutureAuthTokens?: Uint8Array[]

        Saved future auth tokens, if any

      • phone: string

        Phone number in international format

    Returns Promise<SentCode>

    An object containing information about the sent confirmation code

  • Copy a message (i.e. send the same message, but do not forward it).

    Note that if the message contains a webpage, it will be copied simply as a text message, and if the message contains an invoice, it can't be copied. Available: ✅ both users and bots

    Parameters

    Returns Promise<Message>

  • Copy a message group (i.e. send the same message group, but do not forward it).

    Note that all the provided messages must be in the same message group Available: ✅ both users and bots

    Parameters

    Returns Promise<Message[]>

  • Send a single media (a photo or a document-based media)

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      ID of the chat, its username, phone or "me" or "self"

    • media: string | InputMediaLike

      Media contained in the message. You can also pass TDLib and Bot API compatible File ID, which will be wrapped in InputMedia.auto

    • Optionalparams: CommonSendParams & {
          caption?: InputText;
          invert?: boolean;
          progressCallback?: (uploaded: number, total: number) => void;
          replyMarkup?: ReplyMarkup;
      }

      Additional sending parameters

      • Optionalcaption?: InputText

        Override caption for media.

        Can be used, for example. when using File IDs or when using existing InputMedia objects.

      • Optionalinvert?: boolean

        Whether to invert media position.

        Currently only supported for web previews and makes the client render the preview above the caption and not below.

      • OptionalprogressCallback?: (uploaded: number, total: number) => void

        Function that will be called after some part has been uploaded. Only used when a file that requires uploading is passed, and not used when uploading a thumbnail.

      • OptionalreplyMarkup?: ReplyMarkup

        For bots: inline or reply markup or an instruction to hide a reply keyboard or to force a reply.

    Returns Promise<Message>

  • Send a group of media.

    To add a caption to the group, add caption to the first media in the group and don't add caption for any other.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      ID of the chat, its username, phone or "me" or "self"

    • medias: (string | InputMediaLike)[]

      Medias contained in the message.

    • Optionalparams: CommonSendParams & {
          invertMedia?: boolean;
          progressCallback?: (index: number, uploaded: number, total: number) => void;
      }

      Additional sending parameters

      • OptionalinvertMedia?: boolean

        Whether to invert media position.

        Currently only supported for web previews and makes the client render the preview above the caption and not below.

      • OptionalprogressCallback?: (index: number, uploaded: number, total: number) => void

        Function that will be called after some part has been uploaded. Only used when a file that requires uploading is passed, and not used when uploading a thumbnail.

    Returns Promise<Message[]>

  • Change user status to offline or online once, which will expire after a while (currently ~5 minutes)

    For continuously sending online/offline status, use setOnline

    Available: 👤 users only

    Parameters

    • online: boolean

      Whether the user is currently online

    Returns Promise<void>

  • Send a paid reaction using Telegram Stars.

    Available: 👤 users only

    Parameters

    • params: InputMessageId & { anonymous?: boolean; count?: number; shouldDispatch?: true }
      • Optionalanonymous?: boolean

        Whether to send the reaction anonymously

      • Optionalcount?: number

        Number of reactions to send

        1
        
      • OptionalshouldDispatch?: true

        Whether to dispatch the returned edit message event to the client's update handler.

    Returns Promise<MessageReactions>

    Message to which the reaction was sent, if available. The message is normally available for users, but may not be available for bots in PMs.

  • Send or remove a reaction.

    Available: 👤 users only

    Parameters

    • params: InputMessageId & {
          big?: boolean;
          emoji?: MaybeArray<InputReaction> | null | undefined;
          shouldDispatch?: true;
      }
      • Optionalbig?: boolean

        Whether to use a big reaction

      • Optionalemoji?: MaybeArray<InputReaction> | null | undefined

        Reaction emoji (or null to remove reaction)

      • OptionalshouldDispatch?: true

        Whether to dispatch the returned edit message event to the client's update handler.

    Returns Promise<null | Message>

    Message to which the reaction was sent, if available. The message is normally available for users, but may not be available for bots in PMs.

  • Send a code to email needed to recover your password

    Available: 👤 users only

    Returns Promise<string>

    String containing email pattern to which the recovery code was sent

  • Send previously scheduled message(s)

    Note that if the message belongs to a media group, the entire group will be sent, and all the messages will be returned.

    Available: 👤 users only

    Parameters

    Returns Promise<Message[]>

  • Send a star gift to a user.

    Note: this method is not indended to be used by full-fledged clients, as this method hides the actual invoice and payment form from the user. For GUI clients, you should refer to the method's source code and present the payment form to the user.

    Available: 👤 users only

    Parameters

    • params: {
          anonymous?: boolean;
          gift: Long | StarGift;
          message?: InputText;
          shouldDispatch?: true;
          userId: InputPeerLike;
          withUpgrade?: boolean;
      }
      • Optionalanonymous?: boolean

        Whether to send the gift anonymously (i.e. if the recipient chooses to display the gift on their profile, your name won't be visible)

      • gift: Long | StarGift

        ID of the gift to send

      • Optionalmessage?: InputText

        Message to send along with the gift

      • OptionalshouldDispatch?: true

        Whether to dispatch the new message event to the client's update handler.

      • userId: InputPeerLike

        ID of the user to send the gift to

      • OptionalwithUpgrade?: boolean

        Whether to automatically upgrade the gift to a unique star gift

    Returns Promise<Message>

    Service message about the sent gift

  • Send a story

    Available: 👤 users only

    Parameters

    • params: {
          caption?: InputText;
          forbidForwards?: boolean;
          interactiveElements?: TypeMediaArea[];
          media: string | InputMediaLike;
          peer?: InputPeerLike;
          period?: number;
          pinned?: boolean;
          privacyRules?: InputPrivacyRule[];
      }
      • Optionalcaption?: InputText

        Override caption for media

      • OptionalforbidForwards?: boolean

        Whether to disallow sharing this story

      • OptionalinteractiveElements?: TypeMediaArea[]

        Interactive elements to add to the story

      • media: string | InputMediaLike

        Media contained in a story. Currently can only be a photo or a video.

        You can also pass TDLib and Bot API compatible File ID, which will be wrapped in InputMedia.auto

      • Optionalpeer?: InputPeerLike

        Peer ID to send story as

        self

      • Optionalperiod?: number

        TTL period of the story, in seconds

        86400
        
      • Optionalpinned?: boolean

        Whether to automatically pin this story to the profile

      • OptionalprivacyRules?: InputPrivacyRule[]

        Privacy rules to apply to the story

        "Everyone"
        

    Returns Promise<Story>

    Created story

  • Send (or remove) a reaction to a story Available: 👤 users only

    Parameters

    • params: {
          addToRecent?: boolean;
          peerId: InputPeerLike;
          reaction: InputReaction;
          storyId: number;
      }
      • OptionaladdToRecent?: boolean

        Whether to add this reaction to recently used

      • peerId: InputPeerLike
      • reaction: InputReaction
      • storyId: number

    Returns Promise<void>

  • Send a text message

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      ID of the chat, its username, phone or "me" or "self"

    • text: InputText

      Text of the message

    • Optionalparams: CommonSendParams & {
          disableWebPreview?: boolean;
          invertMedia?: boolean;
          replyMarkup?: ReplyMarkup;
      }

      Additional sending parameters

      • OptionaldisableWebPreview?: boolean

        Whether to disable links preview in this message

      • OptionalinvertMedia?: boolean

        Whether to invert media position.

        Currently only supported for web previews and makes the client render the preview above the caption and not below.

      • OptionalreplyMarkup?: ReplyMarkup

        For bots: inline or reply markup or an instruction to hide a reply keyboard or to force a reply.

    Returns Promise<Message>

  • Sends a current user/bot typing event to a conversation partner or group.

    This status is set for 6 seconds, and is automatically cancelled if you send a message.

    If you need a continuous typing status, use setTyping instead.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • Optionalstatus:
          | "contact"
          | "game"
          | "geo"
          | "sticker"
          | "typing"
          | "cancel"
          | "record_video"
          | "upload_video"
          | "record_voice"
          | "upload_voice"
          | "upload_photo"
          | "upload_document"
          | "record_round"
          | "upload_round"
          | "speak_call"
          | "history_import"
          | TypeSendMessageAction

      Typing status

    • Optionalparams: { businessConnectionId?: string; progress?: number; threadId?: number }
      • OptionalbusinessConnectionId?: string

        Unique identifier of the business connection on behalf of which the action will be sent

      • Optionalprogress?: number

        For upload_* and history import actions, progress of the upload

      • OptionalthreadId?: number

        For comment threads, ID of the thread (i.e. top message)

    Returns Promise<void>

  • Send or retract a vote in a poll. Available: 👤 users only

    Parameters

    • params: InputMessageId & { options: MaybeArray<number | Uint8Array> | null }
      • options: MaybeArray<number | Uint8Array> | null

        Selected options, or null to retract. You can pass indexes of the answers or the Buffers representing them. In case of indexes, the poll will first be requested from the server.

    Returns Promise<Poll>

  • Sets information about a bot the current uzer owns (or the current bot) Available: ✅ both users and bots

    Parameters

    • params: {
          bio?: string;
          bot?: InputPeerLike;
          description?: string;
          langCode?: string;
          name?: string;
      }
      • Optionalbio?: string

        New bio text (displayed in the profile)

      • Optionalbot?: InputPeerLike

        When called by a user, a bot the user owns must be specified. When called by a bot, must be empty

      • Optionaldescription?: string

        New description text (displayed when the chat is empty)

      • OptionallangCode?: string

        If passed, will update the bot's description in the given language. If left empty, will change the fallback description.

      • Optionalname?: string

        New bot name

    Returns Promise<void>

  • Set current user's business introduction.

    Available: 👤 users only

    Parameters

    • intro:
          | null
          | {
              description?: string;
              sticker?: TypeInputDocument
              | InputFileLike
              | InputMediaSticker;
              title?: string;
          }

      Introduction parameters, or null to remove

    Returns Promise<void>

  • Set current user's business work hours. Available: 👤 users only

    Parameters

    • params:
          | null
          | (
              { timezone: string; } & ({ hours: readonly BusinessWorkHoursDay[]; } | { intervals: RawBusinessWeeklyOpen[]; })
          )

    Returns Promise<void>

  • Set peer color and optionally background pattern Available: 👤 users only

    Parameters

    • params: {
          backgroundEmojiId?: Long;
          color: number;
          forProfile?: boolean;
          peer?: InputPeerLike;
      }
      • OptionalbackgroundEmojiId?: Long

        Background pattern emoji ID.

        Must be an adaptive emoji, otherwise the request will fail.

      • color: number

        Color identificator

        Note that this value is not an RGB color representation. Instead, it is a number which should be used to pick a color from a predefined list of colors:

        • 0-6 are the default colors used by Telegram clients: red, orange, purple, green, sea, blue, pink
        • >= 7 are returned by help.getAppConfig.
      • OptionalforProfile?: boolean

        Whether to set this color for the profile header instead of chat name/replies.

        Currently only available for the current user.

      • Optionalpeer?: InputPeerLike

        Peer where to update the color.

        By default will change the color for the current user

    Returns Promise<void>

  • Change default chat permissions for all members.

    You must be an administrator in the chat and have appropriate permissions.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • restrictions: Omit<RawChatBannedRights, "_" | "untilDate">

      Restrictions for the chat. Note that unlike Bot API, this object contains the restrictions, and not the permissions, i.e. passing sendMessages=true will disallow the users to send messages, and passing {} (empty object) will lift any restrictions

    Returns Promise<Chat>

  • Change chat description

    You must be an administrator and have the appropriate permissions.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • description: string

      New chat description, 0-255 characters

    Returns Promise<void>

  • Set a new chat photo or video.

    You must be an administrator and have the appropriate permissions. Available: ✅ both users and bots

    Parameters

    • params: {
          chatId: InputPeerLike;
          media: InputFileLike;
          previewSec?: number;
          type: "photo" | "video";
      }
      • chatId: InputPeerLike

        Chat ID or username

      • media: InputFileLike

        Input media file

      • OptionalpreviewSec?: number

        When type = video, timestamp in seconds which will be shown as a static preview.

      • type: "photo" | "video"

        Media type (photo or video)

    Returns Promise<void>

  • Change chat title

    You must be an administrator and have the appropriate permissions.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • title: string

      New chat title, 1-255 characters

    Returns Promise<void>

  • Set maximum Time-To-Live of all newly sent messages in the specified chat

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID

    • period: number

      New TTL period, in seconds (or 0 to disable)

    Returns Promise<void>

  • Change supergroup/channel username

    You must be an administrator and have the appropriate permissions.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID or current username

    • username: null | string

      New username, or null to remove

    Returns Promise<void>

  • Set an emoji status for the given user/chat

    You can change emoji status of:

    • yourself (self)
    • supergroups or channels with enough boosts which you are an admin of
    • for bots – users who gave you the appropriate permissions

    Parameters

    • params: { emoji: null | Long; peerId: InputPeerLike; until?: number | Date }
      • emoji: null | Long

        Custom emoji ID or null to remove the emoji

      • peerId: InputPeerLike

        User or chat where the emoji status should be set

      • Optionaluntil?: number | Date

        Date when the emoji status should expire (only if emoji is not null)

    Returns Promise<void>

  • Reorder folders

    Available: 👤 users only

    Parameters

    • order: number[]

      New order of folders (folder IDs, where default = 0)

    Returns Promise<void>

  • Set a score of a user in a game

    Available: 🤖 bots only

    Parameters

    • params: InputMessageId & {
          force?: boolean;
          noEdit?: boolean;
          score: number;
          shouldDispatch?: true;
          userId: InputPeerLike;
      }
      • Optionalforce?: boolean

        Whether to allow user's score to decrease. This can be useful when fixing mistakes or banning cheaters

      • OptionalnoEdit?: boolean

        When true, the game message will not be modified to include the new score

      • score: number

        The new score (must be >0)

      • OptionalshouldDispatch?: true

        Whether to dispatch the edit message event to the client's update handler.

      • userId: InputPeerLike

        ID of the user who has scored

    Returns Promise<Message>

    The modified message

  • Changes the current default value of the Time-To-Live setting, applied to all new chats.

    Available: 👤 users only

    Parameters

    • period: number

      New TTL period, in seconds (or 0 to disable)

    Returns Promise<void>

  • Set a score of a user in a game contained in an inline message

    Available: 🤖 bots only

    Parameters

    • params: {
          force?: boolean;
          messageId: string | TypeInputBotInlineMessageID;
          noEdit?: boolean;
          score: number;
          userId: InputPeerLike;
      }
      • Optionalforce?: boolean

        Whether to allow user's score to decrease. This can be useful when fixing mistakes or banning cheaters

      • messageId: string | TypeInputBotInlineMessageID

        ID of the inline message

      • OptionalnoEdit?: boolean

        When true, the game message will not be modified to include the new score

      • score: number

        The new score (must be >0)

      • userId: InputPeerLike

        ID of the user who has scored

    Returns Promise<void>

  • Set or remove current user's birthday. Available: 👤 users only

    Parameters

    • birthday: null | { day: number; month: number; year?: number }
      • null
      • { day: number; month: number; year?: number }
        • day: number

          Birthday day

        • month: number

          Birthday month

        • Optionalyear?: number

          Birthday year (optional)

    Returns Promise<void>

  • Sets the default chat permissions for the bot in the supergroup or channel. Available: 🤖 bots only

    Parameters

    • params: { rights: Omit<RawChatAdminRights, "_">; target: "channel" | "group" }
      • rights: Omit<RawChatAdminRights, "_">

        The default chat permissions.

      • target: "channel" | "group"

        Whether to target groups or channels.

    Returns Promise<void>

  • Set an emoji status for the current user

    Available: ✅ both users and bots

    Parameters

    • emoji: null | Long
    • Optionalparams: { until?: number | Date }
      • Optionaluntil?: number | Date

        Date when the emoji status should expire (only if emoji is not null)

    Returns Promise<void>

    – use setEmojiStatus with self instead

  • Set a new profile photo or video for the current user.

    You can also pass a file ID or an InputPhoto to re-use existing photo. Available: ✅ both users and bots

    Parameters

    • params: {
          media: TypeInputPhoto | InputFileLike;
          previewSec?: number;
          type: "photo" | "video";
      }
      • media: TypeInputPhoto | InputFileLike

        Input media file

      • OptionalpreviewSec?: number

        When type = video, timestamp in seconds which will be shown as a static preview.

      • type: "photo" | "video"

        Media type (photo or video)

    Returns Promise<Photo>

  • Change username of the current user.

    Note that bots usernames must be changed through bot support or re-created from scratch.

    Available: 👤 users only

    Parameters

    • username: null | string

      New username (5-32 chars, allowed chars: a-zA-Z0-9_), or null to remove

    Returns Promise<User>

  • Change user status to online or offline

    Once called with true, mtcute will keep notifying the server that the user is still online until a further call with false is made.

    Available: 👤 users only

    Parameters

    • Optionalonline: boolean

    Returns Promise<void>

  • Set supergroup's slow mode interval.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • Optionalseconds: number

      Slow mode interval in seconds. Users will be able to send a message only once per this interval. Valid values are: 0 (off), 10, 30, 60 (1m), 300 (5m), 900 (15m) or 3600 (1h)

    Returns Promise<void>

  • Set sticker set thumbnail

    Available: ✅ both users and bots

    Parameters

    • id: InputStickerSet

      Sticker set short name or a TL object with input sticker set

    • thumb: TypeInputDocument | InputFileLike

      Sticker set thumbnail

    • Optionalparams: { progressCallback?: (uploaded: number, total: number) => void }
      • OptionalprogressCallback?: (uploaded: number, total: number) => void

        Upload progress callback

    Returns Promise<StickerSet>

    Modified sticker set

  • Sets whether a user is typing in a specific chat

    This status is automatically renewed by mtcute until a further call with cancel is made, or a message is sent to the chat. Available: ✅ both users and bots

    Parameters

    • params: {
          businessConnectionId?: string;
          peerId: InputPeerLike;
          progress?: number;
          status?:
              | "contact"
              | "game"
              | "geo"
              | "sticker"
              | "typing"
              | "cancel"
              | "record_video"
              | "upload_video"
              | "record_voice"
              | "upload_voice"
              | "upload_photo"
              | "upload_document"
              | "record_round"
              | "upload_round"
              | "speak_call"
              | "history_import"
              | TypeSendMessageAction;
          threadId?: number;
      }
      • OptionalbusinessConnectionId?: string

        Unique identifier of the business connection on behalf of which the action will be sent

      • peerId: InputPeerLike

        Chat ID where the user is currently typing

      • Optionalprogress?: number

        For upload_* and history import actions, progress of the upload

      • Optionalstatus?:
            | "contact"
            | "game"
            | "geo"
            | "sticker"
            | "typing"
            | "cancel"
            | "record_video"
            | "upload_video"
            | "record_voice"
            | "upload_voice"
            | "upload_photo"
            | "upload_document"
            | "record_round"
            | "upload_round"
            | "speak_call"
            | "history_import"
            | TypeSendMessageAction

        Typing status to send

        typing

      • OptionalthreadId?: number

        For comment threads, ID of the thread (i.e. top message)

    Returns Promise<void>

  • Authorize a user in Telegram with a valid confirmation code.

    Available: 👤 users only

    Parameters

    • params: {
          abortSignal?: AbortSignal;
          phone: string;
          phoneCode: string;
          phoneCodeHash: string;
      }
      • OptionalabortSignal?: AbortSignal

        Abort signal

      • phone: string

        Phone number in international format

      • phoneCode: string

        The confirmation code that was received

      • phoneCodeHash: string

        Code identifier from sendCode

    Returns Promise<User>

    If the code was valid and authorization succeeded, the User is returned.

    BadRequestError In case the arguments are invalid

    SessionPasswordNeededError In case a password is needed to sign in

  • Authorize a bot using its token issued by @BotFather

    Available: ✅ both users and bots

    Parameters

    • token: string

      Bot token issued by BotFather

    Returns Promise<User>

    Bot's User object

    BadRequestError In case the bot token is invalid

  • Execute the QR login flow.

    This method will resolve once the authorization is complete, returning the authorized user. Available: 👤 users only

    Parameters

    • params: {
          abortSignal?: AbortSignal;
          invalidPasswordCallback?: () => MaybePromise<void>;
          onQrScanned?: () => void;
          onUrlUpdated: (url: string, expires: Date) => void;
          password?: MaybeDynamic<string>;
      }
      • OptionalabortSignal?: AbortSignal

        Abort signal

      • OptionalinvalidPasswordCallback?: () => MaybePromise<void>

        Function that will be called after the server has rejected the password.

        Note that in case password is not a function, this callback will never be called, and an error will be thrown instead.

      • OptionalonQrScanned?: () => void

        Function that will be called when the user has scanned the QR code (i.e. when updateLoginToken is received), and the library is finalizing the auth

      • onUrlUpdated: (url: string, expires: Date) => void

        Function that will be called whenever the login URL is changed.

        The app is expected to display url as a QR code to the user

      • Optionalpassword?: MaybeDynamic<string>

        Password for 2FA

    Returns Promise<User>

  • Start the client in an interactive and declarative manner, by providing callbacks for authorization details.

    This method handles both login and sign up, and also handles 2FV

    All parameters are MaybeDynamic<T>, meaning you can either supply T, or a function that returns MaybePromise<T>

    This method is intended for simple and fast use in automated scripts and bots. If you are developing a custom client, you'll probably need to use other auth methods. Available: ✅ both users and bots

    Parameters

    • params: {
          abortSignal?: AbortSignal;
          botToken?: MaybeDynamic<string>;
          code?: MaybeDynamic<string>;
          codeSentCallback?: (code: SentCode) => MaybePromise<void>;
          codeSettings?: Omit<RawCodeSettings, "_" | "logoutTokens">;
          forceSms?: boolean;
          futureAuthTokens?: Uint8Array[];
          invalidCodeCallback?: (type: "code" | "password") => MaybePromise<void>;
          password?: MaybeDynamic<string>;
          phone?: MaybeDynamic<string>;
          qrCodeHandler?: (url: string, expires: Date) => void;
          session?: string | InputStringSessionData;
          sessionForce?: boolean;
      }
      • OptionalabortSignal?: AbortSignal

        Abort signal

      • OptionalbotToken?: MaybeDynamic<string>

        Bot token to use. Ignored if phone is supplied.

      • Optionalcode?: MaybeDynamic<string>

        Code sent to the phone (either sms, call, flash call or other). Ignored if botToken is supplied, must be present if phone is supplied.

      • OptionalcodeSentCallback?: (code: SentCode) => MaybePromise<void>

        Custom method that is called when a code is sent. Can be used to show a GUI alert of some kind.

        This method is called before start.params.code.

        console.log.

      • OptionalcodeSettings?: Omit<RawCodeSettings, "_" | "logoutTokens">

        Additional code settings to pass to the server

      • OptionalforceSms?: boolean

        Whether to force code delivery through SMS

      • OptionalfutureAuthTokens?: Uint8Array[]

        Saved future auth tokens, if any

      • OptionalinvalidCodeCallback?: (type: "code" | "password") => MaybePromise<void>

        If passed, this function will be called if provided code or 2FA password was invalid. New code/password will be requested later.

        If provided code/password is a constant string, providing an invalid one will interrupt authorization flow.

      • Optionalpassword?: MaybeDynamic<string>

        2FA password. Ignored if botToken is supplied

      • Optionalphone?: MaybeDynamic<string>

        Phone number of the account. If account does not exist, it will be created

      • OptionalqrCodeHandler?: (url: string, expires: Date) => void

        When passed, QR login flow will be used instead of the regular login flow.

        This function will be called whenever the login URL is changed, and the app is expected to display it as a QR code to the user.

      • Optionalsession?: string | InputStringSessionData

        String session exported using TelegramClient.exportSession.

        This simply calls TelegramClient.importSession before anything else.

        Note that passed session will be ignored in case storage already contains authorization.

      • OptionalsessionForce?: boolean

        Whether to overwrite existing session.

    Returns Promise<User>

  • Utility function to quickly authorize on test DC using a Test phone number, which is randomly generated by default.

    Note: Using this method assumes that you are using a test DC in primaryDc parameter.

    Available: ✅ both users and bots

    Parameters

    • Optionalparams: { dcId?: number; logout?: boolean; phone?: string }

      Additional parameters

      • OptionaldcId?: number

        Override user's DC. Must be a valid test DC.

      • Optionallogout?: boolean

        Whether to log out if current session is logged in.

        false.
        
      • Optionalphone?: string

        Override phone number. Must be a valid Test phone number.

        By default is randomly generated.

    Returns Promise<User>

  • Returns Promise<void>

  • Returns Promise<void>

  • Set whether a chat has content protection (i.e. forwarding messages is disabled)

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • Optionalenabled: boolean

      Whether content protection should be enabled

    Returns Promise<void>

  • Give or revoke permission for a bot to update emoji status for your account Available: 👤 users only

    Parameters

    • params: { allow: boolean; userId: InputPeerLike }
      • allow: boolean

        Whether to grant or revoke permission

      • userId: InputPeerLike

        Bot to which the permission should be granted/revoked

    Returns Promise<void>

  • Set whether a supergroup is a forum.

    Only owner of the supergroup can change this setting.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • Optionalenabled: boolean

      Whether the supergroup should be a forum

    Returns Promise<void>

  • Toggle open/close status of a topic in a forum

    Only admins with manageTopics permission can do this.

    Available: ✅ both users and bots

    Parameters

    • parmas: {
          chatId: InputPeerLike;
          closed: boolean;
          shouldDispatch?: true;
          topicId: number | ForumTopic;
      }
      • chatId: InputPeerLike

        Chat ID or username

      • closed: boolean

        Whether the topic should be closed

      • OptionalshouldDispatch?: true

        Whether to dispatch the returned service message (if any) to the client's update handler.

      • topicId: number | ForumTopic

        ID of the topic (i.e. its top message ID)

    Returns Promise<Message>

    Service message about the modification

  • Toggle whether a topic in a forum is pinned

    Only admins with manageTopics permission can do this. Available: 👤 users only

    Parameters

    • params: { chatId: InputPeerLike; pinned: boolean; topicId: number | ForumTopic }
      • chatId: InputPeerLike

        Chat ID or username

      • pinned: boolean

        Whether the topic should be pinned

      • topicId: number | ForumTopic

        ID of the topic (i.e. its top message ID)

    Returns Promise<void>

  • Toggle a collectible (Fragment) username

    Note: non-collectible usernames must still be changed using setUsername/setChatUsername Available: 👤 users only

    Parameters

    • params: { active: boolean; peerId: InputPeerLike; username: string }
      • active: boolean

        Whether to enable or disable the username

      • peerId: InputPeerLike

        Peer ID whose username to toggle

      • username: string

        Username to toggle

    Returns Promise<void>

  • Toggle whether "General" topic in a forum is hidden or not

    Only admins with manageTopics permission can do this.

    Available: ✅ both users and bots

    Parameters

    • params: { chatId: InputPeerLike; hidden: boolean; shouldDispatch?: true }
      • chatId: InputPeerLike

        Chat ID or username

      • hidden: boolean

        Whether the topic should be hidden

      • OptionalshouldDispatch?: true

        Whether to dispatch the returned service message (if any) to the client's update handler.

    Returns Promise<Message>

    Service message about the modification

  • Set whether a channel/supergroup has join requests enabled.

    Note: this method only affects primary invite links. Additional invite links may exist with the opposite setting.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • Optionalenabled: boolean

      Whether join requests should be enabled

    Returns Promise<void>

  • Set whether a channel/supergroup has join-to-send setting enabled.

    This only affects discussion groups where users can send messages without joining the group.

    Available: 👤 users only

    Parameters

    • chatId: InputPeerLike

      Chat ID or username

    • Optionalenabled: boolean

      Whether join-to-send setting should be enabled

    Returns Promise<void>

  • Toggle whether peer's stories are archived (hidden) or not.

    This does not archive the chat with that peer, only stories. Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Toggle one or more stories pinned status

    Available: 👤 users only

    Parameters

    • params: { ids: MaybeArray<number>; peer?: InputPeerLike; pinned: boolean }
      • ids: MaybeArray<number>

        Story ID(s) to toggle

      • Optionalpeer?: InputPeerLike

        Peer ID whose stories to toggle

        self

      • pinned: boolean

        Whether to pin or unpin the story

    Returns Promise<number[]>

    IDs of stories that were toggled

  • Transfer a unique star gift.

    Note: this method is not indended to be used by full-fledged clients, as this method hides the actual invoice and payment form from the user. For GUI clients, you should refer to the method's source code and present the payment form to the user.

    Available: 👤 users only

    Parameters

    • params: { message: number | Message; recepient: InputPeerLike; shouldDispatch?: true }
      • message: number | Message

        ID of the message containing the gift

      • recepient: InputPeerLike

        ID of the user to transfer the gift to

      • OptionalshouldDispatch?: true

        Whether to dispatch the new message event to the client's update handler.

    Returns Promise<Message>

    Service message about the transferred gift

  • Translate message text to a given language.

    Returns null if it could not translate the message. Available: 👤 users only

    Parameters

    • params: InputMessageId & { toLanguage: string }
      • toLanguage: string

        Target language (two-letter ISO 639-1 language code)

    Returns Promise<TextWithEntities>

  • Translate text to a given language.

    Available: 👤 users only

    Parameters

    • text: InputText

      Text to translate

    • toLanguage: string

      Target language (two-letter ISO 639-1 language code)

    Returns Promise<TextWithEntities>

  • Unban a user/channel from a supergroup or a channel, or remove any restrictions that they have. Unbanning does not add the user back to the chat, this just allows the user to join the chat again, if they want.

    This method acts as a no-op in case a legacy group is passed. Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Unblock a user

    Available: 👤 users only

    Parameters

    Returns Promise<void>

  • Unpin all pinned messages in a chat.

    Available: ✅ both users and bots

    Parameters

    • chatId: InputPeerLike

      Chat or user ID

    • Optionalparams: { shouldDispatch?: true; topicId?: number }
      • OptionalshouldDispatch?: true

        Whether to dispatch updates that will be generated by this call. Doesn't follow disableNoDispatch

      • OptionaltopicId?: number

        For forums - unpin only messages from the given topic

    Returns Promise<void>

  • Unpin a message in a group, supergroup, channel or PM.

    For supergroups/channels, you must have appropriate permissions, either as an admin, or as default permissions

    Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Unban a user/channel from a supergroup or a channel, or remove any restrictions that they have. Unbanning does not add the user back to the chat, this just allows the user to join the chat again, if they want.

    This method acts as a no-op in case a legacy group is passed. Available: ✅ both users and bots

    Parameters

    Returns Promise<void>

  • Update your profile details.

    Only pass fields that you want to change.

    Available: 👤 users only

    Parameters

    • params: { bio?: string; firstName?: string; lastName?: string }
      • Optionalbio?: string

        New bio (max 70 chars). Pass '' (empty string) to remove it

      • OptionalfirstName?: string

        New first name

      • OptionallastName?: string

        New last name. Pass '' (empty string) to remove it

    Returns Promise<User>

  • Upgrades a star gift to a unique gift.

    Note: this method is not indended to be used by full-fledged clients, as this method hides the actual invoice and payment form from the user. For GUI clients, you should refer to the method's source code and present the payment form to the user.

    Available: 👤 users only

    Parameters

    • params: {
          keepOriginalDetails?: boolean;
          message: number | Message;
          shouldDispatch?: true;
      }
      • OptionalkeepOriginalDetails?: boolean

        Whether to retain the original details of the gift (like sender, recipient, date, message)

      • message: number | Message

        ID of the message containing the gift

      • OptionalshouldDispatch?: true

        Whether to dispatch the new message event to the client's update handler.

    Returns Promise<Message>

    Service message about the upgraded gift

  • Upload a file to Telegram servers, without actually sending a message anywhere. Useful when an InputFile is required.

    This method is quite low-level, and you should use other methods like sendMedia that handle this under the hood.

    Available: ✅ both users and bots

    Parameters

    • params: {
          estimatedSize?: number;
          file: UploadFileLike;
          fileMime?: string;
          fileName?: string;
          fileSize?: number;
          partSize?: number;
          progressCallback?: (uploaded: number, total: number) => void;
          requestsPerConnection?: number;
          requireExtension?: boolean;
          requireFileSize?: boolean;
      }

      Upload parameters

      • OptionalestimatedSize?: number

        If the file size is unknown, you can provide an estimate, which will be used to determine appropriate part size.

      • file: UploadFileLike

        Upload file source.

      • OptionalfileMime?: string

        File MIME type. By default is automatically inferred from magic number If MIME can't be inferred, it defaults to application/octet-stream

      • OptionalfileName?: string

        File name for the uploaded file. Is usually inferred from path, but should be provided for files sent as Buffer or stream.

        When file name can't be inferred, it falls back to "unnamed"

      • OptionalfileSize?: number

        Total file size. Automatically inferred for Buffer, File and local files.

      • OptionalpartSize?: number

        Upload part size (in KB).

        By default, automatically selected by file size. Must not be bigger than 512 and must not be a fraction.

      • OptionalprogressCallback?: (uploaded: number, total: number) => void

        Function that will be called after some part has been uploaded.

      • OptionalrequestsPerConnection?: number

        Number of parts to be sent in parallel per connection.

      • OptionalrequireExtension?: boolean

        When using inputMediaUploadedPhoto (e.g. when sending an uploaded photo) require the file extension to be known beforehand.

        This will make the library try to guess the file extension from the file mime type, or throw an error if it cannot be guessed.

      • OptionalrequireFileSize?: boolean

        When using inputMediaUploadedPhoto (e.g. when sending an uploaded photo) require the file size to be known beforehand.

        In case this is set to true, a stream is passed as file and the file size is unknown, the stream will be buffered in memory and the file size will be inferred from the buffer.

    Returns Promise<UploadedFile>

  • Upload a media to Telegram servers, without actually sending a message anywhere. Useful when File ID is needed.

    The difference with uploadFile is that the returned object will act like a message media and contain fields like File ID.

    Available: ✅ both users and bots

    Parameters

    • media: InputMediaLike

      Media to upload

    • Optionalparams: {
          peer?: InputPeerLike;
          progressCallback?: (uploaded: number, total: number) => void;
      }

      Upload parameters

    Returns Promise<Document | Video | Audio | Sticker | Voice | Photo>

  • Verify an email to use as 2FA recovery method

    Available: 👤 users only

    Parameters

    • code: string

      Code which was sent via email

    Returns Promise<void>

  • Wrap this client so that all RPC calls will use the specified parameters.

    Parameters

    Returns this

    Wrapped client

  • Wrap this client so that all RPC calls will use the specified parameters.

    Parameters

    Returns this

    Wrapped client