Leave
cursor empty (or omit it) for the first page. Stop when has_next_page is false, next_cursor is empty, or next_cursor is the same as the cursor you just sent (a page that returns nothing new).
Notes
- Each page is billed as its own request. See Pricing.
- Page sizes differ by endpoint: search and timelines return up to 20 tweets; followers / followings up to 200 users; follower IDs up to 5,000 IDs.
- Set a
max_pageslimit in your code so a bug can’t page forever. - On some endpoints X can report more results when there are none; you then get an empty page, often with the same cursor back. The stop rule above handles this.
- For “new tweets since last time”, searching with a time window (for example
since_time:/until_time:in the query) is usually cheaper than paging deep.