Skip to content

About

X (Twitter) Scraper API by Piloterr: x post info, x profile info data from X (Twitter) as structured JSON. Python, TypeScript, cURL, PHP, C#, Go, Java, Ruby examples.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

X (Twitter) Scraper API by Piloterr – scrape X (Twitter) data as JSON

X (Twitter) Scraper API

Discord Get API key API docs License: MIT

The Piloterr X (Twitter) Scraper API lets you extract public data from X (Twitter) as clean, structured JSON — no proxies, headless browsers or HTML parsing to maintain. Endpoints available in production:

  • X Post Info API — X Post Info API: fetch public tweet data (text, likes, retweets, views, media) from a status URL or tweet ID via browser rendering.
  • X Profile Info API — X Profile Info API: fetch public X/Twitter profile data (bio, followers, verification, avatars) from a username or URL via browser rendering.

Use it for brand monitoring, social listening, influencer research, ad intelligence or content analytics on public data.

Endpoint Path Credits What you get
X Post Info API /v2/x/post/info 2 X Post Info API
X Profile Info API /v2/x/profile/info 2 X Profile Info API

Table of contents

How it works

  1. Create a free Piloterr account and copy your API key from the dashboard.
  2. Send a GET (or POST) request to https://api.piloterr.com/v2/... with the header x-api-key: YOUR_API_KEY.
  3. Receive structured JSON — Piloterr handles rendering, proxies, retries and parsing.
export PILOTERR_API_KEY="your-api-key"
pip install requests        # Python
# TypeScript: Node.js 18+ (native fetch), run with `npx tsx file.ts`

Every endpoint accepts both GET (query string) and POST (JSON body with the same fields).

X Post Info API

X Post Info API: fetch public tweet data (text, likes, retweets, views, media) from a status URL or tweet ID via browser rendering.

GET | POST https://api.piloterr.com/v2/x/post/info · 2 credits per request · Full reference

Request parameters

Parameter Type Required Description
query string ✅ X tweet to retrieve. Accepts a full status URL or numeric tweet ID.
return_page_source boolean — When true, return the raw HTML page source as {"result": "..."} instead of structured JSON. Defaults to false.

Python example

import json
import os
import requests

response = requests.get(
    "https://api.piloterr.com/v2/x/post/info",
    headers={"x-api-key": os.environ["PILOTERR_API_KEY"]},
    params={
        "query": "https://x.com/example-user/status/0000000000000000001",
    },
    timeout=120,
)
response.raise_for_status()
data = response.json()

print(json.dumps(data, indent=2, ensure_ascii=False)[:2000])

TypeScript example

type XPostInfo = {
  url?: string;
  name?: unknown;
  text?: string;
  media?: string[];
  tweet_id?: string;
  username?: string;
  verified?: boolean;
  created_at?: unknown;
  like_count?: number;
  view_count?: number;
  reply_count?: number;
  retweet_count?: number;
};

const params = new URLSearchParams({
  "query": "https://x.com/example-user/status/0000000000000000001",
});

const response = await fetch(`https://api.piloterr.com/v2/x/post/info?${params}`, {
  headers: { "x-api-key": process.env.PILOTERR_API_KEY! },
});
if (!response.ok) throw new Error(`Piloterr error ${response.status}: ${await response.text()}`);

const data = (await response.json()) as XPostInfo;

console.log(JSON.stringify(data, null, 2).slice(0, 2000));
POST variant
POST https://api.piloterr.com/v2/x/post/info
x-api-key: YOUR_API_KEY
Content-Type: application/json

{"query": "https://x.com/example-user/status/0000000000000000001"}

Output example

Response shape with placeholder values — field names follow the API reference.

{
  "url": "example",
  "name": "example",
  "text": "example",
  "media": [
    "example"
  ],
  "tweet_id": "example",
  "username": "example",
  "verified": false,
  "created_at": "example",
  "like_count": 0,
  "view_count": 0,
  "reply_count": 0,
  "retweet_count": 0
}

Response fields

Field Type Description
url string
name object
text string
media string[]
tweet_id string
username string
verified boolean
created_at object
like_count integer
view_count integer
reply_count integer
retweet_count integer

X Profile Info API

X Profile Info API: fetch public X/Twitter profile data (bio, followers, verification, avatars) from a username or URL via browser rendering.

GET | POST https://api.piloterr.com/v2/x/profile/info · 2 credits per request · Full reference

Request parameters

Parameter Type Required Description
query string ✅ X profile to look up. Accepts a username, @handle, or profile URL.
return_page_source boolean — When true, return the raw HTML page source as {"result": "..."} instead of structured JSON. Defaults to false.

Python example

import json
import os
import requests

