Using the API

Pagination

Walking lists with next_cursor.

Paged routes return an array in data and, when there is more, an opaque meta.next_cursor. Pass it back as cursor to get the next page. When next_cursor is absent, you have everything.

javascript
async function* allPosts(handle) {
  let cursor;
  do {
    const params = new URLSearchParams({ handle, ...(cursor && { cursor }) });
    const res = await fetch(`https://api.crawlfeed.dev/v1/tiktok/posts?${params}`, {
      headers: { Authorization: `Bearer ${process.env.CRAWLFEED_KEY}` },
    });
    const { data, meta } = await res.json();
    yield* data;
    cursor = meta.next_cursor;
  } while (cursor);
}
  • Each page is a separate call and costs the same as the first.
  • Cursors belong to the platform and operation that issued them. A TikTok posts cursor means nothing to Instagram.
  • Treat cursors as opaque strings. Their contents change without notice.
  • Page sizes follow the platform, so do not assume a fixed number of items per page.