v3
latestOpenAPI 3.1.02026-08-01264769.0 KBGet chat history
Returns a page of messages from a private conversation or chat. Supply exactly one of user_id or chat_id, and use offset_message_id to request older messages.
Path parameters
Required bot token included in the URL path.
Query parameters
A positive decimal Inline user identifier
Target a private conversation with this user. Supply exactly one of user_id or chat_id.
A positive decimal Inline chat identifier
Target this chat. Supply exactly one of chat_id or user_id.
A signed decimal integer string within JavaScript's safe-integer range
Maximum number of messages to return.
A positive decimal Inline message identifier
Pagination cursor. When supplied, return messages older than this message.
Headers
Optional bot token using the Bearer scheme. When supplied, it takes precedence over the token in the URL.
Response
Successful getChatHistory response.
Example response
{
"ok": true,
"result": {
"messages": [
{
"message_id": 1808,
"chat_id": 73143,
"chat": {
"chat_id": 73143,
"title": "Maya Chen",
"is_public": false,
"last_message_id": 1808,
"last_message": {
"message_id": 1808,
"from_id": 284901,
"from": {
"id": 284901,
"is_bot": true,
"username": "deploy_bot",
"first_name": "Deploy Bot"
},
"date": 1784332860,
"text": "Deployment finished successfully.",
"entities": [
{
"type": "bold",
"offset": 0,
"length": 10
}
]
}
},
"peer": {
"user_id": 391204
},
"from_id": 284901,
"from": {
"id": 284901,
"is_bot": true,
"username": "deploy_bot",
"first_name": "Deploy Bot"
},
"date": 1784332860,
"text": "Deployment finished successfully.",
"entities": [
{
"type": "bold",
"offset": 0,
"length": 10
}
]
}
]
}
}