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

twx-cli

v0.1.0

Published

A fast, lightweight CLI for the X (Twitter) API v2

Readme

twx-cli

A fast, lightweight CLI for the X (Twitter) API v2.

npx twx-cli post "Hello from the terminal!"

Features

  • Post — Create, delete, quote, reply
  • Timeline — View your recent posts
  • Search — Search recent posts
  • Users — Lookup user profiles
  • Like / Retweet / Follow — Engage with posts and users
  • Dry-run — Preview posts before sending
  • Threads — Post multi-tweet threads in one command
  • JSON output--json flag for scripting
  • Zero config — Just set 4 env vars and go

Install

npm install -g twx-cli
# or
pnpm add -g twx-cli
# or
bun add -g twx-cli

Or use directly without installing:

npx twx-cli post "Hello!"

Setup

Get your API keys from console.x.com:

twx init

This saves your credentials to ~/.config/twx-cli/config.json (mode 600).

Or create it manually:

{
  "api_key": "your_api_key",
  "api_secret": "your_api_secret",
  "access_token": "your_access_token",
  "access_token_secret": "your_access_token_secret",
  "bearer_token": "your_bearer_token"
}

Environment variables (X_API_KEY, etc.) take precedence over config file.

Make sure your app has Read and Write permissions and OAuth 1.0a enabled.

Usage

Post

# Simple post
twx post "Shipping code at 2am"

# Reply to a post
twx post "Great point!" --reply-to 1234567890

# Quote a post
twx post "This is huge 👀" --quote 1234567890

# Dry run (preview without posting)
twx post "Testing..." --dry-run

Thread

# Post a thread (each argument = one tweet)
twx thread "First tweet" "Second tweet" "Third tweet"

# Dry run
twx thread "Part 1" "Part 2" --dry-run

Timeline

# Your recent posts
twx timeline

# Last 5 posts
twx timeline -n 5

# Fetch all with pagination
twx timeline --all

# Fetch up to 50
twx timeline --max 50

Search

twx search "typescript cli"
twx search "#buildinpublic" -n 20

Users

# Your profile
twx me

# Lookup a user
twx user elonmusk

Engage

twx like 1234567890
twx retweet 1234567890
twx follow @username
twx unfollow @username

Authentication

twx-cli uses OAuth 1.0a (User Context) for most operations and optionally Bearer Token (App-only) for search.

Credentials are loaded in order:

  1. Environment variables (X_API_KEY, X_API_SECRET, etc.)
  2. ~/.config/twx-cli/config.json

Project Structure

src/
├── cli.ts              # Command definitions (commander)
├── config.ts           # Credential loading & validation
└── client/
    ├── index.ts        # XClient base (OAuth, fetch, rate limiting)
    ├── types.ts        # Shared type definitions (XPost, XUser, etc.)
    ├── posts.ts        # Post CRUD, timeline, search
    ├── users.ts        # User lookup, follow/unfollow
    └── engagement.ts   # Like, unlike, retweet

See docs/ARCHITECTURE.md for details.

Requirements

License

MIT