В данной статье разобрана документация Входящих запросов от PuzzleBot, при необходимости вы можете ознакомиться с документацией по Исходящим запросам: Исходящие запросы (API).

Для настройки Входящих запросов необходимо сгенерировать API токен (Бот — Настройки — Интеграции — Входящие запросы).
Важно! Не путать с API ключом от бота из @BotFather.
Формат
Формат запроса: https://api.puzzlebot.top/?token=ТОКЕН_API&method=НАЗВАНИЕ_МЕТОДА
Пример запроса:https://api.puzzlebot.top/?token=WOPJL9thftfGtw65NBfVEXEj24qvZ1bj&method=getLinkActivations&link_id=5556&page=1
С помощью данного запроса можно получить Список пользователей перешедших по ссылке (getLinkActivations) с конкретным идентификатором (link_id=5556) состоящий из данных вмещающихся на первую страницу (page=1).
В адрес для отправки запросов необходимо подставить (без пробелов):
- ТОКЕН_API — генерируется в Настройках Бота на вкладке Интеграции.
- НАЗВАНИЕ_МЕТОДА — все методы (пример:
getLinkActivations) и их параметры (пример:link_idиpage).
Параметры передаются через POST или GET методы, а ответ приходит в формате JSON.
Важно! Всего можно выполнить 120 запросов в минуту.
Методы
Telegram
tg.*— любой запрос из Telegram Bot API, где на месте*любой запрос из Telegram Bot API с использованием формата официальной документации, например:method:tg.unpinAllChatMessagesparams:chat_id - number, Telegram id of chat, bot id for privatesuccess result: code = 0, data = Array of all API methods
Важно! Через методы sendPhoto, sendAudio, sendDocument, sendVideo, sendAnimation, sendVoice, sendVideoNote, sendPaidMedia, sendMediaGroup отправлять файлы в формате
multipart/form-dataНЕЛЬЗЯ! Используйте для этого API Telegram и соответствующие методы.
Системные
- Помощь (вывод доступных методов):
method:helpparams: nosuccess result: code = 0, data = Array of all API methods
- Тест:
method:testparams: nosuccess result: code = 0, data = test text with your request params
Общие
Модерация
- Получение списка пользователей:
method:getUsersInChatparams:chat_id - number, Telegram id of chat, bot id for privatepage - number, page number starts with 1, a page have max 200 rowscategory_id - number, id of category for filter users, optional paramsuccess result: code = 0, data = Array of users [user_id, first_name, last_name, username]
- Получение информации о пользователе:
method:getUserInChatStatusparams:user_id - number, Telegram id of userchat_id - number, Telegram id of chat, bot id for privatepage - number, page number starts with 1, a page have max 50 rowssuccess result: code = 0, data = Object[user_id, chat_id, first_name, last_name, username, joined (1 = joined, 0 = left, 2 = banned), joined_date, left_date, ban_date, categories - Array of categories ids]
- Блокировка пользователя (бан):
method:userBanparams:tg_chat_id - number, Telegram id of chatuser_id - number, Telegram id of useruntil_date - number, timestamp of end ban datesuccess result: code = 0, data = "ok"
- Разблокировка пользователя (разбан):
method:userUnbanparams:tg_chat_id - number, Telegram id of chatuser_id - number, Telegram id of usersuccess result: code = 0, data = "ok"
Постинг
- Получение списка отправленных постов:
method:getPostsListparams:page - number, page number starts with 1, a page have max 50 rowssuccess result: code = 0, data = Array of posts [id, date_sent]
- Отправка поста:
method:postSendparams:chats_ids - array of Telegram chats ids with separator "," (without quotes), "private" for send to all private chatscategories_ids - array of categories ids with separator "," (without quotes) for filter users in private chatstype - "message" (for send text message) | "media" (for send video / photo / audio) / "only_command" (for send command from post actions)file_id - string, file id from Telegram for media typetext - string, text of message for message type or caption for media typepin_post - boolean, pin post after send if it's true, false by defaultcommand_name - text, attach command to the post, no by defaultdate - string, date in UTC format (19.04.2024 20:30 or 2024-04-19 20:30) or timestampsuccess result: code = 0, data = "ok"
- Удалить отправленный пост:
method:postDeleteparams:post_id - number, post_id for deletesuccess result: code = 0, data = "ok"
Категории
- Получение списка категорий:
method:getChatCategoriesparams:tg_chat_id - number, Telegram id of chat, bot id for privatesuccess result: code = 0, data = Array of categories [id, name, is_main]
- Изменить категории пользователю (за один запрос):
method:categoriesChangeparams:user_id - number, Telegram id of usercategories - JSON encoded Object[add_categories = Array[[chat_id, category_id],[...]], delete_categories = Array[[chat_id, category_id],[...]], replace = boolean]success result: code = 0, data = "ok"
- Создание категории:
method:createChatCategoryparams:tg_chat_id - number, Telegram id of chat, bot id for privatename - string, name for new categorysuccess result:code = 0, data = id of new categor
- Добавить категорию пользователю:
method:categoryAddparams:user_id - number, Telegram id of usertg_chat_id - number, Telegram id of chat, bot id for privatecategory_id - number, id of categorysuccess result: code = 0, data = "ok"
- Удалить категорию пользователю:
method:categoryDeleteparams:user_id - number, Telegram id of usertg_chat_id - number, Telegram id of chat, bot id for privatecategory_id - number, id of categorysuccess result: code = 0, data = "ok"
- Заменить все категории пользователя на указанную:
method:categoryReplaceparams:user_id - number, Telegram id of usertg_chat_id - number, Telegram id of chat, bot id for privatecategory_id - number, id of categorysuccess result: code = 0, data = "ok"
Сценарии
- Получение списка сценариев:
method:getScenariosListparams:page - number, page number starts with 1, a page have max 50 rowssuccess result: code = 0, data = Array of scenarios [id, name]
- Изменить состояние сценариев пользователю:
method:scenariosChangeparams:user_id - number, Telegram id of userscenarios - JSON encoded Array[scenario_id : state (0 - for stop, 1 - for start)]success result: code = 0, data = "ok"
- Запустить сценарий пользователю:
method:scenarioRunparams:user_id - number, Telegram id of userscenario_id - number, id of scenariosuccess result: code = 0, data = "ok"
- Остановить сценарий пользователю:
method:scenarioStopparams:user_id - number, Telegram id of userscenario_id - number, id of scenariosuccess result: code = 0, data = "ok"
Вход
- Получение списка ссылок:
method:getLinksListparams:page - number, page number starts with 1, a page have max 50 rowssuccess result: code = 0, data = Array of links [id, name, type, variable, max_activations, max_links, enabled]
- Получение списка пользователей по конкретной ссылке:
method:getLinkActivationsparams:link_id - number, id of linkpage - number, page number starts with 1, a page have max 50 rowssuccess result: code = 0, data = Array of links activations [link_id, link_key, link_owner_tg_user_id, user_id, date]
Переменные
- Изменить переменную:
method:variableChangeparams:variable - string, name of variableexpression - string, expression for calc valueuser_id - number, Telegram id of user for change personal variablesuccess result: code = 0, data = "ok"
- Получение значения переменной:
method:getVariableValueparams:variable - string, name of variableuser_id - number, Telegram id of user for get personal variable valuesuccess result: code = 0, data = "Variable value"
- Очистить переменную:
method:variableClearparams:variable - string, name of variableuser_id - number, Telegram id of user for change personal variablesuccess result: code = 0, data = "ok"
Таблицы Google
- Получить содержимое Google таблицы в формате JSON (только для привязанных аккаунтов):
method:getSpreadSheetRowsparams:spreadsheet_id - string, id of spreadsheetemail - string, email for requestsheets_ids - string, ids of sheets with separator "," (without quotes) (default no set, get all sheets)get_rows_cache_time - number, cache time of rows in seconds (default 5, max 86400)get_sheets_cache_time - number, cache time of sheets in seconds (default 5, max 86400)success result: code = 0, data = Array of spreadsheets objects [sheet_id, sheet_title, rows]
Магазин
- Получение списка товаров:
method:getShopItemsListparams:page - number, page number starts with 1, a page have max 50 rowssuccess result: code = 0, data = Array of items [id, name, article, count_left]
- Изменить остатки товара:
method:shopItemChangeCountLeftparams:item_id - number, id of shop itemcount_left - number, new count left for item (-1 for infinity)success result: code = 0, data = "ok"
Только для ботов
- Привязать бота:
method:botConnectparams: nosuccess result: code = 0, data = "ok"
- Отвязать бота:
method:botDisconnectparams: nosuccess result: code = 0, data = "ok"
- Включить бота:
method:botEnableparams: nosuccess result: code = 0, data = "ok"
- Выключить бота:
method:botDisableparams: nosuccess result: code = 0, data = "ok"
- Получить список чатов:
method:getChatsListparams: nosuccess result: code = 0, data = Array of chats [chat_id, tg_chat_id, title, description, type]
- Скачать файл:
method:downloadFileparams: file_id - string, Telegram id of file to downloadsuccess result: Output file with "Content-Type: application/octet-stream"
Конструктор
- Получить список команд и условий:
method:getCommandsListparams: nosuccess result: code = 0, data = Array of commands [id, name, group_id]
- Получить список групп команд:
method:getCommandsGroupsListparams: nosuccess result: code = 0, data = Array of commands groups [id, name]
- Отправка команды или условия:
method:sendCommandparams:command_name - string, name of command or conditiontg_chat_id - number, Telegram id of resource or usersuccess result: code = 0, data = "ok"
Диалоги
- Начать диалог:
method:dialogStartparams:user_id - number, Telegram id of usersuccess result: code = 0, data = "ok"
- Завершить диалог:
method:dialogEndparams:user_id - number, Telegram id of usersuccess result: code = 0, data = "ok"
Только для ресурсов
- Принять заявку на вступление в ресурс:
method:joinRequestApproveparams:user_id - number, Telegram id of usertg_chat_id - number, Telegram id of resourcesuccess result: code = 0, data = "ok"
- Отклонить заявку на вступление в ресурс:
method:joinRequestDeclineparams:user_id - number, Telegram id of usertg_chat_id - number, Telegram id of resourcesuccess result: code = 0, data = "ok"
- Удаление пользователя (кик):
method:userKickparams:tg_chat_id - number, Telegram id of chatuser_id - number, Telegram id of usersuccess result:code = 0, data = "ok"
Триггеры (только для групп)
- Получение списка триггеров:
method:getTriggersListparams:page - number, page number starts with 1, a page have max 50 rowssuccess result: code = 0, data = Array of triggers [id, chat_id, name, enabled]
- Отправка триггера:
method:triggerSendparams:trigger_id - number, id of triggeruser_id - number, Telegram id of usersuccess result: code = 0, data = "ok"
Ошибки
code = 1 — Wrong token format!
code = 2 — Wrong method format!
code = 3 — Token not found!
code = 4 — Unknown method!
code = 40 — No "tg_chat_id" param! | No "user_id" param!
code = 50 — Set webhook error!
code = 51 — Delete webhook error!
code = 100 — Internal error!
code = 102 — Variable evaluate exception!
code = 104 — Variable not found!
code = 200 — Command / condition not found!
code = 201 — User not found!
code = 202 — Chat not found!
code = 203 — User in chat not found!
code = 204 — Post not found!
code = 205 — Post is not sent!
code = 207 — Trigger not found!
code = 208 — Can't approve join request!
code = 209 — Can't decline join request!
code = 210 — Category not found!
code = 211 — Unknown type of post!
code = 212 — Empty chats!
code = 429 — Too many queries per minute!/Too many queries per month