imbot.v2.Bot.list
Список ботов приложения
Описание
Метод imbot.v2.Bot.list возвращает список ботов текущего приложения в расширенном формате.
Параметры
botToken
string
необязательный
Уникальный токен авторизации бота. Обязателен при авторизации через вебхук, не нужен для OAuth.
Передавайте тот же botToken, который был указан при регистрации чат-бота
filter
object
необязательный
Фильтр результатов.
Доступные поля фильтра:
- type — тип бота. Описание типов — Типы ботов
limit
integer
необязательный
Количество ботов на страницу. По умолчанию 50
offset
integer
необязательный
Смещение для пагинации. По умолчанию 0
Примеры запроса
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"botToken":"my_bot_token","filter":{"type":"bot"},"limit":10}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/imbot.v2.Bot.list
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"filter":{"type":"bot"},"limit":10,"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/imbot.v2.Bot.list
try {
const response = await $b24.callMethod('imbot.v2.Bot.list', {
filter: { type: 'bot' },
limit: 10,
});
const { result } = response.getData();
console.log('result:', result);
} catch (error) {
console.error('Error:', error);
}
from b24pysdk.errors import BitrixAPIError, BitrixSDKException
try:
bitrix_response = client.imbot.v2.bot.list(
filter={
"type": "bot",
},
limit=10,
).response
result = bitrix_response.result
print(result)
except BitrixAPIError as error:
print(
"Ошибка Bitrix API",
f"error: {error.error}",
f"error_description: {error.error_description}",
sep="\n",
)
except BitrixSDKException as error:
print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
print(f"Непредвиденная ошибка: {error}")
try {
$response = $b24Service
->core
->call(
'imbot.v2.Bot.list',
[
'filter' => ['type' => 'bot'],
'limit' => 10,
]
);
$result = $response
->getResponseData()
->getResult();
echo 'result: '. print_r($result, true);
} catch (Throwable $exception) {
error_log($exception->getMessage());
echo 'Error: '. $exception->getMessage();
}
BX24.callMethod(
'imbot.v2.Bot.list',
{
filter: { type: 'bot' },
limit: 10,
},
function(result) {
if (result.error()) {
console.error(result.error().ex);
} else {
console.log(result.data());
}
}
);
require_once('crest.php');
$result = CRest::call(
'imbot.v2.Bot.list',
[
'filter' => ['type' => 'bot'],
'limit' => 10,
]
);
if (!empty($result['error'])) {
echo 'Error: '. $result['error_description'];
} else {
foreach ($result['result']['bots'] as $bot) {
echo $bot['id']. ': '. $bot['code']. "\n";
}
}
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "imbot.v2.Bot.list", b24.Params{
"botToken": "my_bot_token",
"filter": b24.Params{
"type": "bot",
},
"limit": 10,
}, b24.WithIdempotent())
if err != nil {
return fmt.Errorf("imbot.v2.Bot.list: %w", err)
}
var item struct {
HasNextPage bool `json:"hasNextPage"`
}
if err := json.Unmarshal(res.Result, &item); err != nil {
return fmt.Errorf("разбор ответа: %w", err)
}
fmt.Println(item.HasNextPage)
Ответ
HTTP-статус: 200
{
"result": {
"bots": [
{
"id": 456,
"code": "support_bot",
"type": "bot",
"isHidden": false,
"isSupportOpenline": false,
"isReactionsEnabled": true,
"backgroundId": null,
"language": "ru",
"moduleId": "rest",
"eventMode": "fetch",
"countMessage": 150,
"countCommand": 3,
"countChat": 12,
"countUser": 45
}
],
"users": [
{
"id": 456,
"active": true,
"name": "Support Bot",
"bot": true,
"type": "bot"
}
],
"hasNextPage": false
},
"time": {
"start": 1728626400.123,
"finish": 1728626400.234,
"duration": 0.111,
"processing": 0.045,
"date_start": "2024-10-11T10:00:00+03:00",
"date_finish": "2024-10-11T10:00:00+03:00"
}
}
Обработка ошибок
HTTP-статус: 400
{
"error": "BOT_TOKEN_NOT_SPECIFIED",
"error_description": "Bot token is not specified"
}
| Код | Описание | Значение |
|---|---|---|
BOT_TOKEN_NOT_SPECIFIED |
Bot token is not specified | Не указан botToken. Обязателен при авторизации через вебхук |

