What it is
A Python library for network calls that do not block: a bot talks to other services' APIs and keeps answering people at the same time. It works both as a client and as a small web server.
How we use it
The subscription-sales bot calls the Marzban panel API with it, the «Дыхание Поволжья» community bot reads the catalogue from the website, and the UNLOCK card service serves card settings and receives the recipients' replies.
Where it helps a business
- A bot needs to call other services' APIs (a panel, a website, a service) without slowing down its answers to people.
- A small service needs its own web server without a heavy framework.
How we use it
- A card service API. In UNLOCK the API that serves card settings and receives the recipient's choice runs on aiohttp.
- A VKontakte community bot. The «Дыхание Поволжья» bot runs on aiohttp over Long Poll and reads the catalogue from the website.
- Talking to a panel. The subscription-sales bot calls the Marzban API, and in webhook mode aiohttp is its built-in web server.
- An internal API. The Peregovorka login bot calls the service's internal API through aiohttp.
- Metadata clients. In ToshaMusic: requests to the Qobuz, Deezer and Tidal APIs and the headless-mode HTTP server.
Common problems
- The service on the other side does not answer. You need timeouts and a clear message for the user. When the tunnel is down, the login bot honestly says the chat service is not responding.
- Retries with a growing pause. In Tech Poly VPN, requests to the database, Marzban, Telegram and VKontakte are retried with an increasing delay instead of hammering the service.
When you do not need it
For a website back end with models, validation and API docs, FastAPI is more convenient. aiohttp shines where you need a light client or a tiny server.