title: How to request all chats/groups of the user through Telegram Database Library(TDLib) for Node.js
body: <p>The official example from telegram explains that in order to use <code>getChats()</code> command, one needs to set two parameters '<code>offset_order</code>' and '<code>offset_chat_id</code>'.
  I'm using this <a href="https://www.npmjs.com/package/tglib" rel="nofollow noreferrer">node.js wrapper for the TDLib</a>.
  So when I use <code>getChats()</code> with the following params:</p>
  
  <pre><code>'offset_order': '9223372036854775807',
  'offset_chat_id': 0,
  'limit': 100
  </code></pre>
  
  <p>just like it is explained in the <a href="https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1get_chats.html" rel="nofollow noreferrer">official docs</a>:</p>
  
  <blockquote>
    <p>For example, to get a list of chats from the beginning, the
    offset_order should be equal to 2^63 - 1</p>
  </blockquote>
  
  <p>as a result I get 100 chats from the top of the user's list.</p>
  
  <p>What I can't understand is how do I iterate through that list? How do I use the API pagination?</p>
  
  <p>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.</p>
  
  <p>If I change that offset_order to ANY other number, I get an empty list of chats in return...</p>
  
  <p>Completely lost here, as <a href="https://github.com/Bannerets/tdl/blob/master/examples/get-chats.js" rel="nofollow noreferrer">every</a> <a href="https://github.com/nodegin/tglib/blob/master/examples/getChats.js" rel="nofollow noreferrer">single</a> <a href="https://github.com/fonbah/tdlnode/blob/master/examples/chats.js" rel="nofollow noreferrer">example</a> I found says the same thing as the official docs, ie how to get the first 100.</p>