The Basic X (Twitter) Search API allows users to search for relevant links or tweets based on X (Twitter) search queries without leveraging AI-powered models. This API analyze links from X (Twitter) posts that match the given prompt.

Using the X (Twitter) Posts Search API

The following examples demonstrate how to interact with the Basic X (Twitter) Search API using multiple coding platform.

Request Sample

The below code snippet script:

  • Interacts with the Datura AI Twitter API https://apis.datura.ai/twitter to retrieve tweets related to the keyword “Bittensor” within a specified date range.

  • The code then sends a POST request with a structured JSON payload containing search parameters such as language (English), sorting order (Top), and engagement filters (minimum likes, replies, and retweets set to zero).

  • The request also specifies that the results should exclude tweets containing images, videos, or quotes and should not be limited to blue-verified accounts.

  • The API request is authenticated via an authorization key, and upon execution, the script prints the HTTP response status code along with the JSON-formatted search results.

    import requests

    url = "https://apis.datura.ai/twitter"
    headers = {
        "Authorization": "<your-api-key>",
        "Content-Type": "application/json"
    }
    payload = {
        "query": "Bittensor",
        "blue_verified": False,
        "end_date": "2025-02-17",
        "is_image": False,
        "is_quote": False,
        "is_video": False,
        "lang": "en",
        "min_likes": 0,
        "min_replies": 0,
        "min_retweets": 0,
        "sort": "Top",
        "start_date": "2025-02-16"
    }

    response = requests.post(url, json=payload, headers=headers)

    print(response.status_code)
    print(response.json())

Parameters

Required

Optional

  • sort: Sort by Top or Latest, e.g., “Top”.
  • start_date: Start date in UTC (YYYY-MM-DD format), e.g., “2025-01-01”.
  • end_date: End date in UTC (YYYY-MM-DD format), e.g., “2025-01-01”.
  • lang: Language code (e.g., en, es, fr), e.g., “en”.
  • verified: Filter for verified users, e.g., “true”.
  • blue_verified: Filter for blue checkmark verified users e.g., “true”.
  • is_quote: Include only tweets with quotes e.g., “true”.
  • is_video: Include only tweets with videos e.g., “true”.
  • is_image: Include only tweets with images e.g., “true”.
  • min_retweets: Minimum number of retweets, e.g., 0.
  • min_replies: Minimum number of replies, e.g., 0.
  • min_likes: Minimum number of likes, e.g., 0.

Response Sample

Based on the above code, here is how the response is retrieve as JSON. Each coding language has its own way of retrieving data from the below JSON.

    [
        {
            "user": {
            "id": "1453417787746029577",
            "url": "https://x.com/firsttensor",
            "name": "Firsττensor - Biττensor Validator",
            "username": "firsttensor",
            "created_at": "2021-10-27",
            "followers_count": 4669,
            "profile_image_url": "https://pbs.twimg.com/profile_images/1890150870563614720/L3PGGoUs_normal.jpg"
            },
            "id": "1891203972003684353",
            "text": "How to Stake/Unstake $TAO to the FirstTensor Validator Using the YUMA Platform.\n\n✅ Make sure your wallet is imported into the Polkadot.js or Bittensor Wallet extension.\n\n👇Share this so everyone can use it! \n\n#bittensor #delegate #root",
            "retweet_count": 2,
            "like_count": 7,
            "created_at": "2025-02-16",
            "url": "https://x.com/firsttensor/status/1891203972003684353",
            "media": [
            {
                "media_url": "https://pbs.twimg.com/ext_tw_video_thumb/1891202584314105856/pu/img/nzOtIMS_Zz7YWHJY.jpg",
                "type": "video"
            }
            ],
            "hashtags": ["bittensor", "delegate", "root"]
        }
    ]
  

Test API

To experiment with the Basic X (Twitter) Search API and see it in action, visit the Basic X (Twitter) Search API.

X (Twitter) Search Operators Guide

X (Twitter) search operators allow users to refine their searches on Web, Mobile, and TweetDeck.

Search Operators

Here are the primary operations that can be used over tweets, users, engagement, media, and more.

Tweet Content

keyword1 keyword2 - Tweets containing both words (AND logic). keyword1 OR keyword2 – Tweets containing either word. “exact phrase” – Matches the complete phrase. +word – Forces inclusion of the word. -word – Excludes the word. #hashtag – Searches for tweets with a specific hashtag. $TWTR – Searches for stock symbols (cashtags). url:example.com – Finds tweets linking to a specific domain. lang:en – Filters tweets by language.

User-Based Filters

from:user – Tweets from a specific user. to:user – Replies to a specific user. @user – Mentions of a specific user. filter:verified – Tweets from verified users.

Geolocation Filters

near:city – Tweets geotagged to a location. within:10km – Restricts results to a radius from the specified location. geocode:lat,long,radius – Searches within a specific latitude and longitude.

Date & Time Filters

since:YYYY-MM-DD – Tweets from a specified date onward. until:YYYY-MM-DD – Tweets before a specified date. since_time:timestamp – Tweets after a UNIX timestamp. until_time:timestamp – Tweets before a UNIX timestamp.

Tweet Type Filters

filter:retweets – Shows retweets. filter:replies – Shows only replies. filter:quote – Shows quote tweets. conversation_id:tweet_id – Finds tweets within a specific thread.

Engagement Filters

min_retweets:10 – Tweets with at least 10 retweets. min_faves:50 – Tweets with at least 50 likes. min_replies:5 – Tweets with at least 5 replies. min_retweets:100 – Tweets with a maximum of 100 retweets.

Media Filters

filter:media – Tweets with any media. filter:images – Tweets with images. filter:videos – Tweets with videos. filter:native_video – Tweets with X (Twitter)-hosted videos. filter:spaces – Tweets from X (TwitterX ( Spaces.

Additional Filters

filter:links – Tweets containing links. filter:mentions – Tweets with mentions. filter:news – Tweets linking to news articles. filter:safe – Excludes NSFW content.

App-Specific Filters

source:client_name – Tweets from a specific app (e.g., TweetDeck). card_name:summary_large_image – Tweets containing large summary cards. card_name:player – Tweets with embedded players.

Matching Behavior

By default, X (Twitter) displays “Top” results, prioritizing tweets with engagement. Keyword searches match tweet text, usernames, screen names, and URLs.

For more details on using advance X (Twitter) search operators, please visit here.