Skip to content

getUpdates

Retrieve the latest updates for the Bot using long polling. Returns an array of Update objects.

Request

GET /:token/getUpdates

POST /:token/getUpdates

This method supports both GET and POST requests.

Parameters

ParameterTypeRequiredDescription
offsetIntegerNoUpdate offset. Pass the most recent update_id + 1 to receive only updates after that offset
limitIntegerNoMaximum number of updates to be returned. Values between 1-100 are accepted, defaults to 100
timeoutIntegerNoLong polling timeout in seconds. Set to 0 for immediate response. Recommended value is around 30 to reduce request frequency
allowed_updatesString[]NoList of allowed update types to receive, e.g. ["message", "callback_query"]

Response

Returns an array of Update objects. If there are no new updates, an empty array is returned.

json
{
  "ok": true,
  "result": [
    {
      "update_id": 100000001,
      "message": {
        "message_id": 1,
        "from": {
          "id": 987654321,
          "is_bot": false,
          "first_name": "User",
          "username": "user123"
        },
        "chat": {
          "id": 987654321,
          "first_name": "User",
          "username": "user123",
          "type": "private"
        },
        "date": 1700000000,
        "text": "Hello, Bot!"
      }
    }
  ]
}

Update Object Fields

FieldTypeDescription
update_idIntegerUnique identifier for the update, incrementing
messageMessageOptional. New incoming message
callback_queryCallbackQueryOptional. Callback query

Error Codes

CodeDescription
400Bad request parameters, e.g. invalid offset format
401Invalid or expired token
409Conflict, possibly because a webhook is already set and long polling cannot be used simultaneously
500Internal server error

Example

cURL

bash
curl -X POST "https://api.example.com/<token>/getUpdates" \
  -H "Content-Type: application/json" \
  -d '{
    "offset": 100000002,
    "limit": 10,
    "timeout": 30
  }'

Response When No Updates

json
{
  "ok": true,
  "result": []
}