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

@xegea/apimetrics-cli

v0.2.35

Published

CLI to run API load tests locally with Vegeta and upload results to Apimetrics.ai

Downloads

53

Readme

apimetrics-cli

Secure CLI to run API load tests locally with Vegeta and upload results to Apimetrics.ai.

⚙️ Installation

Step 1: Install the CLI

npm install -g @xegea/apimetrics-cli

Step 2: Restart your terminal

After installation, restart your terminal or run:

source ~/.zshrc  # (or ~/.bashrc if using bash)

Step 3: Verify installation

apimetrics --help

🧩 Quick Start

Step 4: Create a test configuration

Create a file called test.json:

{
  "target": "https://httpbin.org/get",
  "method": "GET",
  "rps": 5,
  "duration": "10s",
  "id": "my-first-test"
}

Step 5: Run your first load test

apimetrics run test.json --token YOUR_JWT_TOKEN

📋 Complete Example

# 1. Install
npm install -g @xegea/apimetrics-cli

# 2. Restart terminal
source ~/.zshrc

# 3. Verify
apimetrics --help

# 4. Create test.json
# {
#   "target": "https://your-api.com/endpoint",
#   "method": "GET",
#   "rps": 10,
#   "duration": "30s",
#   "id": "my-test"
# }

# 5. Run test
apimetrics run test.json --token YOUR_JWT_TOKEN --env dev

🧩 Test Configuration

Create a JSON file with your request configuration:

{
  "target": "https://api.example.com/users",
  "method": "GET",
  "rps": 10,
  "duration": "30s",
  "id": "demo-123"
}

Configuration fields

  • target: The API endpoint URL to test
  • method: HTTP method (GET, POST, PUT, DELETE, PATCH)
  • rps: Requests per second rate
  • duration: Test duration (e.g., "30s", "5m", "1h")
  • id: Unique identifier for this test

🚀 Usage

Basic Usage

# Run a load test and upload results (defaults to prod environment)
apimetrics run ./test.json --token YOUR_JWT_TOKEN

# Run against dev environment
apimetrics run ./test.json --token YOUR_JWT_TOKEN --env dev

# Run against local environment
apimetrics run ./test.json --token YOUR_JWT_TOKEN --env local

Alternative: Using npx

npx @xegea/apimetrics-cli run ./test.json --token=YOUR_JWT_TOKEN

Environment Configuration

The CLI automatically determines the API endpoint based on the environment:

| Environment | API URL | |-------------|---------| | prod / production (default) | https://apimetrics.onrender.com | | dev / development | https://apimetrics.onrender.com | | local | http://localhost:3000 |

You can control the environment in these ways:

  1. NODE_ENV environment variable:

    NODE_ENV=dev apimetrics run test.json --key YOUR_API_KEY
  2. --env command line flag:

    apimetrics run test.json --key YOUR_API_KEY --env dev
  3. APIMETRICS_API_URL environment variable (overrides all):

    APIMETRICS_API_URL=https://custom-api.com apimetrics run test.json --key YOUR_API_KEY
  4. --api-url command line flag (overrides all):

    apimetrics run test.json --key YOUR_API_KEY --api-url https://custom-api.com

Options

apimetrics run <definition> [options]

Options:
  -k, --key <apiKey>     API key for authentication (required)
  --api-url <url>        API endpoint URL (overrides environment-based defaults)
  --env <environment>    Environment (local, dev, prod) - overrides NODE_ENV
  -h, --help             Show help

📋 Prerequisites

  • Node.js 18+ installed
  • Vegeta installed and available in your PATH
    • Install from: https://github.com/tsenart/vegeta
    • Or via Homebrew: brew install vegeta

🔐 Security

  • ✅ Open-source and npm-published
  • ✅ Requires user API key
  • ✅ No remote code execution
  • ✅ Sends only aggregated metrics (no payloads)

🛠️ Development

# Install dependencies
npm install

# Build the project
npm run build

# Test locally
npm start run test.json --key=abc123

� Troubleshooting

Command not found after installation

If apimetrics command isn't found:

  1. Restart your terminal (close and reopen)
  2. Or reload your shell config:
    source ~/.zshrc  # (or ~/.bashrc)
  3. Check if npm bin directory is in PATH:
    npm config get prefix
    echo $PATH | grep -o '/.*/bin'

Permission issues

If you get permission errors during installation:

# Try with sudo (not recommended)
sudo npm install -g @xegea/apimetrics-cli

# Or fix npm permissions
npm config set prefix ~/.npm
export PATH="$HOME/.npm/bin:$PATH"

�📦 Publishing

The project is configured to automatically publish to npm when a GitHub release is created. See .github/workflows/publish.yml for details.

📄 License

MIT