Letgram Bot API
The Letgram Bot API allows you to build bots that interact with users through the Letgram messaging platform. Bots are special accounts operated by software, capable of responding to messages, managing groups, processing payments, running inline queries, and much more.
What are bots?
Bots are third-party applications that run inside Letgram. Users can interact with bots by sending them messages, commands, and inline requests. Bot developers can use the Letgram Bot API to send text messages, media, keyboards, and more in response.
Bots can:
- Send and receive messages in private chats, groups, and channels
- Provide custom keyboards and inline buttons
- Accept payments from users
- Run Mini Apps (Web Apps) inside the Letgram client
- Respond to inline queries from any chat
- Post, edit, and delete stories
- Manage group and channel settings
How to create a bot
To create a new bot, start a conversation with @BotGod in Letgram. Send the command /newbot and follow the instructions. You will receive an API token that authenticates your bot and grants access to the Bot API.
Other useful commands for @BotGod:
/mybots— list your bots/setname— change bot display name/setdescription— change bot description/setabouttext— change bot about info/setuserpic— change bot profile photo/setcommands— set command list/deletebot— delete a bot/token— generate a new token/revoke— revoke current token
Authentication
Each bot is identified by a unique token in the format:
123456789:ABCDefgh-IJKLmnop_QRSTuvwxyz1234567
The token is a string composed of the bot's numeric ID, a colon, and a random alphanumeric string. Keep your token secure — anyone with the token can control your bot.
Making Requests
All API requests are made via HTTPS POST or GET to:
https://api.letgram.ru/bot<token>/METHOD_NAME
Parameters can be passed as:
- URL query string
application/x-www-form-urlencodedapplication/json(except for file uploads)multipart/form-data(required for file uploads)
All method names are case-insensitive.
Example request
curl -X POST "https://api.letgram.ru/bot123456:ABC-DEF/sendMessage" \
-H "Content-Type: application/json" \
-d '{"chat_id": 12345, "text": "Hello from Letgram!"}'
import requests
TOKEN = "123456:ABC-DEF"
url = f"https://api.letgram.ru/bot{TOKEN}/sendMessage"
response = requests.post(url, json={
"chat_id": 12345,
"text": "Hello from Letgram!"
})
print(response.json())
const TOKEN = "123456:ABC-DEF";
const res = await fetch(
`https://api.letgram.ru/bot${TOKEN}/sendMessage`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
chat_id: 12345,
text: "Hello from Letgram!"
})
}
);
const data = await res.json();
console.log(data);
Response Format
All responses are JSON objects. A successful response has the following structure:
{
"ok": true,
"result": { ... }
}
An error response:
{
"ok": false,
"error_code": 400,
"description": "Bad Request: chat not found"
}
The result field contains the response data. Its type depends on the method called. The error_code field corresponds to HTTP status codes.
Getting Updates
There are two ways to receive updates from Letgram: long polling via getUpdates, or webhooks via setWebhook. Only one method can be active at a time.
getUpdates
Use this method to receive incoming updates using long polling. Returns an Array of Update objects.
| Parameter | Type | Required | Description |
|---|---|---|---|
| offset | Integer | Optional | Identifier of the first update to be returned. Must be greater than the highest update_id previously received. By default, updates starting with the earliest unconfirmed update are returned. |
| limit | Integer | Optional | Limits the number of updates returned. Values between 1-100 accepted. Defaults to 100. |
| timeout | Integer | Optional | Timeout in seconds for long polling. Defaults to 0 (short polling). Should be positive for production use. |
| allowed_updates | Array of String | Optional | List of update types to receive. Specify an empty list to receive all update types except chat_member. Available: message, edited_message, channel_post, edited_channel_post, inline_query, chosen_inline_result, callback_query, shipping_query, pre_checkout_query, poll, poll_answer, my_chat_member, chat_member. |
curl "https://api.letgram.ru/bot<token>/getUpdates?timeout=30&offset=0"
response = requests.get(f"https://api.letgram.ru/bot{TOKEN}/getUpdates", params={
"timeout": 30,
"offset": 0
})
const res = await fetch(
`https://api.letgram.ru/bot${TOKEN}/getUpdates?timeout=30&offset=0`
);
const updates = await res.json();
setWebhook
Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update, Letgram will send an HTTPS POST request to the specified URL containing a JSON-serialized Update. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | String | Yes | HTTPS URL to send updates to. Use an empty string to remove webhook integration. |
| certificate | InputFile | Optional | Upload your public key certificate for webhook verification. |
| ip_address | String | Optional | Fixed IP address to send webhook requests to instead of resolving the URL via DNS. |
| max_connections | Integer | Optional | Maximum allowed simultaneous HTTPS connections for update delivery. 1-100. Defaults to 40. |
| allowed_updates | Array of String | Optional | List of update types to receive. See getUpdates for available types. |
| drop_pending_updates | Boolean | Optional | Pass True to drop all pending updates. |
| secret_token | String | Optional | A secret token (1-256 chars) to be sent in X-Letgram-Bot-Api-Secret-Token header for verification. |
deleteWebhook
Use this method to remove webhook integration. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| drop_pending_updates | Boolean | Optional | Pass True to drop all pending updates. |
getWebhookInfo
Use this method to get current webhook status. Requires no parameters. Returns a WebhookInfo object.
The WebhookInfo object contains fields: url, has_custom_certificate, pending_update_count, ip_address, last_error_date, last_error_message, last_synchronization_error_date, max_connections, allowed_updates.
Update Object
This object represents an incoming update. At most one of the optional parameters can be present in any given update.
| Field | Type | Description |
|---|---|---|
| update_id | Integer | The update's unique identifier. Update identifiers start from a positive number and increase sequentially. |
| message | Message | New incoming message of any kind. |
| edited_message | Message | New version of a message that was edited. |
| channel_post | Message | New incoming channel post. |
| edited_channel_post | Message | Edited channel post. |
| inline_query | InlineQuery | New incoming inline query. |
| chosen_inline_result | ChosenInlineResult | Result of an inline query chosen by the user. |
| callback_query | CallbackQuery | New incoming callback query. |
| shipping_query | ShippingQuery | New incoming shipping query (payments only). |
| pre_checkout_query | PreCheckoutQuery | New incoming pre-checkout query (payments only). |
| poll | Poll | New poll state (stopped or received a new answer). |
| poll_answer | PollAnswer | A user changed their answer in a non-anonymous poll. |
| my_chat_member | ChatMemberUpdated | Bot's chat member status was updated. |
| chat_member | ChatMemberUpdated | A chat member's status was updated. |
Available Types
All types used in the Bot API are described below. Optional fields may not be present in every object.
User
This object represents a Letgram user or bot.
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique identifier for this user or bot. |
| is_bot | Boolean | True, if this user is a bot. |
| first_name | String | User's or bot's first name. |
| last_name | String | Optional. User's or bot's last name. |
| username | String | Optional. User's or bot's username. |
| language_code | String | Optional. IETF language tag of the user's language. |
| is_premium | Boolean | Optional. True, if this user has Letgram Premium. |
| can_join_groups | Boolean | Optional. True, if the bot can be invited to groups. Returned only in getMe. |
| can_read_all_group_messages | Boolean | Optional. True, if privacy mode is disabled for the bot. Returned only in getMe. |
| supports_inline_queries | Boolean | Optional. True, if the bot supports inline queries. Returned only in getMe. |
Chat
This object represents a chat.
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique identifier for this chat. |
| type | String | Type of chat: private, group, supergroup, or channel. |
| title | String | Optional. Title for supergroups, channels, and group chats. |
| username | String | Optional. Username for private chats, supergroups, and channels. |
| first_name | String | Optional. First name of the other party in a private chat. |
| last_name | String | Optional. Last name of the other party in a private chat. |
| photo | ChatPhoto | Optional. Chat photo. |
| bio | String | Optional. Bio of the other party in a private chat. |
| description | String | Optional. Description for groups, supergroups, and channels. |
| invite_link | String | Optional. Primary invite link. |
| pinned_message | Message | Optional. The most recent pinned message. |
| permissions | ChatPermissions | Optional. Default chat permissions for groups and supergroups. |
| slow_mode_delay | Integer | Optional. Minimum delay between consecutive messages sent by each unprivileged user (seconds). |
| message_auto_delete_time | Integer | Optional. Time after which all messages will be auto-deleted (seconds). |
| linked_chat_id | Integer | Optional. Unique identifier of the linked chat. |
Message
This object represents a message.
| Field | Type | Description |
|---|---|---|
| message_id | Integer | Unique message identifier inside this chat. |
| from | User | Optional. Sender of the message. Empty for messages sent to channels. |
| sender_chat | Chat | Optional. Sender of the message when sent on behalf of a chat. |
| date | Integer | Date the message was sent (Unix time). |
| chat | Chat | Conversation the message belongs to. |
| forward_from | User | Optional. Sender of the original message (for forwarded messages). |
| forward_from_chat | Chat | Optional. For forwarded messages from channels, original channel. |
| forward_from_message_id | Integer | Optional. For forwarded channel messages, original message identifier. |
| forward_date | Integer | Optional. For forwarded messages, date of the original message. |
| reply_to_message | Message | Optional. The message being replied to. |
| edit_date | Integer | Optional. Date the message was last edited (Unix time). |
| text | String | Optional. Actual UTF-8 text of the message (0-4096 characters). |
| entities | Array of MessageEntity | Optional. Special entities in text (usernames, URLs, commands, etc.). |
| animation | Animation | Optional. Message is an animation (GIF). |
| audio | Audio | Optional. Message is an audio file. |
| document | Document | Optional. Message is a general file. |
| photo | Array of PhotoSize | Optional. Message is a photo, available sizes. |
| sticker | Sticker | Optional. Message is a sticker. |
| video | Video | Optional. Message is a video. |
| video_note | VideoNote | Optional. Message is a video note (round video). |
| voice | Voice | Optional. Message is a voice message. |
| caption | String | Optional. Caption for animation, audio, document, photo, video (0-1024 chars). |
| caption_entities | Array of MessageEntity | Optional. Special entities in the caption. |
| contact | Contact | Optional. Message is a shared contact. |
| dice | Dice | Optional. Message is a dice with random value. |
| poll | Poll | Optional. Message is a native poll. |
| venue | Venue | Optional. Message is a venue. |
| location | Location | Optional. Message is a shared location. |
| new_chat_members | Array of User | Optional. New members added to the group or supergroup. |
| left_chat_member | User | Optional. A member was removed from the group. |
| new_chat_title | String | Optional. Group title was changed. |
| new_chat_photo | Array of PhotoSize | Optional. Group photo was changed. |
| pinned_message | Message | Optional. A message was pinned. |
| web_app_data | WebAppData | Optional. Data sent from a Mini App. |
| reply_markup | InlineKeyboardMarkup | Optional. Inline keyboard attached to the message. |
MessageEntity
This object represents one special entity in a text message (hashtag, username, URL, etc.).
| Field | Type | Description |
|---|---|---|
| type | String | Type of the entity. One of: mention, hashtag, cashtag, bot_command, url, email, phone_number, bold, italic, underline, strikethrough, spoiler, code, pre, text_link, text_mention, custom_emoji. |
| offset | Integer | Offset in UTF-16 code units to the start of the entity. |
| length | Integer | Length of the entity in UTF-16 code units. |
| url | String | Optional. URL that will be opened when the user taps on the entity (for text_link). |
| user | User | Optional. Mentioned user (for text_mention). |
| language | String | Optional. Programming language of the entity text (for pre). |
| custom_emoji_id | String | Optional. Unique identifier of the custom emoji (for custom_emoji). |
Media Types
PhotoSize
| Field | Type | Description |
|---|---|---|
| file_id | String | Identifier for this file, which can be used to download or reuse the file. |
| file_unique_id | String | Unique identifier for this file (same over time and for different bots, cannot be used to download). |
| width | Integer | Photo width. |
| height | Integer | Photo height. |
| file_size | Integer | Optional. File size in bytes. |
Audio
| Field | Type | Description |
|---|---|---|
| file_id | String | Identifier for this file. |
| file_unique_id | String | Unique identifier for this file. |
| duration | Integer | Duration of the audio in seconds. |
| performer | String | Optional. Performer of the audio. |
| title | String | Optional. Title of the audio. |
| file_name | String | Optional. Original filename. |
| mime_type | String | Optional. MIME type. |
| file_size | Integer | Optional. File size in bytes. |
| thumbnail | PhotoSize | Optional. Thumbnail of the album cover. |
Document
| Field | Type | Description |
|---|---|---|
| file_id | String | Identifier for this file. |
| file_unique_id | String | Unique identifier for this file. |
| thumbnail | PhotoSize | Optional. Document thumbnail. |
| file_name | String | Optional. Original filename. |
| mime_type | String | Optional. MIME type. |
| file_size | Integer | Optional. File size in bytes. |
Video
| Field | Type | Description |
|---|---|---|
| file_id | String | Identifier for this file. |
| file_unique_id | String | Unique identifier for this file. |
| width | Integer | Video width. |
| height | Integer | Video height. |
| duration | Integer | Duration in seconds. |
| thumbnail | PhotoSize | Optional. Video thumbnail. |
| file_name | String | Optional. Original filename. |
| mime_type | String | Optional. MIME type. |
| file_size | Integer | Optional. File size in bytes. |
Animation
| Field | Type | Description |
|---|---|---|
| file_id | String | Identifier for this file. |
| file_unique_id | String | Unique identifier for this file. |
| width | Integer | Video width. |
| height | Integer | Video height. |
| duration | Integer | Duration in seconds. |
| thumbnail | PhotoSize | Optional. Animation thumbnail. |
| file_name | String | Optional. Original filename. |
| mime_type | String | Optional. MIME type. |
| file_size | Integer | Optional. File size in bytes. |
Voice
| Field | Type | Description |
|---|---|---|
| file_id | String | Identifier for this file. |
| file_unique_id | String | Unique identifier for this file. |
| duration | Integer | Duration in seconds. |
| mime_type | String | Optional. MIME type. |
| file_size | Integer | Optional. File size in bytes. |
VideoNote
| Field | Type | Description |
|---|---|---|
| file_id | String | Identifier for this file. |
| file_unique_id | String | Unique identifier for this file. |
| length | Integer | Video width and height (diameter of the circular video). |
| duration | Integer | Duration in seconds. |
| thumbnail | PhotoSize | Optional. Video note thumbnail. |
| file_size | Integer | Optional. File size in bytes. |
Contact, Location, Venue
Contact
| Field | Type | Description |
|---|---|---|
| phone_number | String | Contact's phone number. |
| first_name | String | Contact's first name. |
| last_name | String | Optional. Contact's last name. |
| user_id | Integer | Optional. Contact's user identifier in Letgram. |
| vcard | String | Optional. Additional data about the contact in vCard format. |
Location
| Field | Type | Description |
|---|---|---|
| longitude | Float | Longitude as defined by sender. |
| latitude | Float | Latitude as defined by sender. |
| horizontal_accuracy | Float | Optional. Radius of uncertainty for the location, meters (0-1500). |
| live_period | Integer | Optional. Time relative to the message sending date during which the location can be updated (seconds). |
| heading | Integer | Optional. Direction in which the user is moving (degrees, 1-360). |
| proximity_alert_radius | Integer | Optional. Max distance for proximity alerts (meters). |
Venue
| Field | Type | Description |
|---|---|---|
| location | Location | Venue location. |
| title | String | Name of the venue. |
| address | String | Address of the venue. |
| foursquare_id | String | Optional. Foursquare identifier of the venue. |
| foursquare_type | String | Optional. Foursquare type of the venue. |
| google_place_id | String | Optional. Google Places identifier of the venue. |
| google_place_type | String | Optional. Google Places type of the venue. |
Poll
| Field | Type | Description |
|---|---|---|
| id | String | Unique poll identifier. |
| question | String | Poll question (1-300 characters). |
| options | Array of PollOption | List of poll options. |
| total_voter_count | Integer | Total number of users that voted. |
| is_closed | Boolean | True, if the poll is closed. |
| is_anonymous | Boolean | True, if the poll is anonymous. |
| type | String | Poll type: regular or quiz. |
| allows_multiple_answers | Boolean | True, if the poll allows multiple answers. |
| correct_option_id | Integer | Optional. 0-based index of the correct option (quiz polls). |
| explanation | String | Optional. Text shown when a user selects an incorrect answer (quiz polls). |
| open_period | Integer | Optional. Time in seconds the poll will be active after creation. |
| close_date | Integer | Optional. Unix timestamp when the poll will be automatically closed. |
PollOption
| Field | Type | Description |
|---|---|---|
| text | String | Option text (1-100 characters). |
| voter_count | Integer | Number of users that voted for this option. |
Keyboards
InlineKeyboardMarkup
This object represents an inline keyboard that appears right next to the message it belongs to.
| Field | Type | Description |
|---|---|---|
| inline_keyboard | Array of Array of InlineKeyboardButton | Array of button rows, each represented by an array of InlineKeyboardButton objects. |
InlineKeyboardButton
| Field | Type | Description |
|---|---|---|
| text | String | Label text on the button. |
| url | String | Optional. HTTP/HTTPS URL to open when button is pressed. |
| callback_data | String | Optional. Data to be sent in a callback query when button is pressed (1-64 bytes). |
| web_app | WebAppInfo | Optional. Description of the Mini App to launch. |
| switch_inline_query | String | Optional. Pressing the button will prompt the user to select a chat and insert the bot's username and the specified inline query. |
| switch_inline_query_current_chat | String | Optional. Pressing the button will insert the bot's username and the specified inline query in the current chat. |
| pay | Boolean | Optional. Specify True to send a Pay button. |
ReplyKeyboardMarkup
This object represents a custom keyboard with reply options.
| Field | Type | Description |
|---|---|---|
| keyboard | Array of Array of KeyboardButton | Array of button rows. |
| is_persistent | Boolean | Optional. Requests the keyboard to always be shown. |
| resize_keyboard | Boolean | Optional. Requests clients to resize the keyboard vertically for optimal fit. |
| one_time_keyboard | Boolean | Optional. Requests clients to hide the keyboard after a button is pressed. |
| input_field_placeholder | String | Optional. Placeholder text in the input field (1-64 chars). |
| selective | Boolean | Optional. Show the keyboard to specific users only. |
KeyboardButton
| Field | Type | Description |
|---|---|---|
| text | String | Text of the button. If no optional fields are used, it will be sent as a message. |
| request_contact | Boolean | Optional. The user's phone number will be sent as a contact. |
| request_location | Boolean | Optional. The user's current location will be sent. |
| request_poll | KeyboardButtonPollType | Optional. The user will be asked to create a poll. |
| web_app | WebAppInfo | Optional. Launch a Mini App. |
ReplyKeyboardRemove
Removes the current custom keyboard and displays the default letter-keyboard.
| Field | Type | Description |
|---|---|---|
| remove_keyboard | Boolean | Requests clients to remove the custom keyboard. Always True. |
| selective | Boolean | Optional. Remove for specific users only. |
CallbackQuery
| Field | Type | Description |
|---|---|---|
| id | String | Unique identifier for this query. |
| from | User | Sender. |
| message | Message | Optional. Message with the callback button that originated the query. |
| inline_message_id | String | Optional. Identifier of the message sent via the bot in inline mode. |
| chat_instance | String | Global identifier, uniquely corresponding to the chat. |
| data | String | Optional. Data associated with the callback button (1-64 bytes). |
| game_short_name | String | Optional. Short name of a Game to be returned. |
WebApp Types
WebAppInfo
| Field | Type | Description |
|---|---|---|
| url | String | An HTTPS URL of a Mini App to be opened. |
WebAppData
| Field | Type | Description |
|---|---|---|
| data | String | The data. Can be an arbitrary string. |
| button_text | String | Text of the web_app keyboard button from which the Mini App was opened. |
Available Methods
getMe
A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.
curl "https://api.letgram.ru/bot<token>/getMe"
response = requests.get(f"https://api.letgram.ru/bot{TOKEN}/getMe")
print(response.json())
const res = await fetch(`https://api.letgram.ru/bot${TOKEN}/getMe`);
const me = await res.json();
logOut
Use this method to log out from the cloud Bot API server. Returns True on success. You must log out the bot before running it locally.
close
Use this method to close the bot instance. Returns True on success. Use before moving a bot from one local server to another.
sendMessage
Use this method to send text messages. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Unique identifier for the target chat or username of the target channel (e.g. @channelusername). |
| message_thread_id | Integer | Optional | Unique identifier for the target message thread (topic) of the forum. |
| text | String | Yes | Text of the message to be sent (1-4096 characters). |
| parse_mode | String | Optional | Mode for parsing entities: MarkdownV2, HTML, or Markdown. |
| entities | Array of MessageEntity | Optional | List of special entities in the message text (instead of parse_mode). |
| disable_web_page_preview | Boolean | Optional | Disables link previews for links in this message. |
| disable_notification | Boolean | Optional | Sends the message silently. Users will receive a notification with no sound. |
| protect_content | Boolean | Optional | Protects the contents of the sent message from forwarding and saving. |
| reply_to_message_id | Integer | Optional | If the message is a reply, ID of the original message. |
| allow_sending_without_reply | Boolean | Optional | Pass True if the message should be sent even if the specified replied-to message is not found. |
| reply_markup | InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply | Optional | Additional interface options (keyboards, force reply, etc.). |
curl -X POST "https://api.letgram.ru/bot<token>/sendMessage" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 12345678,
"text": "Hello! This is a *bold* message with an [inline link](https://letgram.ru)",
"parse_mode": "MarkdownV2"
}'
import requests
TOKEN = "YOUR_BOT_TOKEN"
url = f"https://api.letgram.ru/bot{TOKEN}/sendMessage"
response = requests.post(url, json={
"chat_id": 12345678,
"text": "Hello! This is a bold message",
"parse_mode": "HTML",
"reply_markup": {
"inline_keyboard": [[
{"text": "Visit Letgram", "url": "https://letgram.ru"},
{"text": "Click me", "callback_data": "btn_click"}
]]
}
})
print(response.json())
const TOKEN = "YOUR_BOT_TOKEN";
const res = await fetch(`https://api.letgram.ru/bot${TOKEN}/sendMessage`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
chat_id: 12345678,
text: "Hello! This is a bold message",
parse_mode: "HTML",
reply_markup: {
inline_keyboard: [[
{ text: "Visit Letgram", url: "https://letgram.ru" },
{ text: "Click me", callback_data: "btn_click" }
]]
}
})
});
console.log(await res.json());
forwardMessage
Use this method to forward messages of any kind. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| from_chat_id | Integer or String | Yes | Chat where the original message was sent. |
| disable_notification | Boolean | Optional | Sends the message silently. |
| protect_content | Boolean | Optional | Protects the message from forwarding and saving. |
| message_id | Integer | Yes | Message identifier in the chat specified in from_chat_id. |
copyMessage
Use this method to copy messages of any kind. The method is analogous to forwardMessage, but the copied message doesn't have a link to the original. Returns the MessageId of the sent message.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| from_chat_id | Integer or String | Yes | Chat where the original message was sent. |
| message_id | Integer | Yes | Message identifier in the chat specified in from_chat_id. |
| caption | String | Optional | New caption for media (0-1024 chars). |
| parse_mode | String | Optional | Mode for parsing entities in the caption. |
| disable_notification | Boolean | Optional | Sends the message silently. |
| protect_content | Boolean | Optional | Protects the message. |
| reply_to_message_id | Integer | Optional | If the message is a reply, ID of the original message. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
Send Media
sendPhoto
Use this method to send photos. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| photo | InputFile or String | Yes | Photo to send. Pass a file_id as String to send a photo that exists on the Letgram servers, pass an HTTP URL to send a photo from the Internet, or upload a new photo using multipart/form-data. |
| caption | String | Optional | Photo caption (0-1024 characters). |
| parse_mode | String | Optional | Mode for parsing entities in the caption. |
| has_spoiler | Boolean | Optional | Pass True if the photo needs to be covered with a spoiler animation. |
| disable_notification | Boolean | Optional | Sends the message silently. |
| protect_content | Boolean | Optional | Protects the message. |
| reply_to_message_id | Integer | Optional | If the message is a reply. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
# Send photo by URL
curl -X POST "https://api.letgram.ru/bot<token>/sendPhoto" \
-H "Content-Type: application/json" \
-d '{"chat_id": 12345678, "photo": "https://example.com/photo.jpg", "caption": "Beautiful photo!"}'
# Upload photo file
curl -X POST "https://api.letgram.ru/bot<token>/sendPhoto" \
-F "chat_id=12345678" \
-F "photo=@/path/to/photo.jpg" \
-F "caption=Uploaded photo!"
# Send by URL
requests.post(f"https://api.letgram.ru/bot{TOKEN}/sendPhoto", json={
"chat_id": 12345678,
"photo": "https://example.com/photo.jpg",
"caption": "Beautiful photo!"
})
# Upload file
with open("photo.jpg", "rb") as f:
requests.post(f"https://api.letgram.ru/bot{TOKEN}/sendPhoto",
data={"chat_id": 12345678, "caption": "Uploaded!"},
files={"photo": f}
)
// Send by URL
await fetch(`https://api.letgram.ru/bot${TOKEN}/sendPhoto`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
chat_id: 12345678,
photo: "https://example.com/photo.jpg",
caption: "Beautiful photo!"
})
});
sendAudio
Use this method to send audio files (mp3 format, up to 50 MB). On success, the sent Message is returned. For voice messages, use sendVoice instead.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| audio | InputFile or String | Yes | Audio file to send. |
| caption | String | Optional | Audio caption (0-1024 chars). |
| parse_mode | String | Optional | Mode for parsing entities in the caption. |
| duration | Integer | Optional | Duration of the audio in seconds. |
| performer | String | Optional | Performer. |
| title | String | Optional | Track name. |
| thumbnail | InputFile or String | Optional | Thumbnail of the file. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendDocument
Use this method to send general files (up to 50 MB). On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| document | InputFile or String | Yes | File to send. |
| thumbnail | InputFile or String | Optional | Thumbnail of the file. |
| caption | String | Optional | Document caption (0-1024 chars). |
| parse_mode | String | Optional | Mode for parsing entities. |
| disable_content_type_detection | Boolean | Optional | Disables automatic server-side content type detection for uploaded files. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendVideo
Use this method to send video files (up to 50 MB). On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| video | InputFile or String | Yes | Video to send. |
| duration | Integer | Optional | Duration in seconds. |
| width | Integer | Optional | Video width. |
| height | Integer | Optional | Video height. |
| thumbnail | InputFile or String | Optional | Thumbnail of the video. |
| caption | String | Optional | Video caption (0-1024 chars). |
| parse_mode | String | Optional | Mode for parsing entities. |
| has_spoiler | Boolean | Optional | Pass True for a spoiler animation cover. |
| supports_streaming | Boolean | Optional | Pass True if the video is suitable for streaming. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendAnimation
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound, up to 50 MB). On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| animation | InputFile or String | Yes | Animation to send. |
| duration | Integer | Optional | Duration in seconds. |
| width | Integer | Optional | Animation width. |
| height | Integer | Optional | Animation height. |
| caption | String | Optional | Animation caption (0-1024 chars). |
| has_spoiler | Boolean | Optional | Pass True for spoiler cover. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendVoice
Use this method to send audio files as a playable voice message (OPUS in OGG container, up to 50 MB). On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| voice | InputFile or String | Yes | Audio file to send as voice. |
| caption | String | Optional | Voice message caption (0-1024 chars). |
| duration | Integer | Optional | Duration in seconds. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendVideoNote
Use this method to send video messages (round videos, up to 1 minute). On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| video_note | InputFile or String | Yes | Video note to send. |
| duration | Integer | Optional | Duration in seconds. |
| length | Integer | Optional | Video width and height (diameter). |
| thumbnail | InputFile or String | Optional | Thumbnail of the video note. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendSticker
Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| sticker | InputFile or String | Yes | Sticker to send. |
| emoji | String | Optional | Emoji associated with the sticker. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendMediaGroup
Use this method to send a group of photos, videos, documents, or audios as an album. On success, an Array of Messages is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| media | Array of InputMedia | Yes | Array describing messages to be sent. Must include 2-10 items. |
| disable_notification | Boolean | Optional | Sends messages silently. |
| protect_content | Boolean | Optional | Protects the messages. |
| reply_to_message_id | Integer | Optional | If the messages are a reply. |
sendLocation
Use this method to send a point on the map. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| latitude | Float | Yes | Latitude of the location. |
| longitude | Float | Yes | Longitude of the location. |
| horizontal_accuracy | Float | Optional | Radius of uncertainty (0-1500 meters). |
| live_period | Integer | Optional | Period in seconds for live location (60-86400). |
| heading | Integer | Optional | Direction of movement (1-360 degrees). |
| proximity_alert_radius | Integer | Optional | Max distance for proximity alerts (meters). |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendVenue
Use this method to send information about a venue. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| latitude | Float | Yes | Latitude of the venue. |
| longitude | Float | Yes | Longitude of the venue. |
| title | String | Yes | Name of the venue. |
| address | String | Yes | Address of the venue. |
| foursquare_id | String | Optional | Foursquare identifier of the venue. |
| google_place_id | String | Optional | Google Places identifier of the venue. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendContact
Use this method to send phone contacts. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| phone_number | String | Yes | Contact's phone number. |
| first_name | String | Yes | Contact's first name. |
| last_name | String | Optional | Contact's last name. |
| vcard | String | Optional | Additional data in vCard format (0-2048 bytes). |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendPoll
Use this method to send a native poll. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| question | String | Yes | Poll question (1-300 characters). |
| options | Array of String | Yes | List of answer options (2-10 strings, 1-100 chars each). |
| is_anonymous | Boolean | Optional | True for anonymous poll. Defaults to True. |
| type | String | Optional | Poll type: quiz or regular. Defaults to regular. |
| allows_multiple_answers | Boolean | Optional | True if the poll allows multiple answers (regular polls only). |
| correct_option_id | Integer | Optional | 0-based index of the correct answer (quiz polls, required for quiz). |
| explanation | String | Optional | Text shown after user selects an incorrect answer (0-200 chars). |
| open_period | Integer | Optional | Time in seconds the poll will be active (5-600). |
| close_date | Integer | Optional | Unix timestamp when the poll will be closed. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendDice
Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| emoji | String | Optional | Emoji on which the dice throw animation is based. Currently one of: dice, darts, basketball, football, bowling, slot machine. Defaults to dice. |
| reply_markup | Keyboard markup | Optional | Additional interface options. |
sendChatAction
Use this method to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| action | String | Yes | Type of action: typing, upload_photo, record_video, upload_video, record_voice, upload_voice, upload_document, choose_sticker, find_location, record_video_note, upload_video_note. |
User & Files
getUserProfilePhotos
Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | Integer | Yes | Unique identifier of the target user. |
| offset | Integer | Optional | Sequential number of the first photo to be returned. |
| limit | Integer | Optional | Limits the number of photos to be retrieved (1-100). Defaults to 100. |
getFile
Use this method to get basic information about a file and prepare it for downloading. The file can then be downloaded from https://api.letgram.ru/file/bot<token>/<file_path>. Files up to 20 MB in size can be downloaded.
| Parameter | Type | Required | Description |
|---|---|---|---|
| file_id | String | Yes | File identifier to get information about. |
# Step 1: Get file path
curl "https://api.letgram.ru/bot<token>/getFile?file_id=AgACAgIA..."
# Step 2: Download the file
curl "https://api.letgram.ru/file/bot<token>/photos/file_0.jpg" -o downloaded.jpg
# Get file info
file_info = requests.get(f"https://api.letgram.ru/bot{TOKEN}/getFile",
params={"file_id": "AgACAgIA..."}).json()
# Download
file_path = file_info["result"]["file_path"]
file_data = requests.get(f"https://api.letgram.ru/file/bot{TOKEN}/{file_path}")
with open("downloaded.jpg", "wb") as f:
f.write(file_data.content)
// Get file info
const info = await fetch(
`https://api.letgram.ru/bot${TOKEN}/getFile?file_id=AgACAgIA...`
).then(r => r.json());
// Download
const filePath = info.result.file_path;
const fileData = await fetch(
`https://api.letgram.ru/file/bot${TOKEN}/${filePath}`
).then(r => r.blob());
Chat Administration
banChatMember
Use this method to ban a user in a group, supergroup, or channel. The bot must be an administrator with the appropriate rights. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| user_id | Integer | Yes | Unique identifier of the target user. |
| until_date | Integer | Optional | Unix timestamp when the user will be unbanned. If less than 366 days, the user is banned for that duration. If more than 366 days or 0, the user is banned forever. |
| revoke_messages | Boolean | Optional | Pass True to delete all messages from the user in the chat. |
unbanChatMember
Use this method to unban a previously banned user in a supergroup or channel. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| user_id | Integer | Yes | Unique identifier of the target user. |
| only_if_banned | Boolean | Optional | Do nothing if the user is not banned. |
restrictChatMember
Use this method to restrict a user in a supergroup. The bot must be an administrator with can_restrict_members rights. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| user_id | Integer | Yes | Unique identifier of the target user. |
| permissions | ChatPermissions | Yes | JSON-serialized object for new user permissions. |
| until_date | Integer | Optional | Unix timestamp when restrictions will be lifted. |
promoteChatMember
Use this method to promote or demote a user in a supergroup or channel. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| user_id | Integer | Yes | Unique identifier of the target user. |
| is_anonymous | Boolean | Optional | Pass True if the administrator's presence should be hidden. |
| can_manage_chat | Boolean | Optional | Pass True if the administrator can access the chat event log, statistics, etc. |
| can_post_messages | Boolean | Optional | Pass True if the administrator can post messages (channels only). |
| can_edit_messages | Boolean | Optional | Pass True if the administrator can edit messages (channels only). |
| can_delete_messages | Boolean | Optional | Pass True if the administrator can delete messages of other users. |
| can_manage_video_chats | Boolean | Optional | Pass True if the administrator can manage video chats. |
| can_restrict_members | Boolean | Optional | Pass True if the administrator can restrict, ban, or unban members. |
| can_promote_members | Boolean | Optional | Pass True if the administrator can add new administrators. |
| can_change_info | Boolean | Optional | Pass True if the administrator can change the chat title, photo, etc. |
| can_invite_users | Boolean | Optional | Pass True if the administrator can invite new users. |
| can_pin_messages | Boolean | Optional | Pass True if the administrator can pin messages (supergroups only). |
| can_post_stories | Boolean | Optional | Pass True if the administrator can post stories. |
| can_edit_stories | Boolean | Optional | Pass True if the administrator can edit stories. |
| can_delete_stories | Boolean | Optional | Pass True if the administrator can delete stories. |
setChatTitle
Use this method to change the title of a chat. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| title | String | Yes | New chat title (1-128 characters). |
setChatDescription
Use this method to change the description of a group, supergroup, or channel. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| description | String | Optional | New chat description (0-255 characters). |
setChatPhoto
Use this method to set a new profile photo for the chat. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| photo | InputFile | Yes | New chat photo (must be uploaded as multipart/form-data). |
pinChatMessage
Use this method to add a message to the list of pinned messages in a chat. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| message_id | Integer | Yes | Identifier of a message to pin. |
| disable_notification | Boolean | Optional | Pass True to silently pin the message. |
unpinChatMessage
Use this method to remove a message from the list of pinned messages. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| message_id | Integer | Optional | Identifier of a message to unpin. If not specified, the most recent pinned message is unpinned. |
Chat Info
leaveChat
Use this method for your bot to leave a group, supergroup, or channel. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
getChat
Use this method to get up-to-date information about the chat. Returns a Chat object.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
getChatAdministrators
Use this method to get a list of administrators in a chat (non-bots). Returns an Array of ChatMember objects.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
getChatMemberCount
Use this method to get the number of members in a chat. Returns Integer.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
getChatMember
Use this method to get information about a member of a chat. Returns a ChatMember object.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| user_id | Integer | Yes | Unique identifier of the target user. |
Bot Commands
setMyCommands
Use this method to change the list of the bot's commands. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| commands | Array of BotCommand | Yes | List of bot commands (up to 100). Each BotCommand has command (1-32 chars) and description (1-256 chars). |
| scope | BotCommandScope | Optional | Scope of users for which the commands are relevant. |
| language_code | String | Optional | Two-letter ISO 639-1 language code. |
curl -X POST "https://api.letgram.ru/bot<token>/setMyCommands" \
-H "Content-Type: application/json" \
-d '{
"commands": [
{"command": "start", "description": "Start the bot"},
{"command": "help", "description": "Show help message"},
{"command": "settings", "description": "Open settings"}
]
}'
requests.post(f"https://api.letgram.ru/bot{TOKEN}/setMyCommands", json={
"commands": [
{"command": "start", "description": "Start the bot"},
{"command": "help", "description": "Show help message"},
{"command": "settings", "description": "Open settings"}
]
})
await fetch(`https://api.letgram.ru/bot${TOKEN}/setMyCommands`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
commands: [
{ command: "start", description: "Start the bot" },
{ command: "help", description: "Show help message" },
{ command: "settings", description: "Open settings" }
]
})
});
getMyCommands
Use this method to get the current list of the bot's commands. Returns an Array of BotCommand.
| Parameter | Type | Required | Description |
|---|---|---|---|
| scope | BotCommandScope | Optional | Scope of users for which the commands are relevant. |
| language_code | String | Optional | Two-letter ISO 639-1 language code. |
deleteMyCommands
Use this method to delete the list of the bot's commands for the given scope and language. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| scope | BotCommandScope | Optional | Scope of users for which the commands are relevant. |
| language_code | String | Optional | Two-letter ISO 639-1 language code. |
Editing Messages
editMessageText
Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Optional* | Required if inline_message_id is not specified. Target chat. |
| message_id | Integer | Optional* | Required if inline_message_id is not specified. Identifier of the message to edit. |
| inline_message_id | String | Optional* | Required if chat_id and message_id are not specified. Identifier of the inline message. |
| text | String | Yes | New text of the message (1-4096 characters). |
| parse_mode | String | Optional | Mode for parsing entities in the text. |
| disable_web_page_preview | Boolean | Optional | Disables link previews. |
| reply_markup | InlineKeyboardMarkup | Optional | An inline keyboard. |
editMessageCaption
Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Optional* | Required if inline_message_id is not specified. |
| message_id | Integer | Optional* | Required if inline_message_id is not specified. |
| inline_message_id | String | Optional* | Required if chat_id and message_id are not specified. |
| caption | String | Optional | New caption (0-1024 characters). |
| parse_mode | String | Optional | Mode for parsing entities. |
| reply_markup | InlineKeyboardMarkup | Optional | An inline keyboard. |
editMessageReplyMarkup
Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Optional* | Required if inline_message_id is not specified. |
| message_id | Integer | Optional* | Required if inline_message_id is not specified. |
| inline_message_id | String | Optional* | Required if chat_id and message_id are not specified. |
| reply_markup | InlineKeyboardMarkup | Optional | An inline keyboard. |
deleteMessage
Use this method to delete a message. The bot must have the appropriate rights. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| message_id | Integer | Yes | Identifier of the message to delete. |
answerCallbackQuery
Use this method to send answers to callback queries sent from inline keyboards. On success, True is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| callback_query_id | String | Yes | Unique identifier for the query to be answered. |
| text | String | Optional | Text of the notification (0-200 characters). If not specified, nothing will be shown. |
| show_alert | Boolean | Optional | Pass True to show an alert instead of a notification at the top of the chat screen. |
| url | String | Optional | URL that will be opened by the user's client. |
| cache_time | Integer | Optional | Maximum time in seconds that the result may be cached. Defaults to 0. |
curl -X POST "https://api.letgram.ru/bot<token>/answerCallbackQuery" \
-H "Content-Type: application/json" \
-d '{"callback_query_id": "123456789", "text": "Button clicked!", "show_alert": false}'
requests.post(f"https://api.letgram.ru/bot{TOKEN}/answerCallbackQuery", json={
"callback_query_id": callback_query.id,
"text": "Button clicked!",
"show_alert": False
})
await fetch(`https://api.letgram.ru/bot${TOKEN}/answerCallbackQuery`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
callback_query_id: callbackQuery.id,
text: "Button clicked!",
show_alert: false
})
});
Inline Mode
Bots can be called from any chat via inline queries. Users type @botusername query in the text input field, and the bot receives the query and returns results that appear in a dropdown above the text field. When the user selects a result, it is sent to the chat.
To enable inline mode, send the /setinline command to @BotGod and provide a placeholder text that will be shown in the input field when the user types the bot's name.
InlineQuery
This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.
| Field | Type | Description |
|---|---|---|
| id | String | Unique identifier for this query. |
| from | User | Sender. |
| query | String | Text of the query (up to 256 characters). |
| offset | String | Offset of the results to be returned (for pagination). |
| chat_type | String | Optional. Type of the chat from which the inline query was sent: sender, private, group, supergroup, or channel. |
| location | Location | Optional. Sender location (only for bots that request user location). |
answerInlineQuery
Use this method to send answers to an inline query. No more than 50 results per query are allowed. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| inline_query_id | String | Yes | Unique identifier for the answered query. |
| results | Array of InlineQueryResult | Yes | Array of results for the inline query (max 50). |
| cache_time | Integer | Optional | Maximum time in seconds the result may be cached. Defaults to 300. |
| is_personal | Boolean | Optional | Results may be cached on the server side only for the user that sent the query. |
| next_offset | String | Optional | Offset for pagination. Pass the offset that a client should send in the next query to receive more results. |
| switch_pm_text | String | Optional | A button displayed above inline query results to switch to a private chat with the bot. |
| switch_pm_parameter | String | Optional | Deep-linking parameter for the /start message sent to the bot. |
curl -X POST "https://api.letgram.ru/bot<token>/answerInlineQuery" \
-H "Content-Type: application/json" \
-d '{
"inline_query_id": "query123",
"results": [
{
"type": "article",
"id": "1",
"title": "Result Title",
"input_message_content": {
"message_text": "This is the result message"
},
"description": "A short description"
}
]
}'
requests.post(f"https://api.letgram.ru/bot{TOKEN}/answerInlineQuery", json={
"inline_query_id": inline_query.id,
"results": [
{
"type": "article",
"id": "1",
"title": "Result Title",
"input_message_content": {
"message_text": "This is the result message"
},
"description": "A short description"
}
],
"cache_time": 60
})
await fetch(`https://api.letgram.ru/bot${TOKEN}/answerInlineQuery`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
inline_query_id: inlineQuery.id,
results: [{
type: "article",
id: "1",
title: "Result Title",
input_message_content: {
message_text: "This is the result message"
},
description: "A short description"
}],
cache_time: 60
})
});
InlineQueryResult Types
The following types of InlineQueryResult are supported:
- InlineQueryResultArticle — A link to an article or web page.
- InlineQueryResultPhoto — A link to a photo. The photo must be in JPEG format.
- InlineQueryResultGif — A link to an animated GIF file.
- InlineQueryResultMpeg4Gif — A link to a video animation (H.264/MPEG-4 AVC without sound).
- InlineQueryResultVideo — A link to a page containing an embedded video player or a video file.
- InlineQueryResultAudio — A link to an MP3 audio file.
- InlineQueryResultVoice — A link to a voice recording in an OGG container.
- InlineQueryResultDocument — A link to a file (PDF or ZIP).
- InlineQueryResultLocation — A location on a map.
- InlineQueryResultVenue — A venue with location.
- InlineQueryResultContact — A contact with a phone number.
- InlineQueryResultGame — A Game.
- InlineQueryResultCachedPhoto — A photo stored on the Letgram servers.
- InlineQueryResultCachedGif — A GIF stored on the Letgram servers.
- InlineQueryResultCachedMpeg4Gif — An MPEG4 GIF stored on the Letgram servers.
- InlineQueryResultCachedSticker — A sticker stored on the Letgram servers.
- InlineQueryResultCachedDocument — A document stored on the Letgram servers.
- InlineQueryResultCachedVideo — A video stored on the Letgram servers.
- InlineQueryResultCachedVoice — A voice note stored on the Letgram servers.
- InlineQueryResultCachedAudio — An audio file stored on the Letgram servers.
All InlineQueryResult types share common fields: type (String), id (String, up to 64 bytes), and optionally reply_markup (InlineKeyboardMarkup). Each type also has its own specific fields. See the individual type definitions for details.
Mini Apps (Web Apps)
Mini Apps allow bots to present rich, interactive web interfaces to users directly within the Letgram client. They run as embedded web pages with full access to HTML5, CSS, and JavaScript, and can communicate with the Letgram client through a dedicated JavaScript SDK.
Launching a Mini App
There are several ways to launch a Mini App:
- Keyboard button — Add a
web_appfield to aKeyboardButton - Inline button — Add a
web_appfield to anInlineKeyboardButton - Bot Menu Button — Configure via @BotGod with
/setmenubutton - Inline mode — Return a button with a
web_appfield in inline query results - Direct link —
https://letgram.ru/botusername/app
Letgram JS SDK Reference
Include the Letgram JS SDK in your Mini App:
<script src="https://letgram.ru/js/webapp.js"></script>
Once loaded, a window.Letgram.WebApp object becomes available.
WebApp Object
| Property / Method | Type | Description |
|---|---|---|
| initData | String | Raw init data string transferred to the Mini App. |
| initDataUnsafe | WebAppInitData | Parsed init data object (not validated; use server-side validation). |
| version | String | Version of the Mini Apps API available in the user's Letgram app. |
| platform | String | Name of the platform of the user's Letgram app. |
| colorScheme | String | Current color scheme: "light" or "dark". |
| themeParams | ThemeParams | Object containing theme colors (bg_color, text_color, hint_color, link_color, button_color, button_text_color, secondary_bg_color). |
| isExpanded | Boolean | True if the Mini App is expanded to its maximum height. |
| viewportHeight | Float | Current height of the visible area of the Mini App. |
| viewportStableHeight | Float | Height of the visible area in its last stable state. |
| MainButton | MainButton | Object for controlling the main button displayed at the bottom of the Mini App. |
| BackButton | BackButton | Object for controlling the back button in the Mini App header. |
| HapticFeedback | HapticFeedback | Object for controlling haptic feedback. |
| ready() | Function | Informs the Letgram app that the Mini App is ready to be displayed. |
| expand() | Function | Expands the Mini App to its maximum allowed height. |
| close() | Function | Closes the Mini App. |
| sendData(data) | Function | Sends data to the bot (up to 4096 bytes). The Mini App will be closed after the data is sent. |
| openLink(url) | Function | Opens a link in an external browser. |
| openLetgramLink(url) | Function | Opens a Letgram link inside the Letgram app. |
| showPopup(params, callback) | Function | Shows a native popup. params: title, message, buttons[]. |
| showAlert(message, callback) | Function | Shows an alert with a single "OK" button. |
| showConfirm(message, callback) | Function | Shows a confirmation dialog with "OK" and "Cancel" buttons. |
| showScanQrPopup(params, callback) | Function | Opens a native QR code scanner. |
| closeScanQrPopup() | Function | Closes the QR code scanner. |
| readTextFromClipboard(callback) | Function | Reads text from the clipboard. |
| requestWriteAccess(callback) | Function | Requests permission to send messages to the user. |
| requestContact(callback) | Function | Requests the user's contact information. |
MainButton
| Property / Method | Type | Description |
|---|---|---|
| text | String | Current button text. Setter available. |
| color | String | Current button color. Setter available. |
| textColor | String | Current button text color. Setter available. |
| isVisible | Boolean | Whether the button is visible. |
| isActive | Boolean | Whether the button is active (clickable). |
| isProgressVisible | Boolean | Whether a loading indicator is shown. |
| setText(text) | Function | Set the button text. |
| onClick(callback) | Function | Set a handler for the button press event. |
| offClick(callback) | Function | Remove a handler for the button press event. |
| show() | Function | Make the button visible. |
| hide() | Function | Hide the button. |
| enable() | Function | Enable the button. |
| disable() | Function | Disable the button. |
| showProgress(leaveActive) | Function | Show a loading indicator on the button. |
| hideProgress() | Function | Hide the loading indicator. |
| setParams(params) | Function | Set multiple button parameters at once: text, color, text_color, is_active, is_visible. |
BackButton
| Property / Method | Type | Description |
|---|---|---|
| isVisible | Boolean | Whether the button is visible. |
| onClick(callback) | Function | Set a handler for the button press event. |
| offClick(callback) | Function | Remove a handler. |
| show() | Function | Show the back button. |
| hide() | Function | Hide the back button. |
HapticFeedback
| Method | Description |
|---|---|
| impactOccurred(style) | Trigger an impact haptic event. style: "light", "medium", "heavy", "rigid", or "soft". |
| notificationOccurred(type) | Trigger a notification haptic event. type: "error", "success", or "warning". |
| selectionChanged() | Trigger a selection change haptic event. |
Events
The Mini App can subscribe to events from the Letgram client using Letgram.WebApp.onEvent(eventType, callback):
| Event | Description |
|---|---|
| themeChanged | Occurs when the theme used in the Letgram app changes. |
| viewportChanged | Occurs when the visible section of the Mini App is changed. Handler receives {isStateStable: Boolean}. |
| mainButtonClicked | Occurs when the main button is pressed. |
| backButtonClicked | Occurs when the back button is pressed. |
| settingsButtonClicked | Occurs when the Settings button in the context menu is pressed. |
| invoiceClosed | Occurs when an opened invoice is closed. Handler receives {url: String, status: String}. Status: "paid", "cancelled", "failed", "pending". |
| popupClosed | Occurs when a popup is closed. Handler receives {button_id: String | null}. |
| qrTextReceived | Occurs when QR code text is received. Handler receives {data: String}. |
| clipboardTextReceived | Occurs when clipboard content is received. Handler receives {data: String | null}. |
| writeAccessRequested | Occurs when write access request is completed. Handler receives {status: "allowed" | "cancelled"}. |
| contactRequested | Occurs when contact request is completed. Handler receives {status: "sent" | "cancelled"}. |
initData Format
The init data is a query string that contains the following fields:
| Field | Type | Description |
|---|---|---|
| query_id | String | Optional. A unique identifier for the Mini App session. |
| user | WebAppUser | Optional. JSON-serialized object containing data about the current user. |
| receiver | WebAppUser | Optional. Object containing data about the chat partner (private chats only). |
| chat | WebAppChat | Optional. Object containing data about the chat. |
| chat_type | String | Optional. Type of the chat. |
| chat_instance | String | Optional. Global identifier of the chat. |
| start_param | String | Optional. Value of the startattach parameter. |
| can_send_after | Integer | Optional. Number of seconds after which the bot can send messages to the user. |
| auth_date | Integer | Unix timestamp when the form was opened. |
| hash | String | Hash of all passed parameters, used for data integrity validation. |
hash, sorted alphabetically by key. Then compute HMAC-SHA256(secret_key, data_check_string) where secret_key = HMAC-SHA256("WebAppData", bot_token). Compare the result with the hash field.Example Mini App
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Mini App</title>
<script src="https://letgram.ru/js/webapp.js"></script>
<style>
body {
font-family: -apple-system, sans-serif;
background: var(--tg-theme-bg-color, #fff);
color: var(--tg-theme-text-color, #000);
padding: 20px;
}
.btn {
background: var(--tg-theme-button-color, #6B5CD9);
color: var(--tg-theme-button-text-color, #fff);
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Welcome to My Mini App</h1>
<p>Hello, <span id="name"></span>!</p>
<button class="btn" onclick="submitData()">Submit</button>
<script>
const webapp = window.Letgram.WebApp;
webapp.ready();
webapp.expand();
// Display user name
const user = webapp.initDataUnsafe.user;
if (user) {
document.getElementById("name").textContent = user.first_name;
}
// Configure main button
webapp.MainButton.setText("Confirm");
webapp.MainButton.show();
webapp.MainButton.onClick(() => {
webapp.sendData(JSON.stringify({ action: "confirmed" }));
});
// Back button
webapp.BackButton.show();
webapp.BackButton.onClick(() => {
webapp.close();
});
// Haptic feedback on button click
function submitData() {
webapp.HapticFeedback.impactOccurred("medium");
webapp.showAlert("Data submitted successfully!");
}
</script>
</body>
</html>
Payments
Letgram bots can accept payments from users. The payment flow involves sending an invoice, handling shipping queries (if applicable), and confirming pre-checkout queries.
sendInvoice
Use this method to send invoices. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Target chat. |
| title | String | Yes | Product name (1-32 characters). |
| description | String | Yes | Product description (1-255 characters). |
| payload | String | Yes | Bot-defined invoice payload (1-128 bytes). Not displayed to the user. |
| provider_token | String | Yes | Payment provider token obtained via @BotGod. |
| currency | String | Yes | Three-letter ISO 4217 currency code (e.g. RUB, USD, EUR). |
| prices | Array of LabeledPrice | Yes | Price breakdown. Each LabeledPrice has label (String) and amount (Integer, in the smallest currency unit, e.g. kopecks). |
| max_tip_amount | Integer | Optional | Maximum accepted tip amount in the smallest currency unit. |
| suggested_tip_amounts | Array of Integer | Optional | Array of suggested tip amounts (up to 4). |
| photo_url | String | Optional | URL of the product photo. |
| photo_size | Integer | Optional | Photo size in bytes. |
| photo_width | Integer | Optional | Photo width. |
| photo_height | Integer | Optional | Photo height. |
| need_name | Boolean | Optional | Pass True to request the user's full name. |
| need_phone_number | Boolean | Optional | Pass True to request the user's phone number. |
| need_email | Boolean | Optional | Pass True to request the user's email. |
| need_shipping_address | Boolean | Optional | Pass True to request the user's shipping address. |
| send_phone_number_to_provider | Boolean | Optional | Pass True to send the user's phone number to the payment provider. |
| send_email_to_provider | Boolean | Optional | Pass True to send the user's email to the payment provider. |
| is_flexible | Boolean | Optional | Pass True if the final price depends on the shipping method. |
| reply_markup | InlineKeyboardMarkup | Optional | Inline keyboard. The first button must be a pay button. |
curl -X POST "https://api.letgram.ru/bot<token>/sendInvoice" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 12345678,
"title": "Premium Subscription",
"description": "Monthly premium access",
"payload": "premium_monthly_001",
"provider_token": "YOUR_PROVIDER_TOKEN",
"currency": "RUB",
"prices": [{"label": "Premium", "amount": 29900}]
}'
requests.post(f"https://api.letgram.ru/bot{TOKEN}/sendInvoice", json={
"chat_id": 12345678,
"title": "Premium Subscription",
"description": "Monthly premium access",
"payload": "premium_monthly_001",
"provider_token": "YOUR_PROVIDER_TOKEN",
"currency": "RUB",
"prices": [{"label": "Premium", "amount": 29900}]
})
await fetch(`https://api.letgram.ru/bot${TOKEN}/sendInvoice`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
chat_id: 12345678,
title: "Premium Subscription",
description: "Monthly premium access",
payload: "premium_monthly_001",
provider_token: "YOUR_PROVIDER_TOKEN",
currency: "RUB",
prices: [{ label: "Premium", amount: 29900 }]
})
});
createInvoiceLink
Use this method to create a link for an invoice. Returns the created invoice link as a String on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| title | String | Yes | Product name (1-32 chars). |
| description | String | Yes | Product description (1-255 chars). |
| payload | String | Yes | Bot-defined invoice payload (1-128 bytes). |
| provider_token | String | Yes | Payment provider token. |
| currency | String | Yes | Three-letter ISO 4217 currency code. |
| prices | Array of LabeledPrice | Yes | Price breakdown. |
answerShippingQuery
Use this method to reply to shipping queries. If you sent an invoice requesting a shipping address and set is_flexible to True, the Bot API will send an Update with a shipping_query field. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| shipping_query_id | String | Yes | Unique identifier for the query. |
| ok | Boolean | Yes | True if delivery to the specified address is possible. |
| shipping_options | Array of ShippingOption | Optional | Required if ok is True. Available shipping options. |
| error_message | String | Optional | Required if ok is False. Error message explaining why delivery is impossible. |
answerPreCheckoutQuery
Use this method to respond to pre-checkout queries. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| pre_checkout_query_id | String | Yes | Unique identifier for the query. |
| ok | Boolean | Yes | True if everything is alright and the bot is ready to proceed with the order. |
| error_message | String | Optional | Required if ok is False. Error message explaining the reason. |
Stickers
Bots can create and manage sticker sets, and send stickers to users.
sendSticker
Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. See Send Media section for full parameter table.
getStickerSet
Use this method to get a sticker set. Returns a StickerSet object.
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | String | Yes | Name of the sticker set. |
createNewStickerSet
Use this method to create a new sticker set owned by a user. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | Integer | Yes | User identifier of created sticker set owner. |
| name | String | Yes | Short name of sticker set (1-64 chars). Must end with _by_<bot_username>. |
| title | String | Yes | Sticker set title (1-64 chars). |
| stickers | Array of InputSticker | Yes | List of 1-50 initial stickers to be added. |
| sticker_format | String | Yes | Format of stickers: static, animated, or video. |
| sticker_type | String | Optional | Type of stickers: regular, mask, or custom_emoji. Defaults to regular. |
| needs_repainting | Boolean | Optional | Pass True if stickers must be repainted to the color of text when used in messages. |
addStickerToSet
Use this method to add a new sticker to an existing set. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | Integer | Yes | User identifier of sticker set owner. |
| name | String | Yes | Sticker set name. |
| sticker | InputSticker | Yes | Object with information about the added sticker. |
Games
Letgram games are a platform for HTML5-based games that can be launched inside Letgram chats. Use @BotGod to create a game and get its short name.
sendGame
Use this method to send a game. On success, the sent Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer | Yes | Unique identifier for the target chat. |
| game_short_name | String | Yes | Short name of the game. Set up your games via @BotGod. |
| disable_notification | Boolean | Optional | Sends the message silently. |
| protect_content | Boolean | Optional | Protects the message. |
| reply_to_message_id | Integer | Optional | If the message is a reply. |
| reply_markup | InlineKeyboardMarkup | Optional | Inline keyboard. The first button must launch the game. |
setGameScore
Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned.
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | Integer | Yes | User identifier. |
| score | Integer | Yes | New score (non-negative). |
| force | Boolean | Optional | Pass True to set the score even if it is not higher than the current score. |
| disable_edit_message | Boolean | Optional | Pass True to not automatically edit the game message with the new scores. |
| chat_id | Integer | Optional* | Required if inline_message_id is not specified. |
| message_id | Integer | Optional* | Required if inline_message_id is not specified. |
| inline_message_id | String | Optional* | Required if chat_id and message_id are not specified. |
getGameHighScores
Use this method to get data for high score tables. Returns an Array of GameHighScore objects.
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | Integer | Yes | Target user. |
| chat_id | Integer | Optional* | Required if inline_message_id is not specified. |
| message_id | Integer | Optional* | Required if inline_message_id is not specified. |
| inline_message_id | String | Optional* | Required if chat_id and message_id are not specified. |
Stories
Bots with the appropriate permissions can post, edit, and delete stories on behalf of channels they administer.
postStory
Use this method to post a new story to a channel. Returns the posted Story object on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Unique identifier of the target channel. |
| content | InputStoryContent | Yes | Content of the story. Can be a photo or video. |
| caption | String | Optional | Story caption (0-2048 characters). |
| parse_mode | String | Optional | Mode for parsing entities in the caption. |
| areas | Array of StoryArea | Optional | Interactive areas on the story (links, locations, etc.). |
| period | Integer | Optional | Period in seconds for which the story will be visible. Defaults to 86400 (24 hours). Can be: 6h (21600), 12h (43200), 24h (86400), 48h (172800). |
| protect_content | Boolean | Optional | Pass True to protect the story from forwarding and screenshots. |
curl -X POST "https://api.letgram.ru/bot<token>/postStory" \
-F "chat_id=@mychannel" \
-F "content=@story_photo.jpg" \
-F "caption=Check out our new update!" \
-F "period=86400"
with open("story_photo.jpg", "rb") as f:
requests.post(f"https://api.letgram.ru/bot{TOKEN}/postStory",
data={
"chat_id": "@mychannel",
"caption": "Check out our new update!",
"period": 86400
},
files={"content": f}
)
const formData = new FormData();
formData.append("chat_id", "@mychannel");
formData.append("content", fileBlob, "story.jpg");
formData.append("caption", "Check out our new update!");
formData.append("period", "86400");
await fetch(`https://api.letgram.ru/bot${TOKEN}/postStory`, {
method: "POST",
body: formData
});
editStory
Use this method to edit a previously posted story. Returns the edited Story object on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Unique identifier of the target channel. |
| story_id | Integer | Yes | Unique identifier of the story to edit. |
| content | InputStoryContent | Optional | New content of the story. |
| caption | String | Optional | New caption (0-2048 chars). |
| parse_mode | String | Optional | Mode for parsing entities. |
| areas | Array of StoryArea | Optional | New interactive areas. |
deleteStory
Use this method to delete a previously posted story. Returns True on success.
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer or String | Yes | Unique identifier of the target channel. |
| story_id | Integer | Yes | Unique identifier of the story to delete. |
Changelog
v1.0 — March 2026
Initial release of the Letgram Bot API with full feature set:
- 100+ methods for bot interaction
- Full messaging support: text, media, location, contacts, polls, dice
- Inline mode with 20+ InlineQueryResult types
- Mini Apps (Web Apps) platform with JS SDK
- Payment processing with flexible shipping options
- Sticker set creation and management
- HTML5 game platform with high scores
- Stories API: post, edit, delete stories for channels
- Full chat administration: ban, restrict, promote members
- Webhook and long polling update delivery
- Message editing, forwarding, and copying
- Custom keyboards (inline and reply)
- Bot command management with scoping
- File upload and download (up to 50 MB upload, 20 MB download)
Letgram Bot API v1.0 — letgram.ru — © 2026 Letgram