Перейти к основному содержимому

Типы данных

Все объекты, которые возвращает Bot API, имеют чёткую структуру.

User

{
"id": 999,
"is_bot": false,
"first_name": "Иван",
"last_name": "Иванов",
"username": "ivan",
"language_code": "ru",
"is_premium": false,
"added_to_attachment_menu": false
}

Chat

{
"id": -100123,
"type": "supergroup",
"title": "Моя группа",
"username": "my_group",
"description": "Описание",
"photo": {"small_file_id": "...", "big_file_id": "..."},
"is_forum": false,
"join_to_send_messages": false,
"join_by_request": false
}

type: private, group, supergroup, channel.

Message

{
"message_id": 42,
"from": {...User},
"chat": {...Chat},
"date": 1735689600,
"text": "Привет",
"entities": [{"type": "bold", "offset": 0, "length": 6}],
"reply_to_message": {...Message},
"reply_markup": {...InlineKeyboardMarkup}
}

Опционально присутствуют (взаимоисключающие): text, photo, video, document, voice, audio, animation, sticker, poll, location, venue, contact, dice.

MessageEntity

{
"type": "bold" | "italic" | "code" | "pre" | "underline" | "strikethrough" | "spoiler" | "mention" | "hashtag" | "url" | "email" | "phone_number" | "text_link" | "text_mention" | "custom_emoji",
"offset": 0,
"length": 6,
"url": "https://...",
"user": {...User},
"language": "python",
"custom_emoji_id": "..."
}

InlineKeyboardMarkup

{
"inline_keyboard": [
[
{"text": "Кнопка", "callback_data": "btn1"},
{"text": "Ссылка", "url": "https://..."}
]
]
}

ReplyKeyboardMarkup

{
"keyboard": [[{"text": "Опция 1"}]],
"resize_keyboard": true,
"one_time_keyboard": false,
"is_persistent": false,
"input_field_placeholder": "...",
"selective": false
}

PhotoSize / Audio / Video / Document / Voice / Animation / Sticker

Все имеют общие поля: file_id, file_unique_id, file_size. Плюс свои:

  • PhotoSize: width, height
  • Video / Animation: width, height, duration, thumbnail, mime_type
  • Audio / Voice: duration, mime_type, title, performer
  • Document: file_name, mime_type, thumbnail
  • Sticker: type, width, height, is_animated, emoji, set_name

Poll

{
"id": "...",
"question": "...",
"options": [{"text": "...", "voter_count": 5}],
"total_voter_count": 13,
"is_closed": false,
"is_anonymous": true,
"type": "regular" | "quiz",
"allows_multiple_answers": false,
"correct_option_id": 1,
"explanation": "...",
"open_period": 30,
"close_date": 1735689600
}

Location / Venue / Contact

// Location
{"latitude": 55.75, "longitude": 37.62, "horizontal_accuracy": 5}

// Venue
{"location": {...Location}, "title": "Кафе", "address": "...", "foursquare_id": "..."}

// Contact
{"phone_number": "+71234567890", "first_name": "Иван", "last_name": "Иванов", "user_id": 999}

ChatMember

{
"user": {...User},
"status": "creator" | "administrator" | "member" | "restricted" | "left" | "kicked",
"can_be_edited": true,
"is_anonymous": false,
"custom_title": "Главный модератор",
"can_manage_chat": true,
"can_delete_messages": true,
"can_restrict_members": true,
"can_promote_members": false,
"can_change_info": true,
"can_invite_users": true,
"can_pin_messages": true,
"until_date": 1735689600
}

Полная справка с всеми полями — в исходниках наших библиотек или в документации Bot API стандарта.