Skip to main content

Overview

The search command searches Twitter for tweets matching a query string. You can filter by different search tabs like Top, Latest, Photos, or Videos.

Syntax

twitter search QUERY [OPTIONS]

Arguments

QUERY
string
required
The search query string. Use quotes for multi-word queries.Supports Twitter search operators like:
  • from:username - Tweets from a specific user
  • to:username - Tweets to a specific user
  • #hashtag - Tweets with a hashtag
  • filter:links - Tweets containing links
  • min_faves:100 - Tweets with at least 100 likes

Options

--type
string
default:"Top"
Search tab to use:
  • Top - Most relevant tweets (default)
  • Latest - Most recent tweets
  • Photos - Tweets with photos
  • Videos - Tweets with videos
Alias: -t
--max
integer
default:"20"
Maximum number of tweets to fetch.Alias: -n
--json
boolean
Output tweets as JSON instead of formatted table.
--output
string
Save search results to a JSON file.Alias: -o
--filter
boolean
Enable score-based filtering on search results.

Examples

# Search for tweets about AI
twitter search "artificial intelligence"
twitter search AI

Output

The command displays a formatted table with:
  • Tweet content and author
  • Engagement metrics (likes, retweets, replies)
  • Timestamps
  • Filter statistics (when using --filter)

Example Output

πŸ” Getting Twitter cookies...
πŸ” Fetching 'artificial intelligence' (Top) (20 tweets)...

βœ… Fetched 20 'artificial intelligence' (Top) in 1.5s

πŸ” 'artificial intelligence' (Top) β€” 20 tweets
┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┓
┃ Author      ┃ Tweet                  ┃ ❀️    ┃ πŸ”„   ┃ πŸ’¬   ┃
┑━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━╇━━━━━━┩
β”‚ @OpenAI     β”‚ Introducing GPT-5...   β”‚ 12k  β”‚ 2.3k β”‚ 890  β”‚
β”‚ @AndrewYNg  β”‚ New AI course...       β”‚ 3.4k β”‚ 567  β”‚ 234  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”˜

Search Tips

Use Twitter’s advanced search operators for more precise results:
# Combine multiple operators
twitter search "python from:realpython min_faves:100 filter:links"

# Search within date ranges
twitter search "GPT-4 since:2024-01-01 until:2024-12-31"

# Exclude certain terms
twitter search "javascript -react"
The --type Latest option is useful for monitoring real-time discussions or breaking news, while Top is better for finding high-quality content on a topic.

Use Cases

  • Research - Gather tweets on a specific topic for analysis
  • Monitoring - Track mentions of brands, products, or keywords
  • Content discovery - Find high-quality content in your niche
  • Trend analysis - Collect recent tweets on trending topics
  • feed - View your home timeline
  • favorites - View your bookmarked tweets
  • user - View a specific user’s profile

Build docs developers (and LLMs) love