Data Analysis

    How to Search Hashtags on X (Twitter), With and Without Code

    By Desearch Editorial Team6 min read

    Yes, you can search hashtags on X. Type the hashtag with its #, such as #buildinpublic, into the X search box and press Enter. Choose Top for the most engaged posts or Latest for the newest. Add operators like since:, lang:, or min_faves: to narrow the results. To collect hashtag posts as data, send the same query to an X search API.

    This guide shows the search operators for hashtags, then a Python example that uses the Desearch X API to pull posts and count the hashtags that appear alongside yours.

    Search a hashtag on X

    1. Open X and click the search box.
    2. Type the hashtag, including #, for example #opensource.
    3. Press Enter.
    4. Select Top for popular posts or Latest for a time-ordered feed.

    Searching for opensource without the # also matches posts that use the word without tagging it. Keep the # when you only want tagged posts.

    Combine hashtags and filters

    Hashtags work with the rest of the X search operators:

    GoalQuery
    Either of two hashtags#ai OR #machinelearning
    Both hashtags in the same post#ai #agents
    A hashtag without another term#ai -crypto
    One language#ai lang:en
    A date range#ai since:2026-09-01 until:2026-09-08
    Only popular posts#ai min_faves:100
    Leave out replies#ai -filter:replies
    From one account#ai from:username

    until: is not inclusive, so until:2026-09-08 stops at the end of September 7. The full list is in the X query syntax guide.

    Search hashtags with the Desearch X API

    GET /twitter accepts the same query syntax. Encode # as %23 in a URL:

    curl --request GET 'https://api.desearch.ai/twitter?query=%23opensource&sort=Latest&lang=en&count=50' \
      --header "Authorization: $DESEARCH_API_KEY"
    

    The API also has parameters for common filters, so you don't have to write them into the query:

    ParameterMeaning
    sortTop or Latest
    start_date, end_dateDate range in UTC, YYYY-MM-DD
    langLanguage code, such as en
    min_likes, min_retweets, min_repliesMinimum engagement
    verified, blue_verifiedOnly posts from verified accounts
    is_image, is_video, is_quoteOnly posts with images, videos, or quotes
    countPosts to return, 1 to 100 (default 20)

    Get an API key from Desearch Console. You don't need an X developer account.

    Count the hashtags that appear with yours

    Each post returns its hashtags in entities.hashtags. That makes it easy to see which topics travel with a hashtag:

    import os
    from collections import Counter
    
    import requests
    
    API_KEY = os.environ["DESEARCH_API_KEY"]
    
    def search_hashtag(hashtag, **filters):
        response = requests.get(
            "https://api.desearch.ai/twitter",
            headers={"Authorization": API_KEY},
            params={"query": hashtag, "sort": "Latest", "count": 100, **filters},
        )
        response.raise_for_status()
        return response.json()
    
    posts = search_hashtag("#opensource", lang="en", min_likes=5)
    
    related = Counter()
    for post in posts:
        entities = post.get("entities") or {}
        tags = {tag["text"].lower() for tag in entities.get("hashtags") or []}
        related.update(tags - {"opensource"})
    
    print(f"{len(posts)} posts")
    for tag, count in related.most_common(10):
        print(f"#{tag}: {count}")
    

    requests encodes the # for you when it's passed in params. To track a hashtag over time, run the search on a schedule with start_date and end_date, and store each post by its id so repeated posts are counted once.

    To see what's trending instead of searching a known hashtag, use GET /twitter/trends with a location's WOEID. 23424977 is the United States:

    curl --request GET 'https://api.desearch.ai/twitter/trends?woeid=23424977' \
      --header "Authorization: $DESEARCH_API_KEY"
    

    What it costs

    X Search is billed at $0.15 per 1,000 posts (reference rate as of 7 May 2026, see pricing). Every billable response reports its exact cost in the X-Desearch-Cost-Usd header.

    Frequently asked questions

    How do I search two hashtags at once?

    Use OR to match either hashtag, such as #ai OR #ml. Put both hashtags side by side, such as #ai #ml, to match only posts that contain both.

    How do I find the most popular posts for a hashtag?

    Select Top on X, or set sort=Top in the API. For a hard threshold, add min_faves:100 to the query, or min_likes=100 as an API parameter.

    How do I search a hashtag for a specific date?

    Add since: and until:, for example #launchday since:2026-03-10 until:2026-03-11 for March 10. In the API, use start_date and end_date. For older posts, see how to find old tweets by keyword.

    Put your next idea to work.

    Try a query in the playground, then use the docs to bring Desearch into your application.

    Browse more articles