100 free credits. No credit card required.Start building
Logo
Back to blog

Twitter Search API and Pagination: Cursors Explained

··8 min read

Search tweets with sort=latest or top, then page timelines, replies and followers with one cursor. One credit per page, full long posts, with curl and Python.

Twitter Search API and Pagination: Cursors Explained

The Twitter search API at SocialCrawl is GET /v1/twitter/search/tweets. Send a query, pick sort=latest or sort=top, and you get one page of matching tweets with the full text of long posts. To read further, send pagination.next_cursor back as cursor until pagination.has_more is false. Every page costs 1 credit.

The same cursor works on user timelines, replies, retweeters, followers, following and the media tab, so you write one loop and reuse it.

Does the Twitter search API support latest and top results?

Yes. GET /v1/twitter/search/tweets takes a query and a sort of latest (chronological) or top (ranked by engagement). Operators go inside query, for example from:handle, min_faves:20, filter:images or a quoted phrase. A page is roughly 20 tweets.

bash
curl -s -H "x-api-key: $SOCIALCRAWL_API_KEY" \
  "https://www.socialcrawl.dev/v1/twitter/search/tweets?query=NASA%20Artemis&sort=latest"

The response is an envelope with the rows in data.items and the paging state in pagination, next to data rather than inside it. A trimmed row looks like this:

json
{
  "success": true,
  "data": {
    "items": [
      {
        "post": {
          "id": "2095617131295486161",
          "url": "https://x.com/NASAStennis/status/2095617131295486161",
          "published_at": "2026-09-03T20:57:13.000Z",
          "author": { "username": "NASAStennis" },
          "engagement": { "views": 986, "likes": 35, "comments": 1, "shares": 7 },
          "content": { "text": "Artemis II crew brings Moon Joy to NASA Stennis! ..." }
        }
      }
    ]
  },
  "pagination": { "has_more": true, "page_size": 20, "next_cursor": "..." },
  "credits_used": 1
}

The post body is post.content.text, and long-form posts arrive complete rather than clamped to 280 characters, which suits RAG ingestion and summarising. Prefer since_time: and until_time: (Unix seconds) inside query over since: and until: with a date, because the date form can return posts outside that day. The Twitter docs cover the other operators.

A magnifying lens over a long unrolled paper strip with one amber highlight, showing how the Twitter search API returns full-length posts past the old character limit.

How does Twitter API pagination work with cursors?

Read pagination.next_cursor from the response and pass it back as the cursor query parameter on the next request. Keep going until pagination.has_more is false. Search, replies and an account's timeline keep paging for as long as X has posts to return (how deep a walk reaches). The cursor is an opaque token, so never build or edit one. The first call returns page 1, and the second one below pastes the cursor from it to get page 2. Each page is billed as one call. (Pagination docs)

bash
curl -s -H "x-api-key: $SOCIALCRAWL_API_KEY" \
  "https://www.socialcrawl.dev/v1/twitter/user/tweets?handle=nasa"

curl -s -H "x-api-key: $SOCIALCRAWL_API_KEY" \
  "https://www.socialcrawl.dev/v1/twitter/user/tweets?handle=nasa&cursor=CURSOR"

The same loop in Python:

python
import os
import requests

