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::sendVideo([
'chat_id' => $chatId,
'video' => 'https://example.com/video.mp4',
'caption' => 'Check this clip!',
'parse_mode' => 'Markdown'
]);
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::sendAudio([
'chat_id' => $chatId,
'audio' => 'https://example.com/audio.mp3',
'caption' => 'My favorite song!'
]);
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::sendDocument([
'chat_id' => $chatId,
'document' => 'https://example.com/doc.pdf',
'caption' => 'Project report'
]);
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::sendSticker([
'chat_id' => $chatId,
'sticker' => 'https://example.com/sticker.webp'
]);
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::sendVoice([
'chat_id' => $chatId,
'voice' => 'https://example.com/voice.ogg',
'caption' => 'Listen to this!'
]);
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::sendVideoNote([
'chat_id' => $chatId,
'video_note' => 'https://example.com/videonote.mp4'
]);
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::sendMediaGroup([
'chat_id' => $chatId,
'media' => [
['type' => 'photo', 'media' => 'https://example.com/photo1.jpg'],
['type' => 'photo', 'media' => 'https://example.com/photo2.jpg']
]
]);
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::sendLocation([
'chat_id' => $chatId,
'latitude' => 51.5074,
'longitude' => -0.1278
]);
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::sendVenue([
'chat_id' => $chatId,
'latitude' => 51.5074,
'longitude' => -0.1278,
'title' => 'Big Ben',
'address' => 'London, UK'
]);
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::sendContact([
'chat_id' => $chatId,
'phone_number' => '+1234567890',
'first_name' => 'John',
'last_name' => 'Doe'
]);
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::sendPoll([
'chat_id' => $chatId,
'question' => 'Favorite color?',
'options' => ['Red', 'Blue', 'Green'],
'is_anonymous' => true
]);
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::sendDice([
'chat_id' => $chatId,
'emoji' => '🎲'
]);
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::sendChatAction([
'chat_id' => $chatId,
'action' => 'typing'
]);
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::getUserProfilePhotos([
'user_id' => $userId,
'limit' => 10
]);
BotAPI::getChatInfo
BotAPI::getChatInfo($chatId) Description: Retrieves information about a specified Telegram chat. Parameters:
chat_id
(int|string) – The Telegram chat ID. Example:
BotAPI::getChatInfo($chatId);
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::banChatMember([
'chat_id' => $chatId,
'user_id' => $userId,
'until_date' => time() + 86400
]);
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::unbanChatMember([
'chat_id' => $chatId,
'user_id' => $userId
]);
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::restrictChatMember([
'chat_id' => $chatId,
'user_id' => $userId,
'permissions' => ['can_send_messages' => false]
]);
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::promoteChatMember([
'chat_id' => $chatId,
'user_id' => $userId,
'can_change_info' => true
]);
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::setChatAdministratorCustomTitle([
'chat_id' => $chatId,
'user_id' => $userId,
'custom_title' => 'Chief Moderator'
]);
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::answerCallbackQuery([
'callback_query_id' => $queryId,
'text' => 'Action completed!',
'show_alert' => false
]);
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::editMessageText([
'chat_id' => $chatId,
'message_id' => $messageId,
'text' => 'Updated message!',
'parse_mode' => 'Markdown'
]);
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::deleteMessage([
'chat_id' => $chatId,
'message_id' => $messageId
]);
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::sendMessage([
'chat_id' => $chatId,
'text' => 'Hello <b>World</b>!',
'parse_mode' => 'HTML'
]);
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::forwardMessage([
'chat_id' => $chatId,
'from_chat_id' => $fromChatId,
'message_id' => $messageId
]);
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::copyMessage([
'chat_id' => $chatId,
'from_chat_id' => $fromChatId,
'message_id' => $messageId,
'caption' => 'Copied message'
]);
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::sendAnimation([
'chat_id' => $chatId,
'animation' => 'https://example.com/animation.gif',
'caption' => 'Funny GIF!'
]);
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::setChatPermissions([
'chat_id' => $chatId,
'permissions' => ['can_send_messages' => true, 'can_send_media' => false]
]);
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::exportChatInviteLink(['chat_id' => $chatId]);
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::createChatInviteLink([
'chat_id' => $chatId,
'name' => 'VIP Link',
'member_limit' => 100
]);
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::editChatInviteLink([
'chat_id' => $chatId,
'invite_link' => 'https://t.me/joinchat/xxxx',
'name' => 'Updated Link'
]);
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::revokeChatInviteLink([
'chat_id' => $chatId,
'invite_link' => 'https://t.me/joinchat/xxxx'
]);
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::approveChatJoinRequest([
'chat_id' => $chatId,
'user_id' => $userId
]);
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::declineChatJoinRequest([
'chat_id' => $chatId,
'user_id' => $userId
]);
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::setChatPhoto([
'chat_id' => $chatId,
'photo' => 'https://example.com/chatphoto.jpg'
]);
BotAPI::deleteChatPhoto
BotAPI::deleteChatPhoto($params) Description: Deletes a Telegram chat’s profile photo. Parameters:
chat_id
(int|string) – The Telegram chat ID. Example:
BotAPI::deleteChatPhoto(['chat_id' => $chatId]);
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::setChatTitle([
'chat_id' => $chatId,
'title' => 'New Group Name'
]);
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::setChatDescription([
'chat_id' => $chatId,
'description' => 'Welcome to our community!'
]);
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::pinChatMessage([
'chat_id' => $chatId,
'message_id' => $messageId
]);
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::unpinChatMessage([
'chat_id' => $chatId,
'message_id' => $messageId
]);
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::unpinAllChatMessages(['chat_id' => $chatId]);
BotAPI::leaveChat
BotAPI::leaveChat($params) Description: Makes the bot leave a Telegram chat. Parameters:
chat_id
(int|string) – The Telegram chat ID. Example:
BotAPI::leaveChat(['chat_id' => $chatId]);
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::answerInlineQuery([
'inline_query_id' => $queryId,
'results' => [['type' => 'article', 'id' => '1', 'title' => 'Result']]
]);
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::setMyCommands([
'commands' => [['command' => '/start', 'description' => 'Start the bot']]
]);
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::deleteMyCommands([]);
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::getMyCommands([]);
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::editMessageCaption([
'chat_id' => $chatId,
'message_id' => $messageId,
'caption' => 'Updated caption!',
'parse_mode' => 'HTML'
]);
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::editMessageMedia([
'chat_id' => $chatId,
'message_id' => $messageId,
'media' => ['type' => 'photo', 'media' => 'https://example.com/newphoto.jpg']
]);
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::editMessageReplyMarkup([
'chat_id' => $chatId,
'message_id' => $messageId,
'reply_markup' => ['inline_keyboard' => [[['text' => 'New Button', 'callback_data' => 'data']]]]
]);
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::sendInvoice([
'chat_id' => $chatId,
'title' => 'Product',
'description' => 'A cool product',
'payload' => 'payload123',
'provider_token' => 'token',
'currency' => 'USD',
'prices' => [['label' => 'Item', 'amount' => 1000]]
]);
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::answerShippingQuery([
'shipping_query_id' => $queryId,
'ok' => true,
'shipping_options' => [['id' => '1', 'title' => 'Standard', 'prices' => [['label' => 'Shipping', 'amount' => 500]]]]
]);
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::answerPreCheckoutQuery([
'pre_checkout_query_id' => $queryId,
'ok' => true
]);
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::sendGame([
'chat_id' => $chatId,
'game_short_name' => 'MyGame'
]);
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::setGameScore([
'user_id' => $userId,
'score' => 100,
'chat_id' => $chatId,
'message_id' => $messageId
]);
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::getGameHighScores([
'user_id' => $userId,
'chat_id' => $chatId,
'message_id' => $messageId
]);
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::setWebhook([
'url' => 'https://example.com/webhook',
'allowed_updates' => ['message', 'callback_query']
]);
BotAPI::deleteWebhook
BotAPI::deleteWebhook($params) Description: Deletes the webhook, reverting to polling. Parameters:
drop_pending_updates
(bool, optional) – Drop all pending updates. Example:
BotAPI::deleteWebhook(['drop_pending_updates' => true]);
BotAPI::getWebhookInfo
BotAPI::getWebhookInfo($params) Description: Retrieves information about the current webhook. Parameters: None Example:
BotAPI::getWebhookInfo([]);
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::getUpdates([
'offset' => $offset,
'limit' => 100,
'timeout' => 30
]);
BotAPI::getMe
BotAPI::getMe($params) Description: Retrieves information about the bot itself. Parameters: None Example:
BotAPI::getMe([]);
BotAPI::logOut
BotAPI::logOut($params) Description: Logs out the bot from the cloud Bot API server. Parameters: None Example:
BotAPI::logOut([]);
BotAPI::close
BotAPI::close($params) Description: Closes the bot instance. Parameters: None Example:
BotAPI::close([]);
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::getChatAdministrators(['chat_id' => $chatId]);
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::getChatMember([
'chat_id' => $chatId,
'user_id' => $userId
]);
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::getChatMembersCount(['chat_id' => $chatId]);
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::setChatStickerSet([
'chat_id' => $chatId,
'sticker_set_name' => 'MyStickerSet'
]);
BotAPI::deleteChatStickerSet
BotAPI::deleteChatStickerSet($params) Description: Deletes a chat’s sticker set. Parameters:
chat_id
(int|string) – The Telegram chat ID. Example:
BotAPI::deleteChatStickerSet(['chat_id' => $chatId]);
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::createNewStickerSet([
'user_id' => $userId,
'name' => 'MyStickerSet',
'title' => 'My Stickers',
'stickers' => [['sticker' => 'https://example.com/sticker.png', 'emoji' => '😊']]
]);
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::addStickerToSet([
'user_id' => $userId,
'name' => 'MyStickerSet',
'sticker' => ['sticker' => 'https://example.com/sticker.png', 'emoji' => '😊']
]);
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::setStickerPositionInSet([
'sticker' => 'file_id',
'position' => 1
]);
BotAPI::deleteStickerFromSet
BotAPI::deleteStickerFromSet($params) Description: Deletes a sticker from a sticker set. Parameters:
sticker
(string) – File ID of the sticker. Example:
BotAPI::deleteStickerFromSet(['sticker' => 'file_id']);
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:
BotAPI::setStickerSetThumb([
'name' => 'MyStickerSet',
'user_id' => $userId,
'thumb' => 'https://example.com/thumb.png'
]);
Last updated