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

x-api-cli

v1.0.7

Published

Node.js CLI for posting and deleting tweets with X API v2 using OAuth 1.0a.

Readme

x-api-cli

Post and delete tweets from the terminal using the official X API v2 with OAuth 1.0a user tokens.

Commands:

  • x-post
  • x-delete

Why this CLI

  • Safe defaults: help and invalid flag paths never trigger API writes.
  • Predictable errors: strict flag parsing and strict credential validation.
  • Script friendly: stable exit codes for CI and automation.
  • Release ready: CI + semver-tagged releases + publish automation.

Install

npm (recommended)

npm install -g x-api-cli
x-post --help
x-delete --help

Homebrew (macOS/Linux)

brew tap eliaseffects/tap
brew install x-api-cli

From source (development)

git clone https://github.com/eliaseffects/x-api-cli.git
cd x-api-cli
npm install
npm link

Configure credentials

You need an X developer app with read/write access and user access tokens (OAuth 1.0a). Get them from the X Developer Portal: https://developer.x.com/en/portal/dashboard

Environment variables (recommended)

export X_API_KEY="your-consumer-key"
export X_API_SECRET="your-consumer-secret"
export X_ACCESS_TOKEN="your-access-token"
export X_ACCESS_SECRET="your-access-token-secret"

All 4 variables must be set together.

Config file

Create a JSON file with:

{
  "consumerKey": "your-consumer-key",
  "consumerSecret": "your-consumer-secret",
  "accessToken": "your-access-token",
  "accessTokenSecret": "your-access-token-secret"
}

Then use one of these options:

# Explicit path
x-post --config ./secrets/x-api.json "hello from config"

# Or env var
export X_API_CONFIG="./secrets/x-api.json"

Search order for config files:

  • --config <path>
  • $X_API_CONFIG
  • ./x-api.json
  • ./.x-api.json
  • ~/.config/x-api.json

Optional legacy support (only if you set X_API_USE_LEGACY_PATHS=1):

  • ~/.clawdbot/secrets/x-api.json

Usage

# Post
x-post "Hello world from CLI"

# Reply
x-post "Replying to this" --reply-to 1234567890

# Quote by tweet ID
x-post "Read this thread" --quote 1234567890

# Quote by URL
x-post "Read this thread" --quote-url https://x.com/user/status/1234567890

# Delete one or many
x-delete 1234567890
x-delete 1234567890 2345678901 3456789012

# Text that begins with a dash
x-post -- "--not-a-flag"

# Help
x-post --help
x-delete --help

Safety Behaviors

  • --help always exits with status 0 and no API requests.
  • Unknown flags return status 1 and clear usage guidance.
  • Missing/partial credentials fail early before API calls.
  • x-delete exits non-zero when any deletion fails.

Troubleshooting

  • No credentials found Set the env vars or create one of the supported config files.
  • 403/401 from X API Your app/tokens likely lack write permissions, are expired, or are from a different app.
  • Invalid tweet ID Tweet IDs must be numeric. Use --quote-url if you have a URL.

Development

npm test

Tests cover parsing, credential resolution, and edge cases in test/x-cli-common.test.mjs.

Security Notes

  • Do not commit credential files.
  • x-api.json and .x-api.json are ignored by default.
  • Prefer environment variables in CI.

Releasing (SemVer tags):

npm version patch
git push origin HEAD --follow-tags

GitHub Actions runs .github/workflows/release.yml and publishes to npm.

Trusted publishing:

  • Configure a trusted publisher in npm for eliaseffects/x-api-cli with workflow release.yml.
  • Set repo variable: NPM_TRUSTED_PUBLISHING=true
  • Remove NPM_TOKEN after bootstrap.

License

MIT