Blog / API guides

Twitter Scraper or X API: Options for Public Data

A Twitter scraper is a script that loads X in a browser, or replays the requests its web app makes, and reads tweets, threads and trends out of the result. It needs constant repair and runs into whatever limits X puts on automated traffic. You have two other routes: X's own developer API, on X's terms and prices, and 20 X endpoints that return public tweets, threads and trends as JSON at 1 credit a successful call, under restricted-endpoint terms. This post compares the three and gives a verdict per use case.

What does building a Twitter scraper involve?

Building a Twitter scraper means automating a web app that was built for people, not scripts. You either drive a headless browser through X, wait for tweets to render and parse them out of the page, or you capture the requests the web app makes and replay them yourself. The second is faster, but it ties your code to internal request formats, tokens and sessions that you don't control and that can change at any time.

The upkeep is the real cost. Markup and request formats change without notice, so a scraper that worked last month can return nothing today. Much of what you'd want to read may only appear after a login, and logged-in scraping puts an account at risk as well as the project. Large sites limit automated traffic, so at any volume you can expect blocks and challenge pages. When that happens, stop: rotating accounts, proxies or CAPTCHA solvers to get around a site's protections is not a fix we'd recommend.

Then read the rules. X's own terms of service and developer terms are where X sets out what it allows for automated access and reuse of its content. Read them before you build anything that collects X data, and get legal advice if the project is commercial.

What about X's own developer API?

X's developer API is the official way to read and write X data, and for an app that posts, replies or acts on behalf of an X account, it's the route to take. You get X's documented objects, X's authentication, and X's rules about what you may store and display. Those rules, along with the access levels, request limits and prices, are set by X and change over time.

This post doesn't quote X's tiers or prices. We couldn't verify the current figures on X's developer pages for this article, and a figure we can't check isn't worth printing. Read them on X's developer site, note the date you read them, and compare them with your call volume before you decide. If the official API covers the data you need at a cost that fits, use it.

What do the X endpoints return?

The X API at /apis/x returns public X data as JSON, one call per lookup. It has 20 endpoints, all GET, all 1 credit per successful call: tweets, their text, media, video and transcripts, threads, conversations, quotes and reposts, trends, search typeahead, notes, public communities and their posts, and profiles with their posts, media and articles. Data is collected from publicly available sources and returned as found at the time of the call.

Endpoint Returns Required Optional
/v1/x/tweet One tweet id none
/v1/x/tweet-text A tweet's text id none
/v1/x/tweet-thread A tweet's thread id none
/v1/x/tweet-conversation A tweet's conversation id count, cursor, ranking_mode, about_account, lang
/v1/x/tweet-quotes A tweet's quotes id count, cursor
/v1/x/tweet-transcript A tweet's transcript id none
/v1/x/trends Trends none type, count
/v1/x/search-typeahead Search typeahead q result_type
/v1/x/notes Notes id none
/v1/x/user-tweets An account's tweets handle count, cursor, with_replies, groupthreads, since

The API page lists all 20 with their parameters. A trends call needs nothing but your key in the X-API-Key header:

curl "https://api.perceptlayer.com/v1/x/trends" \
  -H "X-API-Key: $API_KEY"

A thread is one call with the tweet's id:

curl "https://api.perceptlayer.com/v1/x/tweet-thread?id=$TWEET_ID" \
  -H "X-API-Key: $API_KEY"

We don't have a recorded response for this API, so this post doesn't show one. Run the calls in the playground on the X API page to see the exact fields before you write a parser; the trends endpoint page links to it.

Which parameters do the endpoints take?

Tweet endpoints take a string id. user-tweets takes a handle and optional count (an integer), cursor (up to 200 characters), with_replies and groupthreads (booleans) and since (up to 40 characters). search-typeahead takes a q of up to 512 characters and an optional result_type. tweet-conversation adds ranking_mode, about_account and lang (up to 10 characters). The reference doesn't document defaults, page sizes or allowed values for these strings, so test them in the playground before you depend on them.

Which terms apply to the restricted endpoints?

All 20 X endpoints are restricted, and the restricted-endpoint terms at /legal/restricted-endpoints apply to them. They work once you accept those terms in the dashboard. The terms don't permit collecting personal data without a lawful basis, and they don't permit using data from these endpoints to contact people. That rules out lead lists, outreach and follower harvesting, whichever route you collect the data through.

What fits is work on brands, public posts and topics in aggregate. Follow which topics trend. Archive the threads a company publishes about its product. Measure how a public announcement was received across its replies and quotes, without keeping who said what. When a response includes names, handles or profile details you don't need, drop them before you store anything. The errors list includes restricted_endpoint (403); the errors docs cover it with the other codes.

How do the three routes compare?

The three routes trade control, permission and upkeep differently. A scraper gives you control and no per-call bill, and costs you repairs, blocks and terms risk. X's API gives you X's permission and documented objects, on X's prices and limits. The X endpoints give you JSON from stable paths for 1 credit a successful call, under the restricted-endpoint terms.

