Receiving Updates via Long Polling (getUpdates)¶
Long Polling is the easiest way to receive updates without needing a public domain, dedicated IP, or TLS certificate. It is ideal for local development, debugging, and edge environments.
How getUpdates Works¶
When calling getUpdates, the server holds the HTTP connection open until new updates arrive or the specified timeout expires.
GET
POST
https://botapi.codemeet.chat/bot<TOKEN>/getUpdates
Request Parameters¶
| Parameter | Type | Status | Default | Description |
|---|---|---|---|---|
offset |
Integer |
Optional | null |
Identifier of the first update to return. Pass last_update_id + 1 to acknowledge received updates. |
limit |
Integer |
Optional | 100 |
Limits the number of updates retrieved (1–100). |
timeout |
Integer |
Optional | 0 |
Long-polling timeout in seconds (0–50 seconds). |
allowed_updates |
Array of String |
Optional | All types | List of update types to receive (e.g., ["message", "callback_query"]). |
getUpdates Response Structure¶
Returns an array of Update objects:
{
"ok": true,
"result": [
{
"update_id": 1042,
"message": {
"message_id": 25,
"date": 1724419200,
"chat": {
"id": "e9b2a1c0-4411-4fa3-9f88-d4508671b122",
"type": "private"
},
"from": {
"id": "c1f72b9a-1122-3344-5566-778899aabbcc",
"is_bot": false,
"first_name": "Sara",
"username": "sara_dev"
},
"text": "Hello bot!"
}
},
{
"update_id": 1043,
"callback_query": {
"id": "a90f12d83b4c",
"from": {
"id": "c1f72b9a-1122-3344-5566-778899aabbcc",
"is_bot": false,
"first_name": "Sara"
},
"message": { "message_id": 24, "chat": { "id": "..." } },
"data": "btn_confirm"
}
}
]
}
Managing offset Acknowledgements¶
To prevent duplicate deliveries, update your offset parameter after successfully processing updates:
sequenceDiagram
participant Bot as Your Bot
participant Server as CodeMeet Server
Bot->>Server: GET /getUpdates (offset=null, timeout=30)
Server-->>Bot: updates: [update_id: 100, update_id: 101]
Note over Bot: Process updates 100 and 101
Bot->>Server: GET /getUpdates (offset=102, timeout=30)
Note over Server: Updates < 102 are marked delivered
Server-->>Bot: updates: [update_id: 102]
/// tip | Webhook Conflict
If a webhook is already active on your bot, calls to getUpdates will return nothing or conflict. Call deleteWebhook before switching back to polling.
///