# Twitter Scraper for Node.js With No Login or Cookies

> Setting SocialTap up for your user? Follow https://socialtap.dev/setup.md.

[Home](https://socialtap.dev/index.md) · [Guides](https://socialtap.dev/guides/index.md)twitter-scraper

Guide · Node.js · Updated Nov 28, 2026

The popular Node.js Twitter scrapers sign in with your X account or its cookies, and their own README warns the account can be banned. Here is X data from one request, logged out.

[Start for free](https://socialtap.dev/signup/) · [Code on GitHub](https://github.com/SocialTapDev/snscrape-alternative/tree/main/node) · [Python version](https://socialtap.dev/guides/snscrape-alternative/index.md)

The most used Twitter scraper on npm today is [@the-convocation/twitter-scraper](https://github.com/the-convocation/twitter-scraper), ahead of rettiwt-api. Both read X the way its web app does, and for most data that means a signed-in session: you log in with an X account or export its `ct0` and `auth_token` cookies. Its README is direct about the risk: "any account you log into with this library is subject to being banned at any time." Its issues show the other cost, requests that start failing with 404s ([#165](https://github.com/the-convocation/twitter-scraper/issues/165)) or Cloudflare 403s ([#158](https://github.com/the-convocation/twitter-scraper/issues/158)) until a fix ships.

This guide reads X with SocialTap from Node.js: profiles, an account's posts, a post's replies and keyword search, with no X account.

## What a scraper login looks like

JavaScript:

```js
import { Scraper } from "@the-convocation/twitter-scraper";

const scraper = new Scraper();
await scraper.login(process.env.X_USERNAME, process.env.X_PASSWORD);
for await (const tweet of scraper.getTweets("nasa", 50)) {
  console.log(tweet.text);
}
```

Each run signs in an account you own. When X challenges it, asks for a code or suspends it, the job stops.

## The same data with one API key

SocialTap reads what X shows a logged-out visitor, through its own sessions and proxies, and returns it in one schema. Install the SDK (ES modules, Node 20.3 or later):

Install:

```shell
npm install socialtap
```

Get a key on the [signup page](https://socialtap.dev/signup/) and set it as `SOCIALTAP_API_KEY`. Every account starts with 100 free credits. This reads one profile:

TypeScript SDK:

```typescript
// Save this as app.mjs (an ES module) and run: node app.mjs
import { SocialTap } from "socialtap";

const client = new SocialTap(); // apiKey defaults to process.env.SOCIALTAP_API_KEY

const res = await client.x.profile.get({ handle: "NASA" });
console.log(res.data);
console.log(res.credits.charged, res.meta.request_id);
```

## An account's posts

`scraper.getTweets(name)` becomes `client.x.posts.iterate()`, an async iterator over the account's posts, up to 100 a page, that stops at the guards you set:

TypeScript SDK:

```typescript
// Save this as app.mjs (an ES module) and run: node app.mjs
import { SocialTap, APIError, NotFoundError, PrivateOrUnavailableError } from "socialtap";

const client = new SocialTap(); // apiKey defaults to process.env.SOCIALTAP_API_KEY

try {
  // Stops at the end of the list, or at the first guard it reaches.
  const items = client.x.posts.iterate({ handle: "NASA" }, { maxPages: 10, maxCredits: 100 });
  for await (const item of items) {
    console.log(item);
  }
  console.log(items.pagesFetched, items.creditsCharged, items.stopReason, items.endReason);
} catch (err) {
  if (err instanceof NotFoundError) {
    // The item does not exist or was deleted.
    console.error(err.code, err.remediation);
  } else if (err instanceof PrivateOrUnavailableError) {
    // The item exists but isn't public: it is private, age- or region-restricted, or needs a login.
    console.error(err.code, err.remediation);
  } else if (err instanceof APIError) {
    // Retryable errors reach you only after the SDK's own retries. Failed requests cost no credits.
    console.error(err.code, err.status, err.retryable, err.remediation, err.requestId);
  } else throw err;
}
```

Each post has its full text, media, links and mentions, and its exact view, like, reply, repost, quote and bookmark counts. Logged out, X shows many organizations' timelines far back, newest first, and for most other accounts their most liked posts. `sort` picks between the two where X offers both.

## Search posts by keyword

Keyword search is `client.x.searchPosts.iterate()`. X serves no search to logged-out visitors, so this endpoint finds posts through a web search engine's index of X. It finds what the index has crawled and ends after a few pages: for one account's posts, use the posts endpoint above.

## From twitter-scraper to SocialTap

| twitter-scraper | SocialTap | Endpoint |
| --- | --- | --- |
| `scraper.getProfile(name)` | `client.x.profile.get()` | [X (Twitter) Profile API](https://socialtap.dev/apis/x/profile/index.md) |
| `scraper.getTweets(name, n)` | `client.x.posts.iterate()` | [X (Twitter) User Posts API](https://socialtap.dev/apis/x/posts/index.md) |
| `scraper.getTweet(id)` | `client.x.post.get()` | [X (Twitter) Post API](https://socialtap.dev/apis/x/post/index.md) |
| `scraper.searchTweets(query, n)` | `client.x.searchPosts.iterate()` | [X (Twitter) Post Search API](https://socialtap.dev/apis/x/search-posts/index.md) |

Replies to a post, the conversation under it, are `client.x.comments.iterate()`.

## What it costs

You pay per successful request, and a list request returns a page:

- An account's posts: $0.0075–$0.02 per 1,000 posts.
- Profiles: $0.75–$1.97 per 1,000 profiles.

Failed requests and cache hits cost nothing. The [X (Twitter) API page](https://socialtap.dev/apis/x/index.md) sets X's own per-post prices beside ours.

## Frequently asked questions

### Can I scrape Twitter without logging in?

Yes, the public part. SocialTap reads profiles, posts and the replies X shows a logged-out visitor. Scrapers on npm mostly sign in because X shows less to logged-out visitors, and that puts the account at risk.

### Will my X account get banned?

Not with SocialTap: no account of yours is used. With a library that signs in, its own README says the account "is subject to being banned at any time".

### Does it run on Vercel or Cloudflare Workers?

Yes. The SDK uses `fetch` and nothing else, so it runs in Node, Deno, Bun, Vercel functions and Cloudflare Workers, with your key kept on the server.

### How is this different from the official X API?

X's API charges for each post it returns, from prepaid credits, after you create an app. SocialTap needs an API key only, and a list request returns a page of posts for the price of one request.

## The endpoints in this guide

Each one is a single request with the same API key.

- [X (Twitter) Profile APIExact follower counts, bio and verification.$0.75–$1.97 per 1,000 profiles](https://socialtap.dev/apis/x/profile/index.md)

- [X (Twitter) User Posts APILatest or most liked posts with exact counts.$0.0075–$0.02 per 1,000 posts](https://socialtap.dev/apis/x/posts/index.md)

- [X (Twitter) Post APIFull text, media and exact view counts.$0.75–$1.97 per 1,000 posts](https://socialtap.dev/apis/x/post/index.md)

- [X (Twitter) Comments APITop replies to a post, with exact counts.$0.04–$0.10 per 1,000 comments](https://socialtap.dev/apis/x/comments/index.md)

- [X (Twitter) Post Search APIPosts by keyword, hashtag or @mention.$0.01–$0.04 per 1,000 web results](https://socialtap.dev/apis/x/search-posts/index.md)

## Replace twitter-scraper with one API key.

Get a key, run the code above and see live data in a minute. Failed requests are free.

100free credits

- No credit card
- Failed requests are free
- Works on all 310 endpoints

[Start for free](https://socialtap.dev/signup/) [Read the docs](https://socialtap.dev/docs/index.md)

---

[HTML version](https://socialtap.dev/guides/twitter-scraper-node/) · [Docs index for AI agents](https://socialtap.dev/llms.txt) · [All docs in one file](https://socialtap.dev/llms-full.txt)
