Skip to main content
Searching through X (Twitter) data is the backbone of Social Listening, Market Research, and Data Journalism. The Sorsa /search-tweets endpoint allows you to programmatically access the global conversation on X, using the same powerful engine that drives the native X search bar.

💡 Use Cases

  • Brand Monitoring: Track keywords related to your product to react to feedback.
  • Competitor Intelligence: Monitor what users are saying about competitors.
  • Market Trends: Identify emerging topics in Crypto, AI, or Finance.
  • Lead Generation: Find high-intent users asking for recommendations in your niche.
📝 Note on Mentions: > While you can find mentions using general search, we have a dedicated endpoint for that. See our guide: How to Search Mentions of Account.

📥 Request Parameters

The endpoint uses the POST method. This is designed for handling complex queries securely and efficiently.
ParameterTypeDescription
querystringRequired. Your keywords, hashtags, or complex search strings.
orderstringOptional. Sorting logic. Defaults to latest. • latest: Newest tweets first. • popular: Top first.
next_cursorstringOptional. The cursor for the next page of results. Omit for the first request.
🚀 Advanced Search Power Sorsa API supports all native X search operators (e.g., min_faves:100, lang:en, since:2024-01-01). Mastering Search Operators →

🛠 Implementation Example

cURL

Bash
curl --request POST \
  --url https://api.sorsa.io/v3/search-tweets \
  --header 'ApiKey: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "elonmusk",
  "order": "latest"
}'

Python

Python
import requests

API_KEY = "YOUR_API_KEY"
URL = "https://api.sorsa.io/v3/search-tweets"

def search_tweets(query, order="latest", cursor=None):
    payload = {
        "query": query,
        "order": order,
        "next_cursor": cursor
    }
    headers = {
        "ApiKey": API_KEY,
        "Content-Type": "application/json"
    }
    
    response = requests.post(URL, json=payload, headers=headers)
    return response.json()

# Example usage
results = search_tweets("elonmusk", order="latest")
print(f"Found {len(results['tweets'])} tweets")

📤 Response Structure

The response provides a complete data set, including full tweet metrics and detailed user profiles. JSON
{
  "next_cursor": "JKHSJFHADUYJKSDy2y3u123",
  "tweets": [
    {
      "id": "1894321...",
      "full_text": "Is there anything more fun than X?",
      "created_at": "Fri Feb 27 10:00:00 +0000 2026",
      "likes_count": 123,
      "retweet_count": 123,
      "reply_count": 123,
      "quote_count": 123,
      "view_count": 123,
      "bookmark_count": 123,
      "lang": "en",
      "is_reply": true,
      "in_reply_to_username": "username",
      "entities": [
        {
          "link": "https://t.co/...",
          "preview": "https://pbs.twimg.com/...",
          "type": "photo"
        }
      ],
      "user": {
        "id": "44196397",
        "username": "elonmusk",
        "display_name": "Elon Musk",
        "description": "...",
        "followers_count": 123,
        "followings_count": 123,
        "verified": true,
        "profile_image_url": "https://pbs.twimg.com/..."
      }
    }
  ]
}

🔄 Pagination Logic

  1. Initial Request: Send your query. Leave next_cursor empty.
  2. Continue: The API returns a next_cursor string. Pass this string into your next request’s next_cursor field.
  3. Finish: When next_cursor in the response is null or an empty string, you have collected all available results.

  • Filter Noise: Use advanced operators like -filter:links or min_retweets:5 to clean your data. Read more in our Operators Guide.
  • Language Specifics: Add lang:es or lang:en directly into the query string to target specific regions.
  • Engagement Gating: Use order: "popular" to identify the most viral content for your research.

⏭ Next Steps