🔄 How it works
Unlike traditional “page-based” pagination (page 1, page 2), Sorsa uses a cursor-based system. This is much more stable for social media data where new content is added every second.💡 Not all endpoints support pagination. For example,/info(single user profile) or/tweet-inforeturn a single object and do not require a cursor. Pagination is only present in endpoints that return lists of items.
📥 The cursor Parameter
In your API response, look for the next_cursor field.
- If
next_cursoris a string: There is more data available. - If
next_cursorisnullor missing: You have reached the end of the list.
next_cursor and pass it in your next request as the cursor query parameter.
⚠️ Important: Result Count
Due to the nature of X (Twitter) data sourcing, the number of items returned per page is not fixed.- “Up to X items”: If an endpoint says it returns 20 items, it might return 18, 15, or even 5 in some cases, even if there is more data on the next page.
- Don’t use count as a stop-sign: Never assume you’ve reached the end just because a page has fewer items than expected. Always rely on the
next_cursorfield to determine if there is a next page.
🛠 Example Workflow
Step 1: Initial requestGET https://api.sorsa.io/v3/search-tweets?query=bitcoin
Response:
JSON
GET https://api.sorsa.io/v3/search-tweets?query=bitcoin&cursor=DAABCgABF7Y...
🐍 Python Example: Robust Pagination
This script handles variable page sizes and stops only when the cursor is gone. Python⏭ Next Steps
- Error Codes — Learn how to handle 404 or 429 errors during pagination.
- Search Guide — See pagination in action with advanced search operators.