MenuPagination

Guides

Pagination

Cursor pagination, in the same place on every list.

Every list response carries a pagination object. Read pagination.next_cursor and send it back as the cursor query parameter to get the next page. pagination.has_more tells you whether there is one. Leave cursor off for the first page.

pagination
"pagination": {
  "next_cursor": "QVFEbV9xS3Bn…",
  "has_more": true
}

One loop works for every paginated endpoint; only the collection key changes.

paginate.mjs
const url = new URL("https://social-api.airaa.xyz/v1/instagram/user/posts");
url.searchParams.set("username", "instagram");

const posts = [];
let cursor;

do {
  if (cursor) url.searchParams.set("cursor", cursor);
  const res = await fetch(url, {
    headers: { "X-API-KEY": process.env.AIRAA_KEY },
  });
  const page = await res.json();

  posts.push(...page.posts);
  cursor = page.pagination.has_more ? page.pagination.next_cursor : undefined;
} while (cursor);

Instagram comments pages with cursor like the rest, and also returns pagination.total_count, the number of comments on the whole post.

X search returns next_cursor and previous_cursor and no has_more. Keep paging while next_cursor is present.

X user posts can end on an empty page (posts: [], has_more: false), and a protected account returns posts: [] on the first page.

EndpointCollectionCursor params
User posts/v1/instagram/user/postspostscursor
User reels/v1/instagram/user/reelsreelscursor
Post comments/v1/instagram/posts/commentscommentscursor
TikTok user posts/v1/tiktok/user/postspostscursor
Facebook user posts/v1/facebook/user/postspostscursor
List X user posts/v1/twitter/user/postspostscursor
Search posts/v1/twitter/searchpostscursor
esc

Pages

Endpoints

↑↓ to move↵ to open