X Posts Search

Search links using X Search backed up with AI-powered models.


The X Posts Search API allows users to search for relevant links based on X search queries by leveraging AI-powered models. This API analyzes links from X posts that match the given prompt. This API is useful for tracking trends, gathering insights, and retrieving real-time information from X.

Using the X Posts Search API

The following examples demonstrate how to interact with the X Posts Search API using multiple coding platforms.

Request Sample

This script sends:

  • A POST request to the AI-powered search API endpoint https://apis.datura.ai/desearch/ai/search/links/twitter.

  • The request body (payload) contains a "prompt" field with the query "What are the recent sport events?" and specifies "model": "NOVA"
    as the AI model to be used.

  • The Authorization header includes an API key, and the Content-Type is set to "application/json".

  • The script sends the request, passing the URL, payload, and headers, and then prints the raw response text.

    import requests

    url = "https://apis.datura.ai/web"

    params =  {
      "query": "latest news on AI",
      "num": 10,
      "start": 0
    }
    headers = {
        "Authorization": "<your-api-key>",
        "Content-Type": "application/json"
    }

    response = requests.get("GET", url, params=params, headers=headers)

    print(response.text)
    const fetch = require("node-fetch");

    const url = "https://apis.datura.ai/web";
    const params = new URLSearchParams({
        query: "latest news on AI",
        num: 10,
        start: 0
    });

    const headers = {
        "Authorization": "<your-api-key>",
        "Content-Type": "application/json"
    };

    fetch(`${url}?${params.toString()}`, {
        method: "GET",
        headers: headers
    })
    .then(response => response.text())
    .then(data => console.log(data))
    .catch(error => console.error("Error:", error));

    const axios = require("axios");

    const url = "https://apis.datura.ai/web";

    const params = {
        query: "latest news on AI",
        num: 10,
        start: 0
    };

    const headers = {
        Authorization: "<your-api-key>",
        "Content-Type": "application/json"
    };

    axios.get(url, { params, headers })
        .then(response => console.log(response.data))
        .catch(error => console.error("Error:", error.response?.data || error.message));
    <?php

    $url = "https://apis.datura.ai/web";
    $params = http_build_query([
        "query" => "latest news on AI",
        "num" => 10,
        "start" => 0
    ]);

    $headers = [
        "Authorization: <your-api-key>",
        "Content-Type: application/json"
    ];

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "$url?$params");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    $response = curl_exec($ch);
    curl_close($ch);

    echo $response;
    ?>
    import Foundation

    let urlString = "https://apis.datura.ai/web"
    var components = URLComponents(string: urlString)
    components?.queryItems = [
        URLQueryItem(name: "query", value: "latest news on AI"),
        URLQueryItem(name: "num", value: "10"),
        URLQueryItem(name: "start", value: "0")
    ]

    guard let url = components?.url else { return }

    var request = URLRequest(url: url)
    request.httpMethod = "GET"
    request.setValue("<your-api-key>", forHTTPHeaderField: "Authorization")
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")

    let task = URLSession.shared.dataTask(with: request) { data, response, error in
        if let error = error {
            print("Error: \(error)")
            return
        }
        if let data = data, let responseString = String(data: data, encoding: .utf8) {
            print("Response: \(responseString)")
        }
    }

    task.resume()

Parameters

Required

  • url: The endpoint for the X (Twitter) Posts Search API.

  • payload/body: A JSON string or dictionary containing:

    • prompt: A string representing the search query.
    • model: The model to be used for processing, e.g., "NOVA".

Response Sample

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

    {
        "miner_tweets": [
            {
            "user": {
                "id": "1582652879428624384",
                "url": "https://x.com/Theolaw19",
                "name": "TheophilusLawrence",
                "username": "Theolaw19",
                "created_at": "2022-10-19T08:41:03Z",
                "description": "Obedient Citizen// Advocate for good governance// An Accountant.",
                "followers_count": 2432,
                "profile_image_url": "https://pbs.twimg.com/profile_images/1743878815720357888/DgLOLAMT_normal.jpg",
                "profile_banner_url": "https://pbs.twimg.com/profile_banners/1582652879428624384/1718389043",
                "statuses_count": 40490,
                "verified": false,
                "is_blue_verified": true,
                "location": "Abuja, Nigeria"
            },
            "id": "1889532907418689681",
            "text": "Tesla's meteoric rise vs. Toyota's steady performance. Tesla's EV dominance continues, while Toyota faces challenges transitioning from combustion to electric.",
            "reply_count": 46,
            "like_count": 50,
            "bookmark_count": 16,
            "url": "https://x.com/Theolaw19/status/1889532907418689681",
            "created_at": "2025-02-12T04:32:05Z",
            "media": [
                {
                "media_url": "https://pbs.twimg.com/media/Gjj4KUBW4AA07pb.jpg",
                "type": "photo"
                }
            ],
            "lang": "en"
            }
        ]
    }

Models

Nova 1.0

Quick insights, broad coverage.

Orbit 1.0

Balanced analysis, targeted relevance.

Horizon 1.0

In-depth exploration, profound insights.


Test API

To experiment with the X Posts Search API and see it in action, visit the X Posts Search API.