   [Home](https://scrapfly.io/)/[Scrapers](https://scrapfly.io/scrapers)/**X (Twitter)** 

Public profiles · posts · engagement counts

# // X (Twitter) Scraper API

Turn a public X post or profile URL into clean JSON: post text, author, publish time and the exact reply, repost, like and bookmark counts, or a profile's bio, location, join date, followers and latest posts. With JavaScript rendering on, Scrapfly loads the page in a cloud browser, so you send the URL and read the data.

- **Clone it and run it.** An open-source X (Twitter) scraper that returns a post's text, date, images, counts and author, and a profile's bio, location, join date and follower counts, tested against live X every night.
- **Exact counts, not 324K.** The buttons under a post show rounded numbers. Their labels carry the exact count, and the Python example reads it.
 
 [Get free API key](https://scrapfly.io/register) [View GitHub scraper](https://github.com/scrapfly/scrapfly-scrapers/tree/main/twitter-scraper) [Read the API docs](https://scrapfly.io/docs/scrape-api/getting-started) 

1,000 free credits. No credit card required.

 [  ](https://scrapeway.com/web-scraping-api/scrapfly) [  ](https://www.capterra.com/p/212653/Scrapfly/reviews/)  

 4.8/5 from 248 reviews 

 

 

 

 

 X (Twitter) pages · illustration

  

 

 Post JSON**Output**

```
{
  <span class="c-str">"id"</span>: <span class="c-str">"20"</span>,
  <span class="c-str">"author"</span>: <span class="c-str">"jack"</span>,
  <span class="c-str">"handle"</span>: <span class="c-str">"jack"</span>,
  <span class="c-str">"posted"</span>: <span class="c-str">"2006-03-21T20:50:14Z"</span>,
  <span class="c-str">"replies"</span>: <span class="c-num">19258</span>,
  <span class="c-str">"reposts"</span>: <span class="c-num">134375</span>,
  <span class="c-str">"likes"</span>: <span class="c-num">324463</span>,
  <span class="c-str">"bookmarks"</span>: <span class="c-num">25509</span>,
  <span class="c-str">"text"</span>: <span class="c-str">"just setting up my twttr"</span>
}
```

Printed by the Python request below[See the request ↓](#implementation)

   

  

What you can scrape from X (Twitter)

Four kinds of X (Twitter) data you can scrape with Scrapfly, all from public post and profile pages.

 

## // Scrape X (Twitter) posts

Send a public post URL such as `x.com/jack/status/20` and get the post text, the author's name and handle, the publish time, attached image URLs and the reply, repost, like and bookmark counts.

- text
- author
- handle
- posted
- images
- replies
- reposts
- likes
- bookmarks

  

## // Scrape X (Twitter) profiles

A public profile page carries the display name, handle, bio, location, website link, join date, profile and banner images, the verified badge, and the follower, following and post counts as X shows them (rounded, such as 92.1M).

- name
- handle
- bio
- location
- joined
- followers
- following
- posts
- verified

  

## // Collect the latest posts on a profile

A public profile also shows its most recent posts, each with its link, text and counts. Collect the post URLs from it and scrape each post for the full details.

- post\_url
- text
- replies
- reposts
- likes

  

## // Read the first replies under a post

The rendered post page includes the first replies shown under it, each with the reply author, text and counts, next to the post itself. The open-source scraper does not parse them.

- reply\_author
- reply\_text
- reply\_url
- replies
- reposts
- likes

  

 

  

Reliability

## // Get rendered X pages with exact counts

X is a JavaScript app. Scrapfly renders each post or profile URL in a cloud browser and returns the finished HTML, with the post, its counts and the first replies in place.

 `render_js=true`

Render the page so the post, the profile and the counts are in the HTML you parse. On datacenter proxies a rendered page costs 6 credits.

 

 `aria-label`

The like button under the first tweet shows 324K. On November 24 its label read 324463 Likes. Read the label and you store the exact number.

 

 `public pages`

Requests cover posts and profiles that load for anyone. Protected accounts and content that isn't public are out of scope.

 

 

 

  

Choose your tools

## // Scrapfly products for X (Twitter) scraping

Start with the Web Scraping API and JavaScript rendering. Add the extraction model, screenshots or a browser session as your workflow needs them, or start from the open-source scraper. One API key covers every product.

 

### Web Scraping API for X (Twitter) pages

Send a public post or profile URL with JavaScript rendering on and get the rendered page back as HTML.

Parse the post, its counts or the profile from it. Datacenter proxies are the low-cost starting point at 6 credits per rendered page.

```
GET /scrape?url=https://x.com/NASA&render_js=true&rendering_wait=2000&country=US
```

 [Explore Web Scraping API →](https://scrapfly.io/products/web-scraping-api)  

### Data Extraction API for X (Twitter) posts

Set `extraction_model` to `social_media_post` to get a post page as structured JSON, with no parser to write.

Get the post text, post ID and link, and the author's name, username and profile link.

```
GET /scrape?url=https://x.com/jack/status/20&render_js=true&rendering_wait=2000&country=US&extraction_model=social_media_post
```

 [Explore Data Extraction API →](https://scrapfly.io/products/extraction-api)  

### Screenshot API for X (Twitter) posts

Capture a post as an image: the post with its counts and the first replies under it, as the page shows them.

Keep a dated visual record of a post next to your JSON.

```
GET /screenshot?url=https://x.com/jack/status/20&country=US&rendering_wait=2000
```

 [Explore Screenshot API →](https://scrapfly.io/products/screenshot-api)  

### Cloud Browser API for X (Twitter) sessions

Connect Playwright or Puppeteer to a hosted Chromium in the country you choose.

Open a public profile or post from your own script, read the rendered page and take your own screenshots.

```
chromium.connect_over_cdp("wss://browser.scrapfly.io?key=KEY&country=us&proxy_pool=datacenter")
```

 [Explore Cloud Browser API →](https://scrapfly.io/products/cloud-browser-api)  

### Open-source X (Twitter) scraper on GitHub

Clone the maintained Python scraper for public posts and profiles.

It runs on the Web Scraping API, returns a post's text, date, images, counts and author, and a profile's bio, location, join date and follower counts, and is tested against live X every night.

- scrape\_tweet
- scrape\_profile

 [View the scraper on GitHub →](https://github.com/scrapfly/scrapfly-scrapers/tree/main/twitter-scraper)  

 

  

One request

## // Scrape an X (Twitter) post in Python

The JSON at the top is sample output from November 24, 2026, for the first tweet, posted by jack in March 2006: one rendered request through a US datacenter IP, the text and author read from the page's meta tags, and the exact counts read from the button labels.

Install `scrapfly-sdk` and `parsel`, then replace the key below. Swap `POST_URL` for another public post. The counts come from the first post on the page, so for a reply in a thread, match the post by its status link first.

**Prefer the full scraper?** The open-source [X (Twitter) scraper on GitHub](https://github.com/scrapfly/scrapfly-scrapers/tree/main/twitter-scraper) scrapes a post's text, date, images, counts and author, and a profile's bio, location, join date and follower counts, in Python 3.12. It runs against live X every night. Clone it, set `SCRAPFLY_KEY`, and point it at your own URLs.

 

 Python · scrapfly-sdkscrape + parse

```
<span class="c-key">import</span> json
<span class="c-key">import</span> re
<span class="c-key">from</span> scrapfly <span class="c-key">import</span> ScrapeConfig, ScrapflyClient

POST_URL = <span class="c-str">"https://x.com/jack/status/20"</span>
client = ScrapflyClient(key=<span class="c-str">"YOUR_SCRAPFLY_KEY"</span>)
result = client.scrape(ScrapeConfig(
    POST_URL,
    render_js=<span class="c-key">True</span>, rendering_wait=<span class="c-num">2000</span>,
    country=<span class="c-str">"US"</span>,
))
sel = result.selector

<span class="c-key">def</span> meta(prop):
    css = f"meta[property='{prop}']::attr(content)"
    <span class="c-key">return</span> sel.css(css).get()

<span class="c-key">def</span> count(action):
    <span class="c-com"># exact numbers sit in the buttons' aria-labels</span>
    box = sel.css(f"[data-engagement-action='{action}']")
    label = box.css(<span class="c-str">"[aria-label]::attr(aria-label)"</span>).get()
    match = re.match(<span class="c-str">r"(\d+)"</span>, label <span class="c-key">or</span> <span class="c-str">""</span>)
    <span class="c-key">return</span> int(match.group(<span class="c-num">1</span>)) <span class="c-key">if</span> match <span class="c-key">else</span> <span class="c-num">0</span>

title = meta(<span class="c-str">"og:title"</span>)  <span class="c-com"># "jack (@jack) on X"</span>
<span class="c-key">if</span> <span class="c-key">not</span> title:
    <span class="c-key">raise</span> RuntimeError(<span class="c-str">"No post data in the response"</span>)
match = re.match(<span class="c-str">r"(.*) \(@(\w+)\)"</span>, title)
author, handle = match.groups()
output = {
    <span class="c-str">"id"</span>: POST_URL.rsplit(<span class="c-str">"/"</span>, <span class="c-num">1</span>)[<span class="c-num">1</span>],
    <span class="c-str">"author"</span>: author,
    <span class="c-str">"handle"</span>: handle,
    <span class="c-str">"posted"</span>: meta(<span class="c-str">"article:published_time"</span>)[:<span class="c-num">19</span>] + <span class="c-str">"Z"</span>,
    <span class="c-str">"replies"</span>: count(<span class="c-str">"reply"</span>),
    <span class="c-str">"reposts"</span>: count(<span class="c-str">"retweet"</span>),
    <span class="c-str">"likes"</span>: count(<span class="c-str">"like"</span>),
    <span class="c-str">"bookmarks"</span>: count(<span class="c-str">"bookmark"</span>),
    <span class="c-str">"text"</span>: meta(<span class="c-str">"og:description"</span>),
}
print(json.dumps(output, indent=<span class="c-num">2</span>, ensure_ascii=<span class="c-key">False</span>))
```

 

 

 

  

What the data is used for

## // Common X (Twitter) scraping use cases

### Brand monitoring

Track replies, reposts and likes on your own posts and on the posts that mention your brand.

 

### Competitor tracking

Follow the follower counts and latest posts of competitor accounts week by week.

 

### Creator vetting

Check an account's bio, join date, follower count and recent engagement before a partnership.

 

### Campaign reporting

Record the counts on campaign posts over time instead of copying them by hand.

 

### Research datasets

Collect public posts and their engagement for a study with a defined scope.

 

### Post data for AI agents

Give an agent the current text and counts of a post when it answers questions about it.

 

 

 

  

Common questions

## // X (Twitter) scraping FAQ

 Is scraping X (Twitter) legal?

There is no universal answer. Legality depends on your jurisdiction, the data, the access method and how you use the result. Keep the workflow to public posts and profiles, review X's terms of service and privacy rules such as GDPR (handles, bios and post text are personal data), and get legal advice for commercial use.

 How is this different from the official X API?

The X API is X's official, paid API, with a developer account, keys and its own access tiers. These requests read the public X pages a visitor sees, so you need a Scrapfly API key instead, and you get the fields shown on the page.

 What X data can I scrape?

Public posts and profiles: post text, author, publish time, images, reply, repost, like and bookmark counts and the first replies the rendered page shows (the open-source scraper does not parse them), plus a profile's bio, location, website, join date, follower and following counts and latest posts. Protected accounts and content that isn't public are out of scope.

 Can I get exact like and repost counts?

Yes. The buttons under a post show rounded numbers such as 324K, and each button's label holds the exact count. The Python example reads the label. The open-source scraper returns the rounded numbers as X displays them.

 How do I scrape many posts from one account?

A public profile shows its most recent posts with their links. Collect the post URLs you need from the profile, then scrape each post URL for its text and counts.

 Do I need JavaScript rendering for X?

Rendering is the reliable default, and the open-source scraper uses it. Public post and profile pages currently carry the same data without rendering too, at 1 credit instead of 6. Check your parser against both before you switch.

 How much does scraping X (Twitter) cost?

A rendered X page costs 6 credits on datacenter proxies, or 1 credit without rendering. Residential proxies with rendering cost 30 credits a page. The social\_media\_post extraction model adds 5 credits, and a Screenshot API capture of a post costs 60. The free plan includes 1,000 credits a month.

 What are the rate limits when scraping X (Twitter)?

Scrapfly sets no X-specific limit. Your maximum parallelism is the concurrency quota on your plan, or a lower cap configured for the project. Each in-flight request uses one slot until it finishes.

 

 

  

Start with one request

## Send the URL. Read the post.

Web Scraping API with JavaScript rendering, one call per public X (Twitter) post or profile URL.

Proxies across 75+ countries

[X (Twitter) scraper on GitHub](https://github.com/scrapfly/scrapfly-scrapers/tree/main/twitter-scraper)[How to scrape X (Twitter)](https://scrapfly.io/blog/posts/how-to-scrape-twitter)[All scraper pages](https://scrapfly.io/scrapers)

 

[Get free API key](https://scrapfly.io/register)[Read the docs](https://scrapfly.io/docs/scrape-api/getting-started)