> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drain.lat/llms.txt
> Use this file to discover all available pages before exploring further.

# Twitter / X

> Fetch public Twitter/X profiles, stats, search users, and bulk lookup.

# Twitter / X

**Base URL:** `https://drain.lat/api/v1/twitter`

<Note>
  First requests may be slower than usual while the scraper initializes.
</Note>

<AccordionGroup>
  <Accordion title="GET /profile/:username" icon="user">
    Fetch a Twitter/X public profile.

    ```
    GET /api/v1/twitter/profile/:username
    ```

    <ParamField path="username" type="string" required>
      The Twitter/X username to look up.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/twitter/profile/elonmusk" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/twitter/profile/elonmusk", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/twitter/profile/elonmusk",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="name" type="string">Display name.</ResponseField>
    <ResponseField name="username" type="string">Twitter handle.</ResponseField>
    <ResponseField name="bio" type="string">Profile bio.</ResponseField>
    <ResponseField name="followers" type="string">Follower count (formatted, e.g. `219.4M`).</ResponseField>
    <ResponseField name="following" type="string">Following count.</ResponseField>
    <ResponseField name="posts" type="string">Total post count.</ResponseField>
    <ResponseField name="verified" type="boolean">Whether the account is verified.</ResponseField>
    <ResponseField name="profileImage" type="string">Profile image URL.</ResponseField>
    <ResponseField name="bannerImage" type="string">Banner image URL.</ResponseField>
    <ResponseField name="location" type="string">Location listed on profile.</ResponseField>
    <ResponseField name="website" type="string">Website listed on profile.</ResponseField>
    <ResponseField name="joinedDate" type="string">When the account was created.</ResponseField>

    ```json Response theme={null}
    {
      "name": "Elon Musk",
      "username": "elonmusk",
      "bio": "Mars & Cars, Chips & Doge",
      "followers": "219.4M",
      "following": "1,012",
      "posts": "47.2K",
      "verified": true,
      "profileImage": "https://pbs.twimg.com/profile_images/...",
      "bannerImage": "https://pbs.twimg.com/profile_banners/...",
      "location": "",
      "website": "",
      "joinedDate": "Joined June 2009",
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /profile/:username/stats" icon="chart-bar">
    Get just the key stats for a Twitter user - faster than the full profile.

    ```
    GET /api/v1/twitter/profile/:username/stats
    ```

    <ParamField path="username" type="string" required>
      The Twitter/X username.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/twitter/profile/elonmusk/stats" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/twitter/profile/elonmusk/stats", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/twitter/profile/elonmusk/stats",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    ```json Response theme={null}
    {
      "username": "elonmusk",
      "followers": "219.4M",
      "following": "1,012",
      "posts": "47.2K",
      "verified": true,
      "joinedDate": "Joined June 2009",
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /search" icon="magnifying-glass">
    Search for Twitter users by keyword.

    ```
    GET /api/v1/twitter/search?q=query
    ```

    <ParamField query="q" type="string" required>
      Search query keyword.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/twitter/search?q=nasa" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/twitter/search?q=nasa", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/twitter/search",
          params={"q": "nasa"},
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    ```json Response theme={null}
    [
      {
        "name": "NASA",
        "username": "NASA",
        "bio": "Explore the universe and discover our home planet.",
        "verified": true,
        "profileImage": "https://pbs.twimg.com/profile_images/..."
      }
    ]
    ```

    <Note>Returns up to 10 results per query.</Note>
  </Accordion>

  <Accordion title="POST /bulk/profiles" icon="users">
    Fetch multiple Twitter profiles in a single request.

    ```
    POST /api/v1/twitter/bulk/profiles
    ```

    <ParamField body="usernames" type="string[]" required>
      Array of Twitter usernames to look up. Maximum 5.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST "https://drain.lat/api/v1/twitter/bulk/profiles" \
        -H "x-api-key: YOUR_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{"usernames": ["elonmusk", "nasa"]}'
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/twitter/bulk/profiles", {
        method: "POST",
        headers: {
          "x-api-key": "YOUR_API_KEY",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({ usernames: ["elonmusk", "nasa"] })
      });
      const data = await res.json();
      ```

      ```python Python theme={null}
      import requests

      res = requests.post(
          "https://drain.lat/api/v1/twitter/bulk/profiles",
          headers={"x-api-key": "YOUR_API_KEY"},
          json={"usernames": ["elonmusk", "nasa"]}
      )
      print(res.json())
      ```
    </CodeGroup>

    ```json Response theme={null}
    [
      {
        "username": "elonmusk",
        "success": true,
        "data": {
          "name": "Elon Musk",
          "username": "elonmusk",
          "followers": "219.4M",
          "verified": true
        }
      },
      {
        "username": "nasa",
        "success": true,
        "data": {
          "name": "NASA",
          "username": "NASA",
          "followers": "98.2M",
          "verified": true
        }
      }
    ]
    ```

    <Warning>Maximum 5 usernames per request. Profiles are fetched sequentially so larger batches take longer.</Warning>
  </Accordion>
</AccordionGroup>
