Most list endpoints support cursor-based pagination for fetching large datasets efficiently.
Initial Request
Make your initial request without a cursor
Check Response
The response includes a cursor and has_more flag
Next Page
If has_more is true, use the cursor in your next request
Repeat
Continue until has_more is false
Example: Paginating TikTok Posts
Initial Request
curl -X POST "https://api.yourservice.com/tiktok/posts" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"username": "charlidamelio",
"limit": 10
}'
Response
{
"success": true,
"data": {
"posts": [...],
"cursor": "1705315800000",
"has_more": true
},
"metadata": {
"credits_used": 11
}
}
Next Page Request
curl -X POST "https://api.yourservice.com/tiktok/posts" \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"username": "charlidamelio",
"limit": 10,
"cursor": "1705315800000"
}'
Code Examples
import requests
def fetch_all_posts(username, max_posts=100):
all_posts = []
cursor = None
while len(all_posts) < max_posts:
payload = {
"username": username,
"limit": min(100, max_posts - len(all_posts))
}
if cursor:
payload["cursor"] = cursor
response = requests.post(
"https://api.yourservice.com/tiktok/posts",
headers={"X-API-Key": "your-api-key"},
json=payload
)
data = response.json()
posts = data["data"]["posts"]
all_posts.extend(posts)
if not data["data"]["has_more"]:
break
cursor = data["data"]["cursor"]
return all_posts
| Endpoint | Cursor Field | Max Limit |
|---|
/tiktok/posts | cursor | 100 |
/instagram/posts | cursor | 100 |
/reddit/posts | cursor | 100 |
/youtube/channel/videos | N/A (uses depth) | 50 |
Important Notes
Cursors are opaque strings - don’t try to parse or modify them
Cursors may expire after some time. If you get an error, start from the beginning.
- The
limit parameter controls how many items per page (not total)
- Credit costs apply to each paginated request