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

@apitwitter/sdk

v1.0.0

Published

JavaScript/TypeScript SDK for the ApiTwitter REST API — Twitter/X data access

Readme

ApiTwitter JavaScript/TypeScript SDK

Official SDK for the ApiTwitter REST API — access Twitter/X data without the official developer portal.

Installation

npm install apitwitter

Quick Start

import { ApiTwitter } from "apitwitter";

const client = new ApiTwitter("your-api-key");

// Get user profile (uses server pool — no cookies needed)
const user = await client.getUser("elonmusk");
console.log(user.name, user.followers);

// Search tweets
const results = await client.search("javascript", "Top", 10);
results.tweets.forEach((tweet) => console.log(tweet.text));

// Get user tweets
const tweets = await client.getUserTweets("elonmusk");

Read Operations (Server Pool)

No cookies or proxy needed:

const client = new ApiTwitter("your-api-key");

// Users
const user = await client.getUser("username");
const userById = await client.getUserById("12345");
const users = await client.getUsersBatch(["id1", "id2"]);
const followers = await client.getFollowers("username", 100);
const following = await client.getFollowing("username", 100);

// Tweets
const tweets = await client.getUserTweets("username");
const tweetsById = await client.getTweets(["id1", "id2"]);

// Search (product: "Top" | "Latest" | "People" | "Photos" | "Videos")
const results = await client.search("query", "Top", 20);

Write Operations (Own Credentials)

Requires your own Twitter cookies and proxy:

const creds = {
  cookie: "ct0=...;auth_token=...",
  proxy: "http://user:pass@host:port",
};

// Tweet
await client.createTweet("Hello from ApiTwitter!", creds);

// Like / unlike
await client.like("tweet_id", creds);
await client.unlike("tweet_id", creds);

// Retweet
await client.retweet("tweet_id", creds);

// Follow / unfollow
await client.follow("user_id", creds);
await client.unfollow("user_id", creds);

// DM
await client.sendDm("user_id", "Hello!", creds);

// Bookmarks
await client.addBookmark("tweet_id", creds);
const bookmarks = await client.getBookmarks(creds);

// Timeline
const foryou = await client.getTimelineForYou(creds, 20);
const latest = await client.getTimelineLatest(creds, 20);

Pagination

let result = await client.getFollowers("username", 100);
let allFollowers = [...result.followers];

while (result.next_cursor) {
  result = await client.getFollowers("username", 100, result.next_cursor);
  allFollowers.push(...result.followers);
}

Error Handling

import {
  ApiTwitter,
  AuthenticationError,
  InsufficientCreditsError,
  RateLimitError,
  NotFoundError,
} from "apitwitter";

const client = new ApiTwitter("your-api-key");

try {
  const user = await client.getUser("username");
} catch (err) {
  if (err instanceof AuthenticationError) {
    console.log("Invalid API key");
  } else if (err instanceof InsufficientCreditsError) {
    console.log("Top up your balance");
  } else if (err instanceof RateLimitError) {
    console.log(`Rate limited, retry after ${err.retryAfter}s`);
  } else if (err instanceof NotFoundError) {
    console.log("User not found");
  }
}

Configuration

// Simple
const client = new ApiTwitter("your-api-key");

// With options
const client = new ApiTwitter({
  apiKey: "your-api-key",
  baseUrl: "https://api.apitwitter.com", // default
  timeout: 30, // seconds
});

Links