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

apin-test

v1.0.0

Published

A lightweight CLI tool to measure API performance through sequential HTTP requests

Readme

API Latency Testing Tool

A lightweight CLI tool to measure API performance through sequential HTTP requests. Perfect for monitoring API latency, testing response times, and evaluating API performance under different conditions.

Features

  • 🚀 Fast & Lightweight: Minimal dependencies, maximum performance
  • 📊 Detailed Metrics: Average, min, max latency with performance categorization
  • 🎯 Flexible Configuration: Customizable request count, timeout, and delays
  • 💾 Persistent Logging: JSON-formatted results with session tracking
  • 🌐 Global CLI: Install once, use anywhere
  • 📈 Performance Categories: Automatic categorization (Fast/Medium/Slow)

Installation

Global Installation (Recommended)

npm install -g apin-test

After global installation, you can use apin command from anywhere:

apin "https://api.example.com/health" --count 5 --timeout 30000 --delay 300

Local Installation

npm install apin-test

Then run using npx:

npx apin "https://api.example.com/health" --count 5

Usage

Basic Usage

apin <url> [options]

Examples

# Basic test with default settings (5 requests, 30s timeout, 300ms delay)
apin "https://jsonplaceholder.typicode.com/posts/1"

# Custom configuration
apin "https://api.example.com/health" --count 10 --timeout 5000 --delay 1000

# Save results to custom location
apin "https://api.example.com/users" --count 3 --log-path ./my-results.json

# Quick test with minimal delay
apin "https://httpbin.org/get" --count 2 --delay 100

Command Line Options

| Option | Short | Description | Default | |--------|-------|-------------|---------| | --count | -c | Number of requests to perform | 5 | | --timeout | -t | Request timeout in milliseconds | 30000 | | --delay | -d | Delay between requests in milliseconds | 300 | | --log-path | -l | Path to save test results | ~/latency-test-results.json | | --version | -V | Show version number | - | | --help | -h | Show help information | - |

Performance Categories

APIN automatically categorizes response times:

  • Fast (Excellent): < 300ms ⚡
  • Medium (Acceptable/Good): 300-1000ms 🟡
  • Slow (Poor/Unacceptable): > 1000ms 🔴

Output Format

Console Output

🔧 API Latency Testing Tool v1.0.0
============================================================

🎯 Starting API latency test...
📍 Target URL: https://jsonplaceholder.typicode.com/posts/1
🔢 Number of requests: 2
⏱️  Timeout: 10000ms
⏳ Delay between requests: 1000ms
💾 Log file: /home/user/latency-test-results.json
============================================================

🚀 Request 1: Starting...
✅ Request 1: 181ms (Status: 200) - Fast (Excellent)
🚀 Request 2: Starting...
✅ Request 2: 37ms (Status: 200) - Fast (Excellent)

============================================================
📊 TEST RESULTS SUMMARY
============================================================

📋 Individual Request Results:
────────────────────────────────────────────────────────────
✅ Request 1: 181ms - SUCCESS (Fast (Excellent))
✅ Request 2: 37ms - SUCCESS (Fast (Excellent))

📈 Performance Metrics:
────────────────────────────────────────────────────────────
🎯 Total Requests: 2
✅ Successful: 2
❌ Failed: 0
📊 Success Rate: 100%
⚡ Average Latency: 109ms
🏷️ Average Category: Fast (Excellent)
🚀 Fastest Request: 37ms
🐌 Slowest Request: 181ms
============================================================

💾 Results saved to: /home/user/latency-test-results.json
🆔 Session ID: bced0e2e-253e-4de8-93ca-a520f31e2e48

JSON Log Format

[
  {
    "sessionId": "bced0e2e-253e-4de8-93ca-a520f31e2e48",
    "timestamp": "2024-01-15T10:30:45.123Z",
    "apiUrl": "https://jsonplaceholder.typicode.com/posts/1",
    "configuration": {
      "requestCount": 2,
      "timeout": 10000,
      "delayMs": 1000
    },
    "evaluationCriteria": {
      "fast": "<300ms",
      "medium": "300-1000ms",
      "slow": ">1000ms"
    },
    "results": [
      {
        "requestNumber": 1,
        "latency": 181,
        "timestamp": "2024-01-15T10:30:45.123Z",
        "statusCode": 200,
        "success": true,
        "errorMessage": null,
        "category": "Fast (Excellent)"
      }
    ],
    "summary": {
      "totalRequests": 2,
      "successfulRequests": 2,
      "failedRequests": 0,
      "averageLatency": 109,
      "minLatency": 37,
      "maxLatency": 181,
      "successRate": 100,
      "averageCategory": "Fast (Excellent)"
    }
  }
]

Exit Codes

  • 0: All requests successful
  • 1: One or more requests failed

Requirements

  • Node.js >= 18.0.0
  • Internet connection for API testing

Development

Local Development Setup

# Clone the repository
git clone https://github.com/arifintahu/api-latency-test.git
cd test-api-latency

# Install dependencies
npm install

# Test locally
node bin/apin.js "https://jsonplaceholder.typicode.com/posts/1" --count 2

# Link for global testing
npm link
apin "https://jsonplaceholder.typicode.com/posts/1" --count 2

Project Structure

├── bin/
│   └── apin.js          # CLI entry point
├── latency-test.js      # Core testing logic
├── package.json         # Package configuration
└── README.md           # Documentation

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

If you encounter any issues or have questions, please file an issue on the project repository.