Skip to main content

botix-cli

Командная строка для BOTIX Public API. Делает то же, что веб-кабинет app.botix.pro, но из терминала: создание ключей, управление подписками webhook, list контактов, отправка сообщений, тестовые доставки. Аналоги — stripe-cli, gh, aws-cli.

Требования

  • Python 3.9+
  • Действующий API-ключ BOTIX (получается в кабинете в разделе «Настройки → API-ключи»)

Установка

pip install botix-cli

После установки команда botix доступна глобально.

Проверка:

botix --version

Первый запуск

botix login
# API-ключ (btx_live_... или btx_test_...): ********
# ✓ Профиль default сохранён (project_id=42).

Ключ кладётся в ~/.botix/config.yaml с правами 600 (читает только владелец).

Проверка авторизации:

botix whoami

Команды

Профили (auth)

Команда Что делает
botix login Сохранить API-ключ. Проверяет через GET /me
botix login --name staging Создать дополнительный профиль
botix logout Удалить весь конфиг
botix logout --name staging Удалить один профиль
botix whoami project_id, scopes, тариф активного ключа

Контакты

botix contacts list --tag VIP --channel telegram --limit 50
botix contacts get 42
botix contacts create --first-name "Иван" --phone "+79991112233" --tag VIP
botix contacts delete 42 --yes

Сообщения

botix messages send --contact-id 42 --channel telegram --text "Привет!"
botix messages list --contact-id 42 --limit 50

messages send автоматически использует Idempotency-Key — повтор той же команды не отправит сообщение второй раз.

Webhooks

botix webhooks list
botix webhooks create \
  --url https://example.com/hook \
  --events contact.created,message.received
botix webhooks test 7              # отправить тестовое событие
botix webhooks tail                # live-лента доставок (аналог `stripe listen`)
botix webhooks delete 7 --yes

webhooks tail опрашивает /api/v1/webhook-deliveries раз в 2 секунды (можно настроить флагом --interval) и печатает новые доставки в реальном времени. Прерывается через Ctrl+C.

API-ключи

botix keys list
botix keys create --name "Production" --scopes contacts:read,messages:send
botix keys revoke 12 --yes

Управление ключами — внутренняя возможность кабинета. Если ваш ключ не имеет прав keys:manage, CLI попросит создать ключ через app.botix.pro/settings?tab=api-keys.

Профили

Несколько профилей живут в одном ~/.botix/config.yaml:

default_profile: production
profiles:
  production:
    api_key: btx_live_...
    base_url: https://api.botix.pro
  staging:
    api_key: btx_test_...
    base_url: https://api.botix.pro

Выбрать профиль на конкретный вызов:

botix --profile staging contacts list

Переменные окружения

Переменная Эффект
BOTIX_API_KEY Полностью обходит конфиг — удобно для CI
BOTIX_BASE_URL Базовый URL API (по умолчанию https://api.botix.pro)
BOTIX_PROFILE Имя профиля по умолчанию (эквивалент --profile)
BOTIX_CONFIG_DIR Каталог конфигурации (для тестов и изолированных сред)

Пример использования в GitHub Actions:

- name: Отправить уведомление через BOTIX
  env:
    BOTIX_API_KEY: ${{ secrets.BOTIX_API_KEY }}
  run: |
    botix messages send --contact-id 42 --text "Деплой прошёл успешно"

Machine-readable вывод

Любая команда поддерживает флаг --json — печатает JSON вместо таблиц:

botix --json contacts list | jq '.[] | select(.tags | index("VIP"))'

Полезно для интеграций и скриптов.

FAQ

Где хранится ключ? ~/.botix/config.yaml, права 600 (читает только владелец).

Как удалить ключ полностью? botix logout --yes (удаляет весь файл) или botix logout --name production --yes (один профиль).

Можно ли использовать в CI без ~/.botix? Да, передайте BOTIX_API_KEY через переменные окружения. login тогда не нужен.

Что делать если 401 Unauthorized?

  1. Проверьте botix whoami — что ключ корректный.
  2. Проверьте scopes ключа в кабинете app.botix.pro/settings?tab=api-keys — у разных команд CLI разные требования (contacts:read для list, messages:send для send и т.д.).

botix webhooks tail ничего не показывает. Доставки появляются только при работе webhook. Запустите рядом botix webhooks test <id> — должна сразу появиться доставка.

Разработка

git clone https://github.com/BOTIX-pro/cli.git
cd cli
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

CI прогоняет тесты на Python 3.9 — 3.12 (см. .github/workflows/test.yml).

Лицензия

MIT — см. LICENSE.

Ссылки

Metadata

Release files for botix-cli 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for botix-cli 1.0.0
File Size Uploaded Provenance Actions
botix_cli-1.0.0.tar.gz 18.8 kB Without provenance Details for botix_cli-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for botix-cli 1.0.0
File Interpreter ABI Platform Actions
botix_cli-1.0.0-py3-none-any.whl Python 3 none any Details for botix_cli-1.0.0-py3-none-any.whl

Total release size: 41.4 kB

Release files / botix_cli-1.0.0.tar.gz

Download URL botix_cli-1.0.0.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3b340b06e4ab1828ecb5b71d5beb04d4abf224d2689ae32cd0b062b283e8f378
BLAKE2b-256 checksum
How to use checksums
2725d94f204c4cfc4f1e455911ffb5aca345083112db8273579e4f9dbd7112be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / botix_cli-1.0.0-py3-none-any.whl

Download URL botix_cli-1.0.0-py3-none-any.whl
Size 22.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4324d439f064de9d6d01f994a6d819b5d195ea537f2aa929d530480461b616a7
BLAKE2b-256 checksum
How to use checksums
ab0b132c5de554e9f549eead2efb048fe6a9887c988232a18fbba709c9fb9fee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for botix-cli 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page