Twitter / X

Search tweets and user timelines on X/Twitter with advanced filters

Overview

Search X/Twitter by query text, username, date range, and content type filters. Returns one page of tweets at a time. Use nextPageToken to paginate.

Base path: https://api.datacaiman.com/v1/twitter

Cost: 1 credit per call


GET /v1/twitter/search

At least one of query or username is required.

Parameters

Name Type Required Description
query string No* Search query text
username string No* Username without @. Can be combined with query
minDate string No Earliest date, YYYY-MM-DD (inclusive)
maxDate string No Latest date, YYYY-MM-DD (inclusive)
pageToken string No Token from previous response to get the next page

* At least one of query or username must be provided.

Tri-state filters

These parameters accept only, exclude, or empty string (no filter):

Name Description
replies Include, exclude, or only show replies
retweets Include, exclude, or only show retweets
quotes Include, exclude, or only show quote tweets
verified Filter by verified (blue checkmark) accounts
links Filter tweets containing links
media Filter tweets containing any media
images Filter tweets containing images
videos Filter tweets containing videos
news Filter news articles
safe Safe search filter

Additional filters

Name Type Description
near string Location bias (e.g. New York)

Response

{
  "hasNextPage": true,
  "nextPageToken": "eyJj...",
  "items": [
    {
      "id": "1234567890",
      "permalink": "https://x.com/user/status/1234567890",
      "username": "user",
      "text": "Tweet content here",
      "createdAt": "2024-08-02T20:25:00Z",
      "comments": 12,
      "retweets": 34,
      "quotes": 5,
      "likes": 200
    }
  ]
}

Examples

Search by keyword:

curl "https://api.datacaiman.com/v1/twitter/search?query=bitcoin" \
  -H "X-API-Key: dc_your_key_here"

Get a user’s tweets excluding retweets:

curl "https://api.datacaiman.com/v1/twitter/search?username=elonmusk&retweets=exclude" \
  -H "X-API-Key: dc_your_key_here"

Search with date range:

curl "https://api.datacaiman.com/v1/twitter/search?query=bitcoin&minDate=2024-01-01&maxDate=2024-01-31" \
  -H "X-API-Key: dc_your_key_here"

Paginate to the next page:

curl "https://api.datacaiman.com/v1/twitter/search?query=bitcoin&pageToken=eyJj..." \
  -H "X-API-Key: dc_your_key_here"