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.
npm install @fetchlayer/twitterpnpm add @fetchlayer/twitteryarn add @fetchlayer/twitter- Go to fetchlayer.dev
- Sign in with your email
- 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.
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.
| 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 |
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 |
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`);
}const profile = await twitter.getUserProfile({ handle: "openai" });
console.log(`${profile.displayName} (@${profile.handle})`);
console.log(`Followers: ${profile.followersCount?.toLocaleString()}`);
console.log(`Bio: ${profile.description}`);const followers = await twitter.getFollowers({
handle: "openai",
count: 50,
});
for (const account of followers.accounts ?? []) {
console.log(`@${account.handle} — ${account.followersCount?.toLocaleString()} followers`);
}const verified = await twitter.getVerifiedFollowers({
handle: "levelsio",
count: 100,
});
console.log(`${verified.accounts?.length ?? 0} verified followers`);// 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);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
}See the FetchLayer Twitter/X API docs for full endpoint reference, parameter details, and response schemas.
MIT © 2026 HootCodes LTD