X Search

    X Search returns X/Twitter posts and related metadata for keyword, user, post, reply, retweeter, and trend workflows.

    Search endpoint

    text
    GET https://api.desearch.ai/twitter

    Example request

    bash
    curl --request GET 'https://api.desearch.ai/twitter?query=Bittensor&sort=Top&count=20' \ --header 'Authorization: $DESEARCH_API_KEY'

    Python example

    python
    import os import requests response = requests.get( "https://api.desearch.ai/twitter", params={"query": "Bittensor", "sort": "Top", "count": 20}, headers={"Authorization": os.environ["DESEARCH_API_KEY"]}, timeout=60, ) response.raise_for_status() print(response.json()) print(response.headers.get("X-Desearch-Cost-Usd"))

    JavaScript example

    js
    const url = new URL("https://api.desearch.ai/twitter"); url.searchParams.set("query", "Bittensor"); url.searchParams.set("sort", "Top"); url.searchParams.set("count", "20"); const response = await fetch(url, { headers: { Authorization: process.env.DESEARCH_API_KEY }, }); if (!response.ok) throw new Error(await response.text()); console.log(await response.json()); console.log(response.headers.get("X-Desearch-Cost-Usd"));

    Billing

    X Search bills for the posts actually returned, with a minimum of 10 posts per request: empty or low-result searches are charged the 10-post minimum rather than the full count. See Pricing and Billing for details.

    Related X endpoints

    The API Reference also documents endpoints for:

    • Fetching posts by URL.
    • Retrieving a post by ID.
    • Searching posts by user.
    • Fetching a user's tweets and replies.
    • Retrieving replies for a post.
    • Getting retweeters.
    • Getting X trends.

    Use GET /twitter for general search and the more specific retrieval endpoints when you already know a post, URL, user, or trend target.