### Telegram Bot API: Hello Bot Example (PHP) Source: https://core.telegram.org/bots/faq A basic example demonstrating the fundamental interactions with the Telegram Bot API. This 'Hello Bot' illustrates the core functionalities required to get started with bot development in PHP. ```php // Placeholder for PHP code example // Actual code would interact with the Telegram Bot API ``` -------------------------------- ### BotPreviewMedia Constructor and Methods Source: https://core.telegram.org/type/BotPreviewMedia_layer=128 This section details the BotPreviewMedia constructor and the methods available for managing Main Mini App preview media. ```APIDOC ## BotPreviewMedia Represents a Main Mini App preview media, see here » for more info. ### Constructors Constructor | Description ---|--- botPreviewMedia | Represents a Main Mini App preview media, see here » for more info. ### Methods Method | Description ---|--- bots.addPreviewMedia | Add a main mini app preview, see here » for more info. Only owners of bots with a configured Main Mini App can use this method, see see here » for more info on how to check if you can invoke this method. bots.editPreviewMedia | Edit a main mini app preview, see here » for more info. Only owners of bots with a configured Main Mini App can use this method, see see here » for more info on how to check if you can invoke this method. ### Related Pages #### Mini Apps on Telegram Bots can offer users interactive HTML5 web apps to completely replace any website. ##### Telegram Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed. ##### About * FAQ * Privacy * Press ##### Mobile Apps * iPhone/iPad * Android * Mobile Web ##### Desktop Apps * PC/Mac/Linux * macOS * Web-browser ##### Platform * API * Translations * Instant View ##### About ##### Blog ##### Press ##### Moderation __Go up ``` -------------------------------- ### messages.getAllStickers Source: https://core.telegram.org/methods This method gets all installed stickers. It retrieves all sticker sets that the user has installed. ```APIDOC ## messages.getAllStickers ### Description Get all installed stickers ### Method GET ### Endpoint messages.getAllStickers ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **stickersets** (array) - Array of stickerset objects. #### Response Example { "stickersets": [{ "id": 123, "title": "My Stickers", "short_name": "my_stickers" }] } ``` -------------------------------- ### BotPreviewMedia Constructor Source: https://core.telegram.org/type/BotPreviewMedia_layer=16 Represents a Main Mini App preview media. ```APIDOC ## BotPreviewMedia Constructor ### Description Represents a Main Mini App preview media, see here » for more info. ### Parameters (No parameters for constructor) ### Example (No specific example for constructor, usage is within method calls) ``` -------------------------------- ### messages.getMaskStickers Source: https://core.telegram.org/methods This method gets installed mask stickers. It retrieves all mask sticker sets that the user has installed. ```APIDOC ## messages.getMaskStickers ### Description Get installed mask stickers ### Method GET ### Endpoint messages.getMaskStickers ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **stickersets** (array) - Array of mask stickerset objects. #### Response Example { "stickersets": [{ "id": 123, "title": "Mask Stickers", "short_name": "mask_stickers" }] } ``` -------------------------------- ### BotPreviewMedia Constructor Source: https://core.telegram.org/type/BotPreviewMedia_layer=145 Represents a Main Mini App preview media. ```APIDOC ## BotPreviewMedia Constructor ### Description Represents a Main Mini App preview media, see here » for more info. ### Method Constructor ### Parameters None ### Request Example None ### Response #### Success Response (200) - **botPreviewMedia** (object) - An object representing the preview media. #### Response Example ```json { "result": { "type": "photo", "media": "AgACAgIAAxkBAAIE5mYjQ571z1z1z1z1z1z1z1z1z1z1z1wAAYAAgI" } } ``` ``` -------------------------------- ### BotPreviewMedia Constructor Source: https://core.telegram.org/type/BotPreviewMedia_layer=125 Represents a Main Mini App preview media. ```APIDOC ## BotPreviewMedia ### Description Represents a Main Mini App preview media, see here » for more info. ### Constructor #### botPreviewMedia - **Description**: Represents a Main Mini App preview media, see here » for more info. ``` -------------------------------- ### Get Premium Sticker Examples Source: https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1get_premium_sticker_examples Retrieves examples of premium stickers for demonstration purposes. This function is part of the TDLib API. ```APIDOC ## GET /getPremiumStickerExamples ### Description Returns examples of premium stickers for demonstration purposes. ### Method GET ### Endpoint /getPremiumStickerExamples ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```json { "method": "getPremiumStickerExamples" } ``` ### Response #### Success Response (200) - **result** (object_ptr) - An object containing sticker examples. #### Response Example ```json { "@type": "stickers", "total_count": 10, "stickers": [ { "id": 1, "sticker": "file_id_1" }, { "id": 2, "sticker": "file_id_2" } ] } ``` ### Error Handling - **400 Bad Request**: Invalid request parameters. - **500 Internal Server Error**: Server-side error. ``` -------------------------------- ### bots.addPreviewMedia Source: https://core.telegram.org/type/BotPreviewMedia_layer=145 Add a main mini app preview. ```APIDOC ## POST /bots.addPreviewMedia ### Description Add a main mini app preview, see here » for more info. Only owners of bots with a configured Main Mini App can use this method. ### Method POST ### Endpoint /bots.addPreviewMedia ### Parameters #### Query Parameters - **bot_token** (string) - Required - Bot token. - **media** (string) - Required - Media file ID. ### Request Example ```json { "bot_token": "YOUR_BOT_TOKEN", "media": "AgACAgIAAxkBAAIE5mYjQ571z1z1z1z1z1z1z1z1z1z1z1wAAYAAgI" } ``` ### Response #### Success Response (200) - **ok** (boolean) - True if the request was successful. #### Response Example ```json { "ok": true } ``` ``` -------------------------------- ### messages.getAllStickers Source: https://core.telegram.org/schema_layer=145 This method gets all installed stickers. ```APIDOC ## messages.getAllStickers ### Description Gets all installed stickers. ### Method GET ### Endpoint messages.getAllStickers ### Parameters #### Query Parameters - **hash** (long) - Required - Hash for pagination ### Request Example { "hash": 0 } ### Response #### Success Response (200) - **messages.AllStickers** (messages.AllStickers) - Returns all stickers. #### Response Example { "_": "messages.allStickers", "stickers": [] } ``` -------------------------------- ### BotPreviewMedia Constructor Source: https://core.telegram.org/type/BotPreviewMedia_layer=117 Represents a Main Mini App preview media. ```APIDOC ## BotPreviewMedia Constructor ### Description Represents a Main Mini App preview media, see here » for more info. ### Method Constructor ### Parameters None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Get Installed Backgrounds Function (TDLib API) Source: https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1get_installed_backgrounds Retrieves a list of backgrounds installed by the user. Supports ordering for dark themes. Returns an object_ptr. ```cpp /// \brief Gets installed backgrounds. /// /// Returns backgrounds installed by the user. /// Returns object_ptr. object_ptr getInstalledBackgrounds(); /// \brief Gets installed backgrounds. /// /// Creates a function, which returns backgrounds installed by the user. /// Returns object_ptr. /// /// \param for_dark_theme_ Pass true to order returned backgrounds for a dark theme. object_ptr getInstalledBackgrounds(bool for_dark_theme_); ``` -------------------------------- ### BotPreviewMedia Constructor Source: https://core.telegram.org/type/BotPreviewMedia_layer=167 Represents a Main Mini App preview media. ```APIDOC ## BotPreviewMedia ### Description Represents a Main Mini App preview media, see here » for more info. ### Constructor `botPreviewMedia` ``` -------------------------------- ### Manage Telegram Stickers Source: https://core.telegram.org/schema_layer=112 APIs for retrieving stickers based on emoticons, fetching all installed stickers, and managing sticker sets (getting, installing, uninstalling). ```Telegram API messages.getStickers#43d4f2c emoticon:string hash:int = messages.Stickers; messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers; messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet; messages.installStickerSet#c78fe460 stickerset:InputStickerSet archived:Bool = messages.StickerSetInstallResult; messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool; ``` -------------------------------- ### BotPreviewMedia Constructor Source: https://core.telegram.org/type/BotPreviewMedia_layer=5 Represents a Main Mini App preview media, with additional information available. ```APIDOC ## BotPreviewMedia Constructor ### Description Represents a Main Mini App preview media, see here » for more info. ### Parameters None ### Request Example None ### Response None ``` -------------------------------- ### Get Installed Attachment Menu Bots Source: https://core.telegram.org/api/bots/attach Retrieves a list of all bots currently installed in the user's attachment and side menus. ```APIDOC ## GET /api/messages.getAttachMenuBots ### Description Fetches the list of bots that have been added to the user's attachment menu or side menu. This call should be made after receiving an `updateAttachMenuBots` notification to refresh the list. ### Method GET ### Endpoint /api/messages.getAttachMenuBots ### Parameters #### Query Parameters - **hash** (long) - Optional - Used for checking if the list has changed since the last fetch. If the list is unchanged, an `attachMenuBotsNotModified` response will be returned. ### Request Example ```json { "hash": "1234567890" } ``` ### Response #### Success Response (200) - **AttachMenuBots** (AttachMenuBots) - Contains the list of installed bots and associated user data. #### Response Example ```json { "attachMenuBots": { "_type": "AttachMenuBots", "hash": "9876543210", "bots": [ { "_type": "AttachMenuBot", "bot_id": "123456789", "short_name": "my_mini_app", "show_in_attach_menu": true, "show_in_side_menu": false, "inactive": false, "icons": [ { "_type": "AttachMenuBotIcon", "name": "default_icon" } ] } ], "users": [ { "_type": "User", "id": "123456789", "first_name": "ExampleBot" } ] } } ``` #### Not Modified Response (304) - **attachMenuBotsNotModified** (AttachMenuBotsNotModified) - Indicates that the list of bots has not changed. #### Not Modified Response Example ```json { "attachMenuBotsNotModified": {} } ``` ``` -------------------------------- ### BotPreviewMedia Constructor Source: https://core.telegram.org/type/BotPreviewMedia_layer=168 Represents a Main Mini App preview media. ```APIDOC ## BotPreviewMedia Constructor ### Description Represents a Main Mini App preview media. See here » for more info. ### Parameters (No parameters for constructor) ### Request Example (No request example for constructor) ### Response (No response for constructor) ``` -------------------------------- ### Get All Stickers Source: https://core.telegram.org/schema_layer=128 Retrieves all installed sticker sets. ```APIDOC ## GET /api/messages/getAllStickers ### Description Retrieves all installed sticker sets. ### Method GET ### Endpoint /api/messages/getAllStickers ### Parameters #### Query Parameters - **hash** (int) - Required - The hash of the sticker sets. ### Response #### Success Response (200) - **all_stickers** (messages.AllStickers) - A container for all sticker sets. #### Response Example ```json { "all_stickers": { "_rpc_error": null } } ``` ``` -------------------------------- ### User Authorization Source: https://core.telegram.org/constructor/codeSettings_layer=11 Guides users on how to register their phone number to start using the Telegram API. ```APIDOC ## User Authorization API ### Description This section details the process of registering a user's phone number to initiate API usage. It covers the necessary steps and potential methods for authentication. ### Method POST (or other methods as defined by specific endpoints) ### Endpoint /api/auth/register ### Parameters #### Path Parameters None. #### Query Parameters None. #### Request Body - **phone_number** (string) - Required - The user's phone number in international format. - **country_code** (string) - Required - The country code for the phone number. ### Request Example ```json { "phone_number": "+12345678900", "country_code": "US" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating successful initiation of the registration process. - **verification_id** (string) - An identifier used for subsequent verification steps. #### Response Example ```json { "message": "Verification code sent to your phone number.", "verification_id": "abc123xyz789" } ``` ``` -------------------------------- ### BotPreviewMedia Constructor and Methods Source: https://core.telegram.org/type/BotPreviewMedia_layer=111 Information about the BotPreviewMedia constructor and its associated methods for managing Mini App previews. ```APIDOC ## BotPreviewMedia Represents a Main Mini App preview media, see here » for more info. ### Constructor - **botPreviewMedia**: Represents a Main Mini App preview media. ### Methods #### bots.addPreviewMedia **Description**: Add a main mini app preview. **Usage**: Only owners of bots with a configured Main Mini App can use this method. #### bots.editPreviewMedia **Description**: Edit a main mini app preview. **Usage**: Only owners of bots with a configured Main Mini App can use this method. ### Related Pages #### Mini Apps on Telegram Bots can offer users interactive HTML5 web apps to completely replace any website. ``` -------------------------------- ### Sticker Set Management Source: https://core.telegram.org/schema_layer=164 Endpoints for getting, installing, and uninstalling sticker sets. ```APIDOC ## GET /api/stickers/{stickerSet} ### Description Retrieves information about a specific sticker set. ### Method GET ### Endpoint `/api/stickers/{stickerSet}` ### Parameters #### Path Parameters - **stickerSet** (InputStickerSet) - Required - The identifier for the sticker set. #### Query Parameters - **hash** (int) - Optional - A hash value for caching. ### Response #### Success Response (200) - **stickerSet** (messages.StickerSet) - Information about the sticker set. ### Response Example ```json { "@type": "messages.stickerSet", "id": 0, "access_hash": 0, "title": "string", "short_name": "string", "count": 0, "hash": 0 } ``` ``` ```APIDOC ## POST /api/stickers/install ### Description Installs or archives a sticker set. ### Method POST ### Endpoint `/api/stickers/install` ### Parameters #### Request Body - **stickerSet** (InputStickerSet) - Required - The sticker set to install. - **archived** (Bool) - Required - Whether to archive the sticker set. ### Response #### Success Response (200) - **result** (messages.StickerSetInstallResult) - The result of the installation. ### Response Example ```json { "@type": "messages.stickerSetInstallResult", "installed_peers": [ { "@type": "inputPeerChannel", "channel_id": 0, "access_hash": 0 } ] } ``` ``` ```APIDOC ## DELETE /api/stickers/uninstall ### Description Uninstalls a sticker set. ### Method DELETE ### Endpoint `/api/stickers/uninstall` ### Parameters #### Request Body - **stickerSet** (InputStickerSet) - Required - The sticker set to uninstall. ### Response #### Success Response (200) - **result** (Bool) - Indicates if the uninstallation was successful. ### Response Example ```json true ``` ``` -------------------------------- ### BotPreviewMedia Constructors and Methods Source: https://core.telegram.org/type/BotPreviewMedia_layer=187 This section details the constructors and methods related to BotPreviewMedia, which represents a Main Mini App preview media. ```APIDOC ## BotPreviewMedia API Documentation ### Description Represents a Main Mini App preview media. This API allows bot owners to manage the preview media displayed for their bots' Main Mini Apps. ### Constructors #### botPreviewMedia - **Description**: Represents a Main Mini App preview media. ### Methods #### bots.addPreviewMedia ##### Description Add a main mini app preview. Only owners of bots with a configured Main Mini App can use this method. ##### Method POST ##### Endpoint /bots/addPreviewMedia ##### Parameters ###### Request Body - **bot** (InputUser) - Required - The bot to which the preview media will be added. - **lang_code** (string) - Required - The language code for the preview media. - **media** (InputMedia) - Required - The media to be set as the preview. ###### Request Example ```json { "bot": {"api_id": 1234567, "api_hash": "your_api_hash"}, "lang_code": "en", "media": {"type": "photo", "media": "attach://photo.jpg"} } ``` #### bots.editPreviewMedia ##### Description Edit a main mini app preview. Only owners of bots with a configured Main Mini App can use this method. ##### Method POST ##### Endpoint /bots/editPreviewMedia ##### Parameters ###### Request Body - **bot** (InputUser) - Required - The bot whose preview media will be edited. - **lang_code** (string) - Required - The language code of the preview media to edit. - **new_media** (InputMedia) - Required - The new media to set as the preview. ###### Request Example ```json { "bot": {"api_id": 1234567, "api_hash": "your_api_hash"}, "lang_code": "en", "new_media": {"type": "video", "media": "attach://video.mp4"} } ``` ### Related Pages #### Mini Apps on Telegram Bots can offer users interactive HTML5 web apps to completely replace any website. ##### Telegram Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed. ###### About - FAQ - Privacy - Press ###### Mobile Apps - iPhone/iPad - Android - Mobile Web ###### Desktop Apps - PC/Mac/Linux - macOS - Web-browser ``` -------------------------------- ### messages.getAllStickers#b8a0a1a8 Source: https://core.telegram.org/method/messages_layer=43 This method is used to get all installed stickers. It returns messages.AllStickers. ```APIDOC ## messages.getAllStickers#b8a0a1a8 ### Description This method retrieves all installed stickers. ### Method GET ### Endpoint messages.getAllStickers#b8a0a1a8 ### Parameters #### Query Parameters - **hash** (long) - Required - Hash used for caching. ### Request Example {} ### Response #### Success Response (200) - **sets** (Vector) - A list of sticker sets. #### Response Example { "_: 'messages.allStickers', "sets": [] } ``` -------------------------------- ### inputBotInlineMessageMediaWebPage API Documentation Source: https://core.telegram.org/constructor/inputBotInlineMessageMediaWebPage_layer=142 Documentation for the inputBotInlineMessageMediaWebPage constructor, detailing its parameters and usage for creating link previews. ```APIDOC ## POST /websites/core_telegram/inputBotInlineMessageMediaWebPage ### Description Specifies options that will be used to generate the link preview for the message, or even a standalone link preview without an attached message. ### Method POST ### Endpoint /websites/core_telegram/inputBotInlineMessageMediaWebPage ### Parameters #### Request Body - **flags** (integer) - Flags, see TL conditional fields - **invert_media** (boolean) - If set, any eventual webpage preview will be shown on top of the message instead of at the bottom. - **force_large_media** (boolean) - If set, specifies that a large media preview should be used. - **force_small_media** (boolean) - If set, specifies that a small media preview should be used. - **optional** (boolean) - If not set, a `WEBPAGE_NOT_FOUND` RPC error will be emitted if a webpage preview cannot be generated for the specified `url`; otherwise, no error will be emitted (unless the provided message is also empty, in which case a `MESSAGE_EMPTY` will be emitted, instead). - **message** (string) - The message, can be empty. - **entities** (array) - Message entities for styled text - **url** (string) - The URL to use for the link preview. - **reply_markup** (object) - Inline keyboard ### Request Example ```json { "flags": 0, "invert_media": false, "force_large_media": false, "force_small_media": false, "optional": false, "message": "Check out this link!", "entities": [], "url": "https://example.com", "reply_markup": {} } ``` ### Response #### Success Response (200) - **result** (object) - The result of the operation #### Response Example ```json { "ok": true, "result": { "message_id": 12345, "chat": { "id": 67890, "type": "private" }, "date": 1678886400 } } ``` ``` -------------------------------- ### Get Premium Sticker Examples (C++) Source: https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1get_premium_sticker_examples Retrieves examples of premium stickers for demonstration purposes using the TDLib API. This function is part of the `td_api.h` header and returns an object pointer to Stickers. ```c++ object_ptr getPremiumStickerExamples() const; ``` -------------------------------- ### InputBotInlineMessageMediaWebPage Source: https://core.telegram.org/constructor/inputBotInlineMessageMediaWebPage_layer=117 Documentation for the InputBotInlineMessageMediaWebPage constructor, which allows for the creation of link previews. ```APIDOC ## InputBotInlineMessageMediaWebPage ### Description Specifies options that will be used to generate the link preview for the message, or even a standalone link preview without an attached message. ### Method Not Applicable (Constructor) ### Endpoint Not Applicable (Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **flags** (integer) - Flags, see TL conditional fields * **invert_media** (boolean) - If set, any eventual webpage preview will be shown on top of the message instead of at the bottom. * **force_large_media** (boolean) - If set, specifies that a large media preview should be used. * **force_small_media** (boolean) - If set, specifies that a small media preview should be used. * **optional** (boolean) - If **not** set, a `WEBPAGE_NOT_FOUND` RPC error will be emitted if a webpage preview cannot be generated for the specified `url`; otherwise, no error will be emitted (unless the provided message is also empty, in which case a `MESSAGE_EMPTY` will be emitted, instead). * **message** (string) - The message, can be empty. * **entities** (Array) - Message entities for styled text * **url** (string) - The URL to use for the link preview. * **reply_markup** (ReplyMarkup) - Inline keyboard ### Request Example ```json { "flags": 0, "message": "Check out this link!", "url": "https://example.com" } ``` ### Response #### Success Response (200) This constructor does not typically return a direct response but is used within other API calls. #### Response Example None (Constructor) ``` -------------------------------- ### Get Attach Menu Bots Source: https://core.telegram.org/type/AttachMenuBots_layer=119 Retrieves a list of installed bot mini apps that can be launched from the attachment menu. ```APIDOC ## GET /messages.getAttachMenuBots ### Description Returns installed attachment menu bot mini apps. ### Method GET ### Endpoint /messages.getAttachMenuBots ### Parameters #### Query Parameters - **api_id** (int) - Required - Your application's API ID. - **api_hash** (string) - Required - Your application's API hash. - **access_hash** (string) - Optional - Access hash for the user. ### Request Example ```json { "api_id": 1234567, "api_hash": "your_api_hash" } ``` ### Response #### Success Response (200) - **count** (int) - The number of attach menu bots. - **bots** (array) - An array of attach menu bot objects. - **id** (int) - The bot's user ID. - **access_hash** (string) - The bot's access hash. - **first_name** (string) - The bot's first name. - **username** (string) - The bot's username. - **photo_url** (string) - URL of the bot's profile photo. - **app_bot_id** (int) - The bot mini app ID. #### Response Example ```json { "count": 2, "bots": [ { "id": 123456789, "access_hash": "some_access_hash", "first_name": "BotName", "username": "botusername", "photo_url": "http://example.com/photo.jpg", "app_bot_id": 1 } ] } ``` ``` -------------------------------- ### inputMediaWebPage Documentation Source: https://core.telegram.org/constructor/inputMediaWebPage_layer=151 Details the inputMediaWebPage constructor, used to specify options for generating link previews. ```APIDOC ## inputMediaWebPage ### Description Specifies options that will be used to generate the link preview for the caption, or even a standalone link preview without an attached message. ### Method Not Applicable (Constructor) ### Endpoint Not Applicable (Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **flags** (integer) - Flags, see TL conditional fields. - **force_large_media** (boolean) - If set, specifies that a large media preview should be used. - **force_small_media** (boolean) - If set, specifies that a small media preview should be used. - **optional** (boolean) - If not set, a `WEBPAGE_NOT_FOUND` RPC error will be emitted if a webpage preview cannot be generated for the specified `url`; otherwise, no error will be emitted (unless the provided message is also empty, in which case a `MESSAGE_EMPTY` will be emitted, instead). - **url** (string) - The URL to use for the link preview. ### Request Example ```json { "@type": "inputMediaWebPage", "flags": 0, "force_large_media": false, "force_small_media": false, "optional": false, "url": "https://example.com" } ``` ### Response #### Success Response (200) This is a constructor, its response depends on the method it's used with. #### Response Example (Depends on the method using this constructor) ``` -------------------------------- ### BotPreviewMedia Constructor Source: https://core.telegram.org/type/BotPreviewMedia_layer=23 Represents a Main Mini App preview media. This is a constructor for creating or referencing preview media. ```APIDOC ## BotPreviewMedia Constructor ### Description Represents a Main Mini App preview media, see here » for more info. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ``` -------------------------------- ### Account Wallpaper Management Source: https://core.telegram.org/schema_layer=177 APIs for getting, uploading, saving, installing, and resetting wallpapers. ```APIDOC ## POST /account/getWallPaper ### Description Retrieves a specific wallpaper. ### Method POST ### Endpoint /account/getWallPaper ### Parameters #### Request Body - **wallpaper** (InputWallPaper) - Required - The input representing the wallpaper to retrieve. ### Response #### Success Response (200) - **wallpaper** (WallPaper) - The retrieved wallpaper object. ### Request Example ```json { "wallpaper": { ... } } ``` ### Response Example ```json { "wallpaper": { ... } } ``` ## POST /account/uploadWallPaper ### Description Uploads a new wallpaper. ### Method POST ### Endpoint /account/uploadWallPaper ### Parameters #### Request Body - **flags** (int) - Bitwise flags for options. - **for_chat** (Bool, optional, flag 0) - Whether the wallpaper is for a chat. - **file** (InputFile) - Required - The wallpaper file. - **mime_type** (string) - Required - The MIME type of the wallpaper file. - **settings** (WallPaperSettings) - Required - Settings for the wallpaper. ### Response #### Success Response (200) - **wallpaper** (WallPaper) - The uploaded wallpaper object. ### Request Example ```json { "flags": 0, "file": "...", "mime_type": "image/jpeg", "settings": { ... } } ``` ### Response Example ```json { "wallpaper": { ... } } ``` ## POST /account/saveWallPaper ### Description Saves or unsaves a wallpaper. ### Method POST ### Endpoint /account/saveWallPaper ### Parameters #### Request Body - **wallpaper** (InputWallPaper) - Required - The wallpaper to save or unsave. - **unsave** (Bool) - Required - Whether to unsave the wallpaper. - **settings** (WallPaperSettings) - Required - Settings for the wallpaper. ### Response #### Success Response (200) - **result** (Bool) - Indicates if the operation was successful. ### Request Example ```json { "wallpaper": { ... }, "unsave": false, "settings": { ... } } ``` ### Response Example ```json { "result": true } ``` ## POST /account/installWallPaper ### Description Installs a wallpaper. ### Method POST ### Endpoint /account/installWallPaper ### Parameters #### Request Body - **wallpaper** (InputWallPaper) - Required - The wallpaper to install. - **settings** (WallPaperSettings) - Required - Settings for the wallpaper. ### Response #### Success Response (200) - **result** (Bool) - Indicates if the operation was successful. ### Request Example ```json { "wallpaper": { ... }, "settings": { ... } } ``` ### Response Example ```json { "result": true } ``` ## POST /account/resetWallPapers ### Description Resets all installed wallpapers to default. ### Method POST ### Endpoint /account/resetWallPapers ### Response #### Success Response (200) - **result** (Bool) - Indicates if the operation was successful. ### Request Example ```json {} ``` ### Response Example ```json { "result": true } ``` ## POST /account/getMultiWallPapers ### Description Retrieves multiple wallpapers. ### Method POST ### Endpoint /account/getMultiWallPapers ### Parameters #### Request Body - **wallpapers** (Vector) - Required - A list of wallpapers to retrieve. ### Response #### Success Response (200) - **wallpapers** (Vector) - A list of retrieved wallpaper objects. ### Request Example ```json { "wallpapers": [ { ... }, { ... } ] } ``` ### Response Example ```json { "wallpapers": [ { ... }, { ... } ] } ``` ``` -------------------------------- ### inputMediaWebPage Constructor Source: https://core.telegram.org/constructor/inputMediaWebPage_layer=136 Details of the inputMediaWebPage constructor, including its parameters and usage for creating link previews. ```APIDOC ## inputMediaWebPage API Endpoint ### Description Specifies options that will be used to generate the link preview for the caption, or even a standalone link preview without an attached message. ### Method N/A (Constructor) ### Endpoint N/A (Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body **inputMediaWebPage** - **flags** (integer) - Flags, see TL conditional fields - **force_large_media** (boolean) - Optional - If set, specifies that a large media preview should be used. - **force_small_media** (boolean) - Optional - If set, specifies that a small media preview should be used. - **optional** (boolean) - Optional - If **not** set, a `WEBPAGE_NOT_FOUND` RPC error will be emitted if a webpage preview cannot be generated for the specified `url`; otherwise, no error will be emitted (unless the provided message is also empty, in which case a `MESSAGE_EMPTY` will be emitted, instead). - **url** (string) - The URL to use for the link preview. ### Request Example ```json { "@type": "inputMediaWebPage", "url": "https://example.com" } ``` ### Response #### Success Response (200) This constructor is used in requests, not directly returned as a response. #### Response Example N/A ``` -------------------------------- ### Get All Stickers Source: https://core.telegram.org/api/stickers Fetches all installed and non-archived stickersets. A hash can be provided to check for modifications. ```APIDOC ## POST /messages.getAllStickers ### Description Fetches all installed and non-archived stickersets. A hash can be provided to check for modifications. ### Method POST ### Endpoint /messages.getAllStickers ### Parameters #### Request Body - **hash** (long) - Optional - Hash of the sticker sets for checking modifications. ### Request Example ```json { "hash": 1234567890123456789 } ``` ### Response #### Success Response (200) - **_type** (string) - The type of the result, either "messages.allStickersNotModified" or "messages.allStickers". - **hash** (long) - Hash of the sticker sets. - **sets** (Vector) - A list of installed sticker sets. #### Response Example ```json { "_type": "messages.allStickers", "hash": 1234567890123456789, "sets": [ { "id": 1111111111111111111, "access_hash": 2222222222222222222, "title": "My First StickerSet", "thumbnail": "thumb_url", "thumbnail_version": 1, "stickers": 10, "installed_date": 1678886400, "hash": 3333333333333333333 } ] } ``` ```json { "_type": "messages.allStickersNotModified", "hash": 1234567890123456789 } ``` ``` -------------------------------- ### Upload Profile Photo (Python) Source: https://core.telegram.org/method/photos_layer=121 Example of uploading a profile photo using the Telethon library in Python. This method utilizes the photos.uploadProfilePhoto API call. Ensure you have the Telethon library installed (`pip install telethon`). ```python from telethon.sync import TelegramClient from telethon.tl.functions.photos import UploadProfilePhotoRequest api_id = YOUR_API_ID api_hash = 'YOUR_API_HASH' phone = 'YOUR_PHONE_NUMBER' client = TelegramClient(phone, api_id, api_hash) client.start() # Upload a static photo with open('profile_photo.jpg', 'rb') as photo_file: client(UploadProfilePhotoRequest(file=client.upload_file(photo_file))) # Upload an animated video profile photo (e.g., MP4) # with open('profile_video.mp4', 'rb') as video_file: # client(UploadProfilePhotoRequest(video=client.upload_file(video_file))) print('Profile photo updated successfully!') client.disconnect() ``` -------------------------------- ### BotPreviewMedia Constructor Source: https://core.telegram.org/type/BotPreviewMedia_layer=120 Represents a Main Mini App preview media. This is a constructor for creating or referencing preview media. ```APIDOC ## BotPreviewMedia Constructor ### Description Represents a Main Mini App preview media, see here » for more info. ### Method Constructor ### Parameters None ### Request Example ```json { "constructor": "botPreviewMedia" } ``` ### Response #### Success Response (200) - **botPreviewMedia** (object) - The botPreviewMedia object #### Response Example ```json { "botPreviewMedia": { "description": "Represents a Main Mini App preview media" } } ``` ``` -------------------------------- ### BotPreviewMedia API Source: https://core.telegram.org/type/BotPreviewMedia_layer=180 This section covers the BotPreviewMedia constructor and related methods for managing Main Mini App previews. ```APIDOC ## BotPreviewMedia API ### Description Represents a Main Mini App preview media. This documentation outlines the methods for adding and editing these previews. ### Constructor #### `botPreviewMedia` **Description:** Represents a Main Mini App preview media, see here » for more info. ### Methods #### `bots.addPreviewMedia` ##### Description Add a main mini app preview. Only owners of bots with a configured Main Mini App can use this method. ##### Method POST ##### Endpoint /bots/addPreviewMedia ##### Parameters ###### Request Body - **media** (InputMedia) - Required - The media to be added as a preview. - **language_code** (string) - Optional - Language code of the preview. ###### Request Example ```json { "media": { "type": "photo", "media": "attach://photo.jpg" }, "language_code": "en" } ``` #### `bots.editPreviewMedia` ##### Description Edit a main mini app preview. Only owners of bots with a configured Main Mini App can use this method. ##### Method POST ##### Endpoint /bots/editPreviewMedia ##### Parameters ###### Request Body - **media** (InputMedia) - Required - The media to be edited. - **language_code** (string) - Optional - Language code of the preview. ###### Request Example ```json { "media": { "type": "photo", "media": "attach://photo.jpg" }, "language_code": "en" } ``` ### Related Pages #### Mini Apps on Telegram Bots can offer users interactive HTML5 web apps to completely replace any website. ``` -------------------------------- ### contacts.resolveUsername Source: https://core.telegram.org/method/contacts_layer=38 Resolves a @username to get peer information. This method is available starting from Layer 195. ```APIDOC ## POST contacts.resolveUsername ### Description Resolve a @username to get peer info. This method is available from Layer 195 onwards. ### Method POST ### Endpoint /api/contacts/resolveUsername ### Parameters #### Query Parameters - **layer** (integer) - Required - The API layer version. #### Request Body - **username** (string) - Required - The @username to resolve. - **referer** (string) - Optional - Referrer ID from referral links. ### Request Example ```json { "username": "exampleuser" } ``` ### Response #### Success Response (200) - **peer** (Peer) - Information about the resolved peer. - **chats** (Vector) - A vector of chats associated with the peer. - **users** (Vector) - A vector of users associated with the peer. #### Response Example ```json { "peer": { "_type": "user", "id": 12345, "access_hash": "some_hash" }, "chats": [], "users": [ { "_type": "user", "id": 12345, "first_name": "Example", "last_name": "User", "username": "exampleuser" } ] } ``` ### Errors - **400 CONNECTION_LAYER_INVALID**: The API layer version is invalid. - **400 USERNAME_INVALID**: The provided username is not valid. - **400 USERNAME_NOT_OCCUPIED**: The provided username is not occupied. ``` -------------------------------- ### InputMediaWebPage Constructor Source: https://core.telegram.org/constructor/inputMediaWebPage_layer=112 Details the parameters and usage of the InputMediaWebPage constructor for creating link previews. ```APIDOC ## POST /inputMediaWebPage ### Description Specifies options that will be used to generate the link preview for the caption, or even a standalone link preview without an attached message. ### Method POST ### Endpoint /inputMediaWebPage ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **flags** (integer) - Flags, see TL conditional fields - **force_large_media** (boolean) - If set, specifies that a large media preview should be used. - **force_small_media** (boolean) - If set, specifies that a small media preview should be used. - **optional** (boolean) - If not set, a `WEBPAGE_NOT_FOUND` RPC error will be emitted if a webpage preview cannot be generated for the specified `url`; otherwise, no error will be emitted (unless the provided message is also empty, in which case a `MESSAGE_EMPTY` will be emitted, instead). - **url** (string) - The URL to use for the link preview. ### Request Example ```json { "flags": 0, "force_large_media": false, "force_small_media": false, "optional": true, "url": "https://example.com" } ``` ### Response #### Success Response (200) This endpoint typically returns a success status or an object representing the generated link preview. The exact structure depends on the Telegram API implementation. #### Response Example ```json { "ok": true, "result": { "type": "webpage", "url": "https://example.com", "title": "Example Domain", "description": "This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.", "photo": { "url": "https://example.com/image.jpg", "width": 800, "height": 600 } } } ``` ``` -------------------------------- ### updateAttachMenuBots Source: https://core.telegram.org/constructor/updateAttachMenuBots_layer=18 This update is sent when the list of installed attachment menu entries has changed. To get the updated list, you should call messages.getAttachMenuBots. ```APIDOC ## updateAttachMenuBots ### Description Notifies that the list of installed attachment menu entries has changed. After receiving this update, clients should call `messages.getAttachMenuBots` to fetch the updated list of attachment menu bots. ### Method Update ### Endpoint N/A (This is an update notification, not a direct API endpoint to call) ### Parameters This update does not have any specific parameters. ### Request Example N/A ### Response N/A (This is an update notification) ### Related Pages - [messages.getAttachMenuBots](messages.getAttachMenuBots.md) - [Bot attachment menu and side menu entries](bot_attachment_menu.md) ``` -------------------------------- ### User Authorization Source: https://core.telegram.org/constructor/codeSettings_layer=168 Guides on how to register a user's phone number to start using the API. ```APIDOC ## User Authorization ### Description This documentation outlines the process for registering a user's phone number to enable API usage. ### Method POST ### Endpoint `/api/auth/register` ### Parameters #### Request Body - **phone_number** (string) - The user's phone number in E.164 format. - **phone_code_hash** (string) - The hash received after sending the phone code. - **code** (string) - The authentication code sent to the user's phone. - **settings** (object) - Optional: CodeSettings object to configure code delivery preferences. ### Request Example ```json { "phone_number": "+12345678900", "phone_code_hash": "some_hash_value", "code": "12345", "settings": { "allow_flashcall": true } } ``` ### Response #### Success Response (200) - **user** (object) - Details of the authenticated user. - **auth_key** (string) - The authentication key for subsequent requests. #### Response Example ```json { "user": { "id": 12345, "first_name": "John", "last_name": "Doe" }, "auth_key": "some_auth_key_value" } ``` ```