DIY scraper X's developer API X endpoints
Setup Headless browser or replayed requests, sessions, parsers X's developer sign-up, per X's docs API key in the X-API-Key header
What you get Whatever you parse from the page X's documented objects JSON from 20 documented endpoints
Threads and replies Parsed per page Per X's documentation tweet-thread, tweet-conversation, tweet-quotes by id
Trends Parsed from the page Per X's documentation trends with optional type and count
Maintenance High: pages and requests change Low Low: you maintain only your own code
Speed One browser or session per job X's request limits 1 request a second free, at least 5 a second on paid packs
Terms X's terms of service X's developer terms Restricted-endpoint terms; no personal data without a lawful basis
Cost Hosting and engineering time X's published prices 1 credit per successful call; failed calls cost 0

What does a brand monitor cost?

On the X endpoints, cost follows calls. A brand team that checks trends 5 times a day makes 5 × 30 = 150 calls a month. Adding one user-tweets call a day for each of 10 brand accounts in its category is 10 × 30 = 300 more. That's 450 credits a month, or 15 a day, so the 100 free credits every account gets once after verifying an email address, with no credit card, cover the first 6 days.

Now add reception analysis: for 60 announcements a month, one tweet-conversation call and one tweet-quotes call each is 60 × 2 = 120 credits, bringing the month to 570. If you fetch further pages with cursor, each one is another credit. After the free credits, the Starter pack's 10,000 covers a year of this monitor, and purchased credits last 12 months. See pricing for what credits cost, and the credits docs for how billing works.

Which route should you choose?

Choose by what you'll do with the data, because that decides whose terms apply and what you maintain. The verdicts below assume brand, topic or aggregate work. If your plan involves contacting people or building lists of individuals, none of these routes is the answer.

  • An app that posts, replies or acts for an X account: use X's developer API. None of the endpoints here post or reply, so the official API is the route for that.
  • Trend and topic monitoring: use trends on a schedule, and search-typeahead with a q to see which terms and topics come up for a keyword.
  • Tracking what brands publish: use user-tweets with each brand's handle, and tweet-thread to keep long announcements whole. Store tweet text and counts, not follower details.
  • How a public announcement landed: use tweet-conversation and tweet-quotes with the announcement's id, and score the replies in aggregate. Drop authors' identities before you store the text.
  • Video content analysis: use tweet-transcript with the tweet's id to work with a transcript instead of the video.
  • A one-off question from an AI agent: connect the MCP server at https://perceptlayer.com/mcp; search_endpoints and get_endpoint are free and call_endpoint spends credits only on success. The AI agents docs cover setup.

For the same trade-off on other sites, read YouTube Data API Quota: Limits, Costs and Alternatives and TikTok API: Official Options and Public Trend Data, or browse the social media APIs. To check the fields first, run trends in the playground on the X API page, then get a free API key when they fit.

APIs in this post

Frequently asked questions

It depends on your jurisdiction, what you collect and how you use it, and X's own terms set out what X allows for automated access. Public posts about brands and topics are lower risk than data about individuals, which is personal data in many places. Read X's terms, get legal advice for commercial use, and don't get around logins, blocks or challenges.

How much does the official X API cost?

X sets its own access levels, limits and prices, and they change, so read them on X's developer pages and note the date. This post doesn't quote them because we couldn't verify the current figures. The X endpoints described here cost 1 credit per successful call, and pricing shows what credits cost.

Can I collect followers or contact people from X data?

No. The restricted-endpoint terms don't permit collecting personal data without a lawful basis or using data from these endpoints to contact people, so lead generation, outreach and follower harvesting are out. Use the X endpoints for brands, public posts and topics in aggregate, and drop names and handles you don't need before storing results.

Does a failed X call cost credits?

No. Only a successful response debits credits. A failed call returns an HTTP status, a JSON error with a code, message and request_id, and X-Credits-Used: 0. A rate-limited call returns 429 with a Retry-After header. The rate limits docs cover the per-account limits and the RateLimit-Remaining header.

Can I see an X response before writing code?

Yes. The X API page has a playground: pick an endpoint such as trends or tweet-thread, fill in its parameters and run a real call with your key to see the JSON. Do this before you write a parser, since this post doesn't include a recorded response.

  1. TikTok Scraper or API: Hashtag, Sound and Trend Data

    A TikTok scraper next to 31 TikTok endpoints at 1 credit a call: trending hashtags by country, hashtag and sound posts, and 2 credits per hashtag tracked a day.

  2. Pinterest Scraper or API: What You Get

    A DIY Pinterest scraper versus 6 Pinterest endpoints at 1 credit a call: pin search, board pins, upkeep, terms and the credits per search term tracked.

  3. Telegram Scraper or API: What You Get

    A DIY Telegram scraper versus 4 Telegram channel endpoints at 1 credit a call: channel posts, in-channel search, upkeep, terms and cost per channel.

Start with 100 free credits

No password to set. We email you a sign-in link, and your key works on every API.

No credit card. 100 free credits on signup.