Skip to main content
Fetches tweets from Twitter/X using the TwitterAPI.io advanced search API. Uses Twitter’s native advanced search syntax (from:, to:, lang:, since:, until:, OR, etc.). Returns a dataset with 37 columns: tweet text, author info, engagement metrics, entities (hashtags, URLs, mentions), media URLs, and quoted/retweeted tweets. Cost: ~$0.15 per 1,000 tweets (15 credits per tweet).

Query Syntax

OperatorExampleDescription
from:from:NASATweets from a user
to:to:NASATweets replying to a user
lang:lang:esFilter by language
since:since:2026-01-01Tweets after date
until:until:2026-02-01Tweets before date
ORcat OR dogEither term
-cat -dogExclude term
"""exact phrase"Exact match
min_faves:min_faves:100Minimum likes
filter:mediafilter:mediaOnly with media
-filter:retweetsExclude retweets

Error Handling

  • Rate limit (429): Retries with exponential backoff
  • Credits exhausted (402): Returns partial data with warning (W41)
  • Timeout: Returns partial data with warning (W41)
Learn more at docs.twitterapi.io.

Usage

The following example shows how the step can be used in a recipe.

Examples

Fetch tweets about climate change in English
fetch_twitter_api_io({
    "integration": "MY_TWITTER_API_IO",
    "query": "\"climate change\" lang:en since:2026-01-01",
    "query_type": "Latest",
    "max_items": 5000
}) -> (ds_out)

Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally columns (ds.first_name), datasets (ds or ds[["first_name", "last_name"]]) or models (referenced by name e.g. "churn-clf").
ds_out
dataset
required
The dataset containing tweets from the search.

Configuration

The following parameters can be used to configure the behaviour of the step by including them in a json object as the last “input” to the step, i.e. step(..., {"param": "value", ...}) -> (output).

Parameters

integration
string
required
TwitterAPI.io Integration. ID of your TwitterAPI.io integration containing the API key.
query
string
required
Search Query. Twitter advanced search query. Supports operators: from:, to:, lang:, since:YYYY-MM-DD, until:YYYY-MM-DD, OR, -, “exact phrase”, min_replies:, min_faves:, filter:links, filter:media. Reference: https://github.com/igorbrigadir/twitter-advanced-search.
query_type
string
default:"Latest"
Sort Order. Sort order. “Latest” for chronological, “Top” for most relevant.Values must be one of the following:
  • Latest
  • Top
max_items
integer
Max Tweets. Maximum number of tweets to fetch. Leave empty to fetch all matching tweets. Cost: ~15 credits per tweet ($0.15 per 1,000 tweets).
timeout
integer
default:"3600"
Timeout. Maximum seconds to wait for the search to complete.