The official example from telegram explains that in order to use getChats()
command, one needs to set two parameters 'offset_order
' and 'offset_chat_id
'.
I'm using this node.js wrapper for the TDLib.
So when I use getChats()
with the following params:
'offset_order': '9223372036854775807',
'offset_chat_id': 0,
'limit': 100
just like it is explained in the official docs:
For example, to get a list of chats from the beginning, the offset_order should be equal to 2^63 - 1
as a result I get 100 chats from the top of the user's list.
What I can't understand is how do I iterate through that list? How do I use the API pagination?
When I try to enter a legitimate chat_id from the middle of the first 100, I still get the same first 100, so it seems like it makes no difference.
If I change that offset_order to ANY other number, I get an empty list of chats in return...
Completely lost here, as every single example I found says the same thing as the official docs, ie how to get the first 100.
Had the same problem, have tried different approaches and re-read documentation for a long time, and here is a decision:
getChats
as you do with '9223372036854775807'
offset_order
parametergetChat
request with id of the last chat you have got. It's an offline request, just to tdlib. positions: [
{
_: 'chatPosition',
list: [Object],
order: '6910658003385450706',
is_pinned: false
}
],
getChats
- use the positions[0].order
from (3) as offset_order
It wasn't easy to come to this, so would be glad if it helps anybody who came from google like me :)