npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fetchlayer/twitter

v0.1.0

Published

Official FetchLayer SDK for X/Twitter data. Search tweets, get profiles, pull followers, and scrape replies with JavaScript and TypeScript.

Downloads

45

Readme

Twitter/X Scraper & API Client for JavaScript / TypeScript

npm license types

The official JavaScript & TypeScript SDK for the FetchLayer Twitter/X API.

Search tweets. Get profiles. Pull followers and following lists. Fetch replies. All as clean JSON from a single API — no scraping infrastructure, no proxies, no X developer account.

Open-source SDK, hosted API. This package is MIT-licensed. The API requires a free FetchLayer API key — no subscriptions, no contracts, no lock-in. Pay only for what you use.


Install

npm install @fetchlayer/twitter
pnpm add @fetchlayer/twitter
yarn add @fetchlayer/twitter

Get your API key

  1. Go to fetchlayer.dev
  2. Sign in with your email
  3. Copy your API key from the dashboard

That's it. No credit card. No trial expiration. You get free requests to start, then pay-as-you-go when you need more.

Quick start

import { FetchLayerTwitter } from "@fetchlayer/twitter";

const twitter = new FetchLayerTwitter({
  apiKey: process.env.FETCHLAYER_API_KEY!,
});

// Search Twitter/X for tweets about any topic
const results = await twitter.search({
  query: "best CRM tools",
  product: "Top",
  count: 10,
});

console.log(results);

That's 4 lines to get structured Twitter/X data. No OAuth, no rate-limit wrestling, no $100/month X API bill.


Why use this instead of X's official API

| Problem | FetchLayer | | --- | --- | | X API costs $100/mo (Basic) or $5K/mo (Pro) | Free tier + pay-per-use | | Complex OAuth setup (4 keys to manage) | Single API key | | Aggressive rate limits (1 req/15s on some endpoints) | No rate limits | | Follower graph requires Pro tier ($5K/mo) | Followers, following, verified followers included | | Maintaining scraping infra is a full-time job | npm install and done | | You need tweets, profiles, AND followers | 10 endpoints, one SDK |


All methods

const twitter = new FetchLayerTwitter({ apiKey });

| Method | What it does | | --- | --- | | twitter.search(params) | Search tweets by keyword (Top, Latest, People, Media, Lists) | | twitter.getTweetDetail(params) | Get a specific tweet by ID | | twitter.getTweetReplies(params) | Fetch replies to a tweet | | twitter.getUserProfile(params) | Get user profile, bio, follower count | | twitter.getAboutProfile(params) | Get extended profile metadata (category, business type) | | twitter.getUserTweets(params) | Get recent tweets from a user | | twitter.getUserReplies(params) | Get recent replies from a user | | twitter.getFollowers(params) | Get accounts following a user | | twitter.getFollowing(params) | Get accounts a user follows | | twitter.getVerifiedFollowers(params) | Get verified accounts following a user |


Examples

Search tweets

const results = await twitter.search({
  query: "react server components",
  product: "Latest",
  count: 25,
});

for (const tweet of results.results ?? []) {
  console.log(`@${tweet.author?.handle}: ${tweet.text?.slice(0, 100)}`);
  console.log(`  ${tweet.likeCount} likes · ${tweet.retweetCount} retweets`);
}

Get a user profile

const profile = await twitter.getUserProfile({ handle: "openai" });

console.log(`${profile.displayName} (@${profile.handle})`);
console.log(`Followers: ${profile.followersCount?.toLocaleString()}`);
console.log(`Bio: ${profile.description}`);

Get followers

const followers = await twitter.getFollowers({
  handle: "openai",
  count: 50,
});

for (const account of followers.accounts ?? []) {
  console.log(`@${account.handle} — ${account.followersCount?.toLocaleString()} followers`);
}

Get verified followers

const verified = await twitter.getVerifiedFollowers({
  handle: "levelsio",
  count: 100,
});

console.log(`${verified.accounts?.length ?? 0} verified followers`);

Paginate through results

// Search with pagination
const page1 = await twitter.search({ query: "AI", product: "Latest", count: 50 });

if (page1.cursor) {
  const page2 = await twitter.search({
    query: "AI",
    product: "Latest",
    count: 50,
    cursor: page1.cursor,
  });
}

// Followers pagination works the same way
let cursor: string | undefined;
do {
  const page = await twitter.getFollowers({
    handle: "openai",
    count: 100,
    ...(cursor ? { cursor } : {}),
  });
  cursor = page.cursor;
  // Process page.accounts...
} while (cursor);

TypeScript

All response types are exported. Import them for full type safety:

import type { SearchResponse, Tweet, UserProfile, FollowersResponse } from "@fetchlayer/twitter";

const data: SearchResponse = await twitter.search({ query: "typescript" });

// Fully typed — no `any` anywhere
for (const tweet of data.results ?? []) {
  console.log(tweet.author?.handle); // string | undefined
  console.log(tweet.likeCount);      // number | undefined
}

API Reference

See the FetchLayer Twitter/X API docs for full endpoint reference, parameter details, and response schemas.


License

MIT © 2026 HootCodes LTD