response = requests.get(
    "https://api.piloterr.com/v2/x/profile/info",
    headers={"x-api-key": os.environ["PILOTERR_API_KEY"]},
    params={
        "query": "elonmusk",
    },
    timeout=120,
)
response.raise_for_status()
data = response.json()

print(json.dumps(data, indent=2, ensure_ascii=False)[:2000])

TypeScript example

type XProfileInfo = {
  url?: string;
  name?: string;
  user_id?: string;
  location?: unknown;
  username?: string;
  verified?: boolean;
  created_at?: string;
  description?: string;
  tweet_count?: number;
  followers_count?: number;
  following_count?: number;
  profile_image_url?: string;
  profile_banner_url?: string;
  profile_image_url_normal?: string;
};

const params = new URLSearchParams({
  "query": "elonmusk",
});

const response = await fetch(`https://api.piloterr.com/v2/x/profile/info?${params}`, {
  headers: { "x-api-key": process.env.PILOTERR_API_KEY! },
});
if (!response.ok) throw new Error(`Piloterr error ${response.status}: ${await response.text()}`);

const data = (await response.json()) as XProfileInfo;

console.log(JSON.stringify(data, null, 2).slice(0, 2000));
POST variant
POST https://api.piloterr.com/v2/x/profile/info
x-api-key: YOUR_API_KEY
Content-Type: application/json

{"query": "elonmusk"}

Output example

Response shape with placeholder values — field names follow the API reference.

{
  "url": "example",
  "name": "example",
  "user_id": "example",
  "location": "example",
  "username": "example",
  "verified": false,
  "created_at": "example",
  "description": "example",
  "tweet_count": 0,
  "followers_count": 0,
  "following_count": 0,
  "profile_image_url": "example",
  "profile_banner_url": "example",
  "profile_image_url_normal": "example"
}

Response fields

Field Type Description
url string
name string
user_id string
location object
username string
verified boolean
created_at string
description string
tweet_count integer
followers_count integer
following_count integer
profile_image_url string
profile_banner_url string
profile_image_url_normal string

Code examples in other languages

Ready-to-run examples live in the examples/ folder. Each one reads your key from the PILOTERR_API_KEY environment variable.

Language X Post Info X Profile Info
cURL (Bash) post-info profile-info
PHP post-info profile-info
C# post-info profile-info
Go post-info profile-info
Java post-info profile-info
Ruby post-info profile-info
Node.js post-info profile-info

Practical use cases

  • Brand monitoring — Follow public mentions and engagement around your brand.
  • Social listening — Analyse public conversations and trends.
  • Influencer research — Qualify public creator profiles and audience metrics.
  • Ad intelligence — Study competitors' public ads and creatives.
  • Content analytics — Benchmark formats and engagement over time.

Why Piloterr?

  • No infrastructure — no proxies, headless browsers or CAPTCHA solving to run yourself.
  • Structured JSON — stable, documented fields instead of brittle HTML selectors.
  • Pay per request — transparent credit cost per endpoint, failed requests are retried for you.
  • One API key, hundreds of sources — X (Twitter) plus many other e-commerce, search and company data endpoints in the Piloterr library.
  • Any language — plain HTTPS + JSON, with examples for Python, TypeScript, cURL, PHP, C#, Go, Java, Ruby and Node.js.

FAQ

Is it legal to scrape X (Twitter)?

Collecting publicly available data is generally allowed in many jurisdictions, but rules depend on your country, the data you collect and how you use it. Avoid personal data unless you have a lawful basis, respect the website's terms where they apply, and get legal advice for your specific use case. This is not legal advice.

Do I need proxies or a headless browser?

No. Piloterr handles rendering, proxy rotation and retries on its side. You only send an HTTPS request with your x-api-key header and receive JSON.

How much does a request cost?

Credits per call: /v2/x/post/info 2, /v2/x/profile/info 2. See the Piloterr website for plans.

What data does the X (Twitter) API return?

Each endpoint returns structured JSON: X Post Info — url, name, text, media, tweet_id, username; X Profile Info — url, name, user_id, location, username, verified.

Can I get the raw HTML instead of JSON?

Yes. Set return_page_source=true and the response becomes {"result": "..."} with the page source.

Which languages are supported?

Any language that can make an HTTP request. This README shows Python and TypeScript; the examples/ folder contains cURL, PHP, C#, Go, Java, Ruby and Node.js.

Related scrapers

Support


Piloterr
Built by Piloterr — web scraping APIs for e-commerce, search, real estate and more, one API key.

X (Twitter) is a trademark of its respective owner. This repository is not affiliated with or endorsed by X (Twitter). Examples are released under the MIT license.

About

X (Twitter) Scraper API by Piloterr: x post info, x profile info data from X (Twitter) as structured JSON. Python, TypeScript, cURL, PHP, C#, Go, Java, Ruby examples.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors