Skip to main content

maxapi-lite

PyPI Python CI

Легковесный асинхронный клиент MAX Bot API, совместимый с aiohttp 3.8.x.

Пакет нужен, когда в проекте уже зафиксирован старый aiohttp — например, рядом живёт aiogram 2.x (aiohttp<3.9), а официальный клиент maxapi требует aiohttp>=3.12. Зависимости — только aiohttp>=3.8 и pydantic>=2.

Lightweight async client for the MAX messenger Bot API that works with aiohttp 3.8, so it can share an environment with aiogram 2.x.

Установка

pip install maxapi-lite

Быстрый старт

import asyncio
from maxapi_lite import Bot, ParseMode


async def main():
    bot = Bot(token="YOUR_MAX_TOKEN", parse_mode=ParseMode.HTML)  # или переменная окружения MAX_BOT_TOKEN

    # Кнопка-ссылка
    kb_attachment = bot.build_link_button_attachment(
        text="Открыть MiniApp",
        url="https://example.com/app?startapp=123",
    )

    # Отправка фото + кнопки
    result = await bot.send_message_with_media(
        chat_id=-70893181482276,
        text="<b>Розыгрыш</b>",
        media_type="photo",
        file_path="banner.jpg",  # или media_url="https://..."
        attachments=[kb_attachment],
    )

    # Извлечение mid и закрепление
    mid = bot.extract_message_id(result)
    if mid:
        await bot.pin_chat_message(chat_id=-70893181482276, message_id=mid)

    await bot.close_session()


asyncio.run(main())

Long polling

marker = None
while True:
    data = await bot.get_updates(timeout=30, marker=marker)
    for update in data.get("updates", []):
        ...
    marker = data.get("marker", marker)

Методы Bot

Группа Методы
Бот и обновления get_me, get_updates
Сообщения send_message, edit_message, delete_message, get_message
Медиа upload_file, create_media_attachment, send_message_with_media, edit_message_with_media
Закрепление pin_chat_message, pin_from_response, unpin_chat_message
Чаты get_chat_by_id, get_chat_member, get_chat_members_batch, get_list_admin_chat
Callback send_callback
Утилиты extract_message_id, build_link_button_attachment

Методы возвращают «сырые» dict из ответа API. Ошибки API поднимаются как MaxApiError (с полем code), ошибка авторизации — как InvalidToken.

Поддерживаемые media_type

  • photo, animation, image → загрузка как image
  • video
  • document, file

Примечания

  • chat_id / user_id передаются query-параметрами, как требует MAX API.
  • edit_message(..., attachments=[]) явно очищает вложения; attachments=None оставляет их как есть.
  • Формат (parse_mode) применяется к редактированию только если передан text.
  • Для upload используется multipart-поле data.

Разработка

pip install -e ".[test]"
pytest

Релиз: поднять __version__ в src/maxapi_lite/__init__.py, дополнить CHANGELOG.md, создать GitHub Release с тегом vX.Y.Z — workflow publish.yml соберёт пакет и опубликует его на PyPI.

Лицензия

MIT

Metadata

Release files for maxapi-lite 0.2.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 maxapi-lite 0.2.0
File Size Uploaded Provenance
maxapi_lite-0.2.0.tar.gz 11.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for maxapi-lite 0.2.0
File Interpreter ABI Platform
maxapi_lite-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / maxapi_lite-0.2.0.tar.gz

Download URL maxapi_lite-0.2.0.tar.gz
Size 11.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c1cafcb5c64478ea5e1b9d28b1427173f94f2f303131e152844b656298bd902a
BLAKE2b-256 checksum
How to use checksums
135758671aef0ca6e3a413d3f4f1bc71a99f04d3f220c84953536c58f226b5a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / maxapi_lite-0.2.0-py3-none-any.whl

Download URL maxapi_lite-0.2.0-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4657b5d03f1dd7c6f8ae29b2e074b2e284e51779948e4a1b1ec8476f4d00ed2a
BLAKE2b-256 checksum
How to use checksums
9722bb1d3a16c11b94c38a22db9bd44d775300b49db62ea3fe0661dc40220887
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Security for maxapi-lite 0.2.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for maxapi_lite-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

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

0.2.0 This release

2 release files Full 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