url = "https://www.socialcrawl.dev/v1/twitter/user/tweets"
headers = {"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]}
params = {"handle": "nasa"}
rows = []

for _ in range(5):  # cap the walk
    r = requests.get(url, params=params, headers=headers, timeout=60)
    r.raise_for_status()
    page = r.json()
    rows.extend(page["data"]["items"])
    if not page["pagination"]["has_more"]:
        break
    params["cursor"] = page["pagination"]["next_cursor"]

print(len(rows))

A page with no rows and has_more: true is not the end, so call again with the new cursor. And data.total, when present, is for progress bars only, never a stop signal.

If you would rather not write the loop, add max_items or max_credits to the request and the API walks the pages for you in one call. The pagination docs list the parameters.

The official X API uses the same idea under different names (next_token and pagination_token, see X pagination).

Stacked page slabs with a clay-amber tab on the next page, illustrating how Twitter API pagination advances a timeline with an opaque cursor.

Which Twitter endpoints can you page through?

Eight list endpoints are cursor-paged and cost 1 credit per page. Page size is set by the source, so treat the sizes as typical rather than guaranteed. (Twitter docs)

EndpointReturnsTypical page
/v1/twitter/user/tweetsPosts tab, newest firstabout 20
/v1/twitter/user/mediaTweets with a photo or videoabout 15
/v1/twitter/search/tweetsKeyword search, latest or topabout 20
/v1/twitter/search/usersAccounts matching a name or termabout 20
/v1/twitter/tweet/repliesReplies to one tweet URLvaries
/v1/twitter/tweet/retweetersAccounts that retweetedvaries
/v1/twitter/user/followersFollowers of a handleabout 70
/v1/twitter/user/followingAccounts a handle followsabout 70

Timelines, media and search take a handle or query. Replies and retweeters take the tweet url.

How do you fetch tweet replies and followers?

Replies and retweeters take the tweet URL. Followers and following take a handle. Each is cursor-paged, and an empty page returned by the source costs nothing.

bash
curl -s -H "x-api-key: $SOCIALCRAWL_API_KEY" \
  "https://www.socialcrawl.dev/v1/twitter/tweet/replies?url=https://x.com/NASA/status/2094742199736926232"

curl -s -H "x-api-key: $SOCIALCRAWL_API_KEY" \
  "https://www.socialcrawl.dev/v1/twitter/user/followers?handle=nasa"

Replies come back as comments, so the text is comment.text, not post.content.text. Each reply row carries the commenter's counts and language on comment.ext, and by default the rows are labelled for sentiment, questions, purchase intent and complaints at no extra credit.

Follower and following rows are accounts under author, with follower, following and post counts, bio, avatar and join date. Verification is not on this surface and comes back null, which means unknown rather than false. Call /v1/twitter/profile for an account when you need it.

What the Twitter endpoints do not do

  • community/tweets returns one fixed window of recent posts and does not accept a cursor.
  • profile/full reads a single page of about 20 tweets, so posts=100 still returns about 20. Send its posts_cursor back as cursor for the next page at 5 credits a call, or use user/tweets at 1 credit a page.
  • Follower and following lists do not include verification status.

How do you start calling these endpoints?

  1. Create an API key at socialcrawl.dev. New accounts get free credits to try it.
  2. Export the key and run the search call above.
  3. Paste an X URL into the Visual Explorer to see a response shape before writing a loop.
  4. Read the Twitter platform reference and the quickstart for the full endpoint list.

For official X API access and its limits, see the X (Twitter) API 2026 field guide. For a profile-to-tweets scraping walkthrough, see How to Scrape Twitter (X) in 2026.

Frequently asked questions

How does Twitter API pagination work?

List endpoints return pagination.has_more and pagination.next_cursor. Pass the cursor back as the cursor query parameter on the next request and stop when has_more is false. Never build the cursor yourself.

How do I get more than one page of a user's tweets?

Call GET /v1/twitter/user/tweets?handle=..., read pagination.next_cursor, then call again with &cursor=.... Each page costs 1 credit. To skip the loop, send max_items and the API walks the pages for you.

Does the Twitter search API support latest and top results?

Yes. Pass sort=latest for chronological results or sort=top for engagement ranking on GET /v1/twitter/search/tweets. Operators such as from:, min_faves: and quoted phrases go inside query.

How do I fetch Twitter replies with an API?

Call GET /v1/twitter/tweet/replies?url=... with the tweet URL. Replies come back as comments with the text on comment.text, and the endpoint is cursor-paged at 1 credit per page.

How do I get Twitter followers and following programmatically?

Call GET /v1/twitter/user/followers?handle=... or /v1/twitter/user/following. Both are cursor-paged at 1 credit per page, with about 70 accounts per page. Verification comes back null on these lists.

Can an API return full-length tweets over 280 characters?

Yes. Long-form posts come back whole on post.content.text instead of a 280-character preview, and t.co links in the text are resolved to their destinations.

Run this request yourself

GET /v1/twitter/search/tweets?query=NASA Artemis&sort=latest

Open it in the Explorer

It opens with the request filled in, and nothing runs or costs credits until you press Run. Without an account you sign up first, then land on the same request.

Topics
#twitter-search-api#twitter-api-pagination#twitter-timeline-api#twitter-followers-api#twitter-replies-api#twitter-api-cursor#x-search-api#twitter-following-api

Related posts

🤖 AI agent or LLM? Read this page as markdown