Bot API
Long polling guide
How to consume updates with `GET /v1/bot-api/updates` without losing events.
1. Basic request
Use `offset`, `limit`, and `timeout`. The server returns updates with `update_id > offset`. With `timeout > 0`, the request waits for new updates up to the given limit.
curl -H "Authorization: Bearer <bot_token>" \ "https://api.yullama.ru/v1/bot-api/updates?offset=0&limit=50&timeout=30"
2. Ack semantics
Acknowledgement is client-driven through the next `offset`. If you processed update `41`, the next request should use at least `offset=41`. Bot API will then not return that row again.
3. Recommended loop
Persist `lastSeenUpdateID`, advance it only after successful handling, and keep polling immediately. If your handler crashes mid-batch, do not move the offset past the last confirmed update.
let offset = loadOffset();
for (;;) {
const { items } = await client.bot.getUpdates({ offset, limit: 50, timeout: 30 });
for (const item of items) {
await handleUpdate(item);
offset = item.update_id;
}
}