BotAPI:: Library Functions
This page provides a comprehensive reference for the BotAPI library, detailing all available methods for interacting with the Telegram Bot API.
BotAPI::sendPhoto
BotAPI::sendPhoto($params) Description: Sends a photo to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the photo to.photo(string) – URL or file path of the photo.caption(string, optional) – Photo caption.parse_mode(string, optional) – Format of the caption ("HTML" or "Markdown").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendPhoto([
'chat_id' => $chatId,
'photo' => 'https://example.com/photo.jpg',
'caption' => 'A beautiful sunset!',
'parse_mode' => 'HTML'
]);BotAPI::sendVideo
BotAPI::sendVideo($params) Description: Sends a video to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the video to.video(string) – URL or file path of the video.caption(string, optional) – Video caption.parse_mode(string, optional) – Format of the caption ("HTML" or "Markdown").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendAudio
BotAPI::sendAudio($params) Description: Sends an audio file to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the audio to.audio(string) – URL or file path of the audio file.caption(string, optional) – Audio caption.parse_mode(string, optional) – Format of the caption ("HTML" or "Markdown").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendDocument
BotAPI::sendDocument($params) Description: Sends a document to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the document to.document(string) – URL or file path of the document.caption(string, optional) – Document caption.parse_mode(string, optional) – Format of the caption ("HTML" or "Markdown").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendSticker
BotAPI::sendSticker($params) Description: Sends a sticker to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the sticker to.sticker(string) – URL or file ID of the sticker.reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendVoice
BotAPI::sendVoice($params) Description: Sends a voice message to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the voice message to.voice(string) – URL or file path of the voice file.caption(string, optional) – Voice message caption.parse_mode(string, optional) – Format of the caption ("HTML" or "Markdown").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendVideoNote
BotAPI::sendVideoNote($params) Description: Sends a video note to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the video note to.video_note(string) – URL or file path of the video note.reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendMediaGroup
BotAPI::sendMediaGroup($params) Description: Sends a group of media (photos or videos) to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the media group to.media(array) – Array of media objects (photos or videos).reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendLocation
BotAPI::sendLocation($params) Description: Sends a location to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the location to.latitude(float) – Latitude of the location.longitude(float) – Longitude of the location.reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendVenue
BotAPI::sendVenue($params) Description: Sends a venue to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the venue to.latitude(float) – Latitude of the venue.longitude(float) – Longitude of the venue.title(string) – Name of the venue.address(string) – Address of the venue.reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendContact
BotAPI::sendContact($params) Description: Sends a contact to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the contact to.phone_number(string) – Phone number of the contact.first_name(string) – First name of the contact.last_name(string, optional) – Last name of the contact.reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendPoll
BotAPI::sendPoll($params) Description: Sends a poll to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the poll to.question(string) – Poll question.options(array) – Array of answer options.is_anonymous(bool, optional) – Whether the poll is anonymous.type(string, optional) – Poll type ("quiz" or "regular").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendDice
BotAPI::sendDice($params) Description: Sends a dice animation to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the dice to.emoji(string, optional) – Emoji for the dice (e.g., 🎲).reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::sendChatAction
BotAPI::sendChatAction($params) Description: Sends a chat action (e.g., "typing") to indicate bot activity. Parameters:
chat_id(int|string) – The Telegram chat ID.action(string) – Action type (e.g., "typing", "upload_photo"). Example:
BotAPI::getUserProfilePhotos
BotAPI::getUserProfilePhotos($params) Description: Retrieves profile photos of a user. Parameters:
user_id(int) – The Telegram user ID.offset(int, optional) – Offset for pagination.limit(int, optional) – Number of photos to retrieve. Example:
BotAPI::getChatInfo
BotAPI::getChatInfo($chatId) Description: Retrieves information about a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID. Example:
BotAPI::banChatMember
BotAPI::banChatMember($params) Description: Bans a member from a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.user_id(int) – The user ID to ban.until_date(int, optional) – Unix timestamp for ban expiration.revoke_messages(bool, optional) – Whether to delete the user’s messages. Example:
BotAPI::unbanChatMember
BotAPI::unbanChatMember($params) Description: Unbans a member from a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.user_id(int) – The user ID to unban.only_if_banned(bool, optional) – Unban only if the user is banned. Example:
BotAPI::restrictChatMember
BotAPI::restrictChatMember($params) Description: Restricts a member’s permissions in a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.user_id(int) – The user ID to restrict.permissions(array) – Permissions to allow or restrict.until_date(int, optional) – Unix timestamp for restriction expiration. Example:
BotAPI::promoteChatMember
BotAPI::promoteChatMember($params) Description: Promotes a member to administrator in a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.user_id(int) – The user ID to promote.can_change_info(bool, optional) – Allow changing chat info.can_post_messages(bool, optional) – Allow posting messages. Example:
BotAPI::setChatAdministratorCustomTitle
BotAPI::setChatAdministratorCustomTitle($params) Description: Sets a custom title for an administrator in a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.user_id(int) – The administrator’s user ID.custom_title(string) – Custom title for the administrator. Example:
BotAPI::answerCallbackQuery
BotAPI::answerCallbackQuery($params) Description: Responds to a callback query from an inline button. Parameters:
callback_query_id(string) – The callback query ID.text(string, optional) – Notification text.show_alert(bool, optional) – Show an alert instead of a notification.url(string, optional) – URL to open.cache_time(int, optional) – Cache duration for the result. Example:
BotAPI::editMessageText
BotAPI::editMessageText($params) Description: Edits the text of a previously sent message. Parameters:
chat_id(int|string) – The Telegram chat ID.message_id(int) – The message ID to edit.text(string) – New message text.parse_mode(string, optional) – Format of the text ("HTML" or "Markdown").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::deleteMessage
BotAPI::deleteMessage($params) Description: Deletes a message from a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.message_id(int) – The message ID to delete. Example:
BotAPI::sendMessage
BotAPI::sendMessage($params) Description: Sends a text message to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the message to.text(string) – The message text.parse_mode(string, optional) – Format of the message ("HTML" or "Markdown").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::forwardMessage
BotAPI::forwardMessage($params) Description: Forwards a message from one chat to another. Parameters:
chat_id(int|string) – The Telegram chat ID to forward the message to.from_chat_id(int|string) – The chat ID of the original message.message_id(int) – The message ID to forward. Example:
BotAPI::copyMessage
BotAPI::copyMessage($params) Description: Copies a message to another chat. Parameters:
chat_id(int|string) – The Telegram chat ID to copy the message to.from_chat_id(int|string) – The chat ID of the original message.message_id(int) – The message ID to copy.caption(string, optional) – New caption for the copied message.parse_mode(string, optional) – Format of the caption ("HTML" or "Markdown"). Example:
BotAPI::sendAnimation
BotAPI::sendAnimation($params) Description: Sends an animation (GIF) to a specified Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID to send the animation to.animation(string) – URL or file path of the animation.caption(string, optional) – Animation caption.parse_mode(string, optional) – Format of the caption ("HTML" or "Markdown").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::setChatPermissions
BotAPI::setChatPermissions($params) Description: Sets default permissions for a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.permissions(array) – Permissions to set (e.g., can_send_messages, can_send_media). Example:
BotAPI::exportChatInviteLink
BotAPI::exportChatInviteLink($params) Description: Generates a new invite link for a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID. Example:
BotAPI::createChatInviteLink
BotAPI::createChatInviteLink($params) Description: Creates a custom invite link for a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.name(string, optional) – Name of the invite link.expire_date(int, optional) – Unix timestamp for link expiration.member_limit(int, optional) – Maximum number of users that can join. Example:
BotAPI::editChatInviteLink
BotAPI::editChatInviteLink($params) Description: Edits an existing invite link for a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.invite_link(string) – The invite link to edit.name(string, optional) – New name for the invite link.expire_date(int, optional) – New expiration timestamp. Example:
BotAPI::revokeChatInviteLink
BotAPI::revokeChatInviteLink($params) Description: Revokes an invite link for a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.invite_link(string) – The invite link to revoke. Example:
BotAPI::approveChatJoinRequest
BotAPI::approveChatJoinRequest($params) Description: Approves a chat join request. Parameters:
chat_id(int|string) – The Telegram chat ID.user_id(int) – The user ID to approve. Example:
BotAPI::declineChatJoinRequest
BotAPI::declineChatJoinRequest($params) Description: Declines a chat join request. Parameters:
chat_id(int|string) – The Telegram chat ID.user_id(int) – The user ID to decline. Example:
BotAPI::setChatPhoto
BotAPI::setChatPhoto($params) Description: Sets a profile photo for a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.photo(string) – URL or file path of the photo. Example:
BotAPI::deleteChatPhoto
BotAPI::deleteChatPhoto($params) Description: Deletes a Telegram chat’s profile photo. Parameters:
chat_id(int|string) – The Telegram chat ID. Example:
BotAPI::setChatTitle
BotAPI::setChatTitle($params) Description: Changes the title of a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.title(string) – New title for the chat. Example:
BotAPI::setChatDescription
BotAPI::setChatDescription($params) Description: Changes the description of a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.description(string) – New description for the chat. Example:
BotAPI::pinChatMessage
BotAPI::pinChatMessage($params) Description: Pins a message in a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.message_id(int) – The message ID to pin.disable_notification(bool, optional) – Disable notification for the pinned message. Example:
BotAPI::unpinChatMessage
BotAPI::unpinChatMessage($params) Description: Unpins a specific pinned message in a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.message_id(int) – The message ID to unpin. Example:
BotAPI::unpinAllChatMessages
BotAPI::unpinAllChatMessages($params) Description: Unpins all pinned messages in a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID. Example:
BotAPI::leaveChat
BotAPI::leaveChat($params) Description: Makes the bot leave a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID. Example:
BotAPI::answerInlineQuery
BotAPI::answerInlineQuery($params) Description: Responds to an inline query with results. Parameters:
inline_query_id(string) – The inline query ID.results(array) – Array of results to send.cache_time(int, optional) – Cache duration for the results. Example:
BotAPI::setMyCommands
BotAPI::setMyCommands($params) Description: Sets the bot’s command list. Parameters:
commands(array) – Array of bot commands.scope(array, optional) – Scope of users for the commands.language_code(string, optional) – Language code for the commands. Example:
BotAPI::deleteMyCommands
BotAPI::deleteMyCommands($params) Description: Deletes the bot’s command list. Parameters:
scope(array, optional) – Scope of users for the commands.language_code(string, optional) – Language code for the commands. Example:
BotAPI::getMyCommands
BotAPI::getMyCommands($params) Description: Retrieves the bot’s current command list. Parameters:
scope(array, optional) – Scope of users for the commands.language_code(string, optional) – Language code for the commands. Example:
BotAPI::editMessageCaption
BotAPI::editMessageCaption($params) Description: Edits the caption of a previously sent message. Parameters:
chat_id(int|string) – The Telegram chat ID.message_id(int) – The message ID to edit.caption(string) – New caption text.parse_mode(string, optional) – Format of the caption ("HTML" or "Markdown").reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::editMessageMedia
BotAPI::editMessageMedia($params) Description: Edits the media content of a previously sent message. Parameters:
chat_id(int|string) – The Telegram chat ID.message_id(int) – The message ID to edit.media(array) – New media object (photo, video, etc.).reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::editMessageReplyMarkup
BotAPI::editMessageReplyMarkup($params) Description: Edits the reply markup of a previously sent message. Parameters:
chat_id(int|string) – The Telegram chat ID.message_id(int) – The message ID to edit.reply_markup(array, optional) – New inline or custom keyboard markup. Example:
BotAPI::sendInvoice
BotAPI::sendInvoice($params) Description: Sends an invoice for payment. Parameters:
chat_id(int|string) – The Telegram chat ID.title(string) – Product title.description(string) – Product description.payload(string) – Bot-defined invoice payload.provider_token(string) – Payment provider token.currency(string) – Currency code (e.g., USD).prices(array) – Array of price components. Example:
BotAPI::answerShippingQuery
BotAPI::answerShippingQuery($params) Description: Responds to a shipping query. Parameters:
shipping_query_id(string) – The shipping query ID.ok(bool) – Whether the shipping is available.shipping_options(array, optional) – Available shipping options.error_message(string, optional) – Error message if not available. Example:
BotAPI::answerPreCheckoutQuery
BotAPI::answerPreCheckoutQuery($params) Description: Responds to a pre-checkout query. Parameters:
pre_checkout_query_id(string) – The pre-checkout query ID.ok(bool) – Whether the checkout is approved.error_message(string, optional) – Error message if not approved. Example:
BotAPI::sendGame
BotAPI::sendGame($params) Description: Sends a game to a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID.game_short_name(string) – Short name of the game.reply_markup(array, optional) – Inline or custom keyboard markup. Example:
BotAPI::setGameScore
BotAPI::setGameScore($params) Description: Sets a user’s score in a game. Parameters:
user_id(int) – The user ID.score(int) – The score to set.chat_id(int|string, optional) – The Telegram chat ID.message_id(int, optional) – The message ID of the game. Example:
BotAPI::getGameHighScores
BotAPI::getGameHighScores($params) Description: Retrieves high scores for a game. Parameters:
user_id(int) – The user ID.chat_id(int|string, optional) – The Telegram chat ID.message_id(int, optional) – The message ID of the game. Example:
BotAPI::setWebhook
BotAPI::setWebhook($params) Description: Sets a webhook for receiving Telegram updates. Parameters:
url(string) – HTTPS URL to send updates to.certificate(string, optional) – Public key certificate.max_connections(int, optional) – Maximum allowed connections.allowed_updates(array, optional) – Types of updates to receive. Example:
BotAPI::deleteWebhook
BotAPI::deleteWebhook($params) Description: Deletes the webhook, reverting to polling. Parameters:
drop_pending_updates(bool, optional) – Drop all pending updates. Example:
BotAPI::getWebhookInfo
BotAPI::getWebhookInfo($params) Description: Retrieves information about the current webhook. Parameters: None Example:
BotAPI::getUpdates
BotAPI::getUpdates($params) Description: Retrieves updates via polling. Parameters:
offset(int, optional) – Identifier of the first update to retrieve.limit(int, optional) – Number of updates to retrieve.timeout(int, optional) – Timeout in seconds for long polling.allowed_updates(array, optional) – Types of updates to receive. Example:
BotAPI::getMe
BotAPI::getMe($params) Description: Retrieves information about the bot itself. Parameters: None Example:
BotAPI::logOut
BotAPI::logOut($params) Description: Logs out the bot from the cloud Bot API server. Parameters: None Example:
BotAPI::close
BotAPI::close($params) Description: Closes the bot instance. Parameters: None Example:
BotAPI::getChatAdministrators
BotAPI::getChatAdministrators($params) Description: Retrieves a list of administrators in a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID. Example:
BotAPI::getChatMember
BotAPI::getChatMember($params) Description: Retrieves information about a specific chat member. Parameters:
chat_id(int|string) – The Telegram chat ID.user_id(int) – The user ID. Example:
BotAPI::getChatMembersCount
BotAPI::getChatMembersCount($params) Description: Retrieves the number of members in a Telegram chat. Parameters:
chat_id(int|string) – The Telegram chat ID. Example:
BotAPI::setChatStickerSet
BotAPI::setChatStickerSet($params) Description: Sets a sticker set for a supergroup. Parameters:
chat_id(int|string) – The Telegram chat ID.sticker_set_name(string) – Name of the sticker set. Example:
BotAPI::deleteChatStickerSet
BotAPI::deleteChatStickerSet($params) Description: Deletes a chat’s sticker set. Parameters:
chat_id(int|string) – The Telegram chat ID. Example:
BotAPI::createNewStickerSet
BotAPI::createNewStickerSet($params) Description: Creates a new sticker set. Parameters:
user_id(int) – The user ID of the sticker set creator.name(string) – Name of the sticker set.title(string) – Title of the sticker set.stickers(array) – Array of stickers to include. Example:
BotAPI::addStickerToSet
BotAPI::addStickerToSet($params) Description: Adds a sticker to an existing sticker set. Parameters:
user_id(int) – The user ID of the sticker set owner.name(string) – Name of the sticker set.sticker(array) – Sticker to add. Example:
BotAPI::setStickerPositionInSet
BotAPI::setStickerPositionInSet($params) Description: Changes a sticker’s position in a sticker set. Parameters:
sticker(string) – File ID of the sticker.position(int) – New position in the set. Example:
BotAPI::deleteStickerFromSet
BotAPI::deleteStickerFromSet($params) Description: Deletes a sticker from a sticker set. Parameters:
sticker(string) – File ID of the sticker. Example:
BotAPI::setStickerSetThumb
BotAPI::setStickerSetThumb($params) Description: Sets a thumbnail for a sticker set. Parameters:
name(string) – Name of the sticker set.user_id(int) – The user ID of the sticker set owner.thumb(string) – URL or file path of the thumbnail. Example:
Last updated