title: Paginating Firebase data through the REST API on property without duplicates
body: <p>Is there an equivalent of <code>startAt(value, [key])</code> in the REST API? Specifically the optional key param.</p>
  <p><a href="https://www.firebase.com/docs/web/api/query/startat.html" rel="nofollow noreferrer">https://www.firebase.com/docs/web/api/query/startat.html</a></p>
  <p>Details:</p>
  <p>I am paging through a collection on a property (dueDate) using the REST API. Paging through works but, since the values for dueDate are not unique, each successive page may contain several duplicates. In the worst case, there may be more duplicates on a date than the page size, which would break the pagination.</p>
  <p>Because of the way Firebase paging through works I'm expecting 1 duplicate, the last item from the previous page.</p>
  <p>The JS SDK startAt method supports a second argument to provide the last key when making the next query but this does not appear to exist, or is not documented in the REST API.</p>
  <p>Unhelpfully, the REST API docs do not provide a full specification for the query parameters, only the REST-specific params like &quot;auth&quot;, and &quot;shallow&quot;.</p>
  <blockquote>
  <p>orderBy</p>
  <p>See the section in the guide on ordered data for more information.</p>
  <p>limitToFirst, limitToLast, startAt, endAt, equalTo</p>
  <p>See the section in the guide on querying data for more information.</p>
  </blockquote>
  <p>Docs: <a href="https://firebase.google.com/docs/reference/rest/database/#section-query-parameters" rel="nofollow noreferrer">https://firebase.google.com/docs/reference/rest/database/#section-query-parameters</a></p>
  <p>The request in NodeJS:</p>
  <pre><code>var request = require('request-promise');
  var startAt = 0
  var now = new Date().getTime(); // calculate once per paginated query
  getPage(startAt, now)
  // then process page
  // then get the next page
  // etc
  
  function getPage(startAt, endAt, lastId) {
    var params = {
      auth: /* ... auth token ... */,
      orderBy: '&quot;dueDate&quot;',
      startAt: startDate, /* startDate is a Unix timestamp in milliseconds */
      endAt: endAt,
      limitToFirst: 1000
    };
    return request.get({
      url: 'https://my-firebase.firebaseio.com/todos.json',
      qs: params,
      json: true,
      timeout: 20000 /* ms */
    });
  }
  </code></pre>
  <p>I have looked at <a href="https://stackoverflow.com/questions/15671000/firebase-rest-api-how-to-fetch-data-by-priority-like-startat-endat-in-js">Firebase REST API: How to fetch data by priority like startAt/endAt in JS?</a>. The newer answer refers to the old docs, which as stated above, do not answer this question unless I have missed something. I have read everything in the REST sections in both the old docs and the new docs pages.</p>