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

api-latency-monitor

v1.0.4

Published

Express middleware for monitoring API latency

Readme

API Latency Monitor 🚀

npm version license downloads

A lightweight and production-ready Express middleware for monitoring API latency, response times, slow endpoints, and backend performance in Node.js applications.


✨ Features

  • ⚡ Real-time API latency tracking
  • 🚨 Automatic slow API detection
  • 🎨 Colored terminal logs
  • 📊 Status code monitoring
  • 🪶 Lightweight middleware
  • 🔧 Configurable slow API threshold
  • 📈 Backend performance visibility
  • 🛠 Easy Express integration
  • 🚀 Zero-config setup

❓ Why API Latency Monitor?

Debugging slow APIs in production is difficult.

Traditional logging systems are often:

  • reactive instead of proactive
  • difficult to analyze
  • missing latency visibility
  • hard to monitor in real time

api-latency-monitor solves this by providing:

  • instant API response tracking
  • real-time slow endpoint detection
  • lightweight monitoring
  • clean terminal visibility
  • minimal setup

📦 Installation

npm install api-latency-monitor

🚀 Quick Start

Basic Usage

const express = require("express");
const monitor = require("api-latency-monitor");

const app = express();

app.use(
  monitor({
    slowThreshold: 1000
  })
);

app.get("/", (req, res) => {

  setTimeout(() => {
    res.send("Fast API");
  }, 300);

});

app.get("/slow", (req, res) => {

  setTimeout(() => {
    res.send("Slow API");
  }, 2000);

});

app.listen(3000, () => {
  console.log("🚀 Server running on port 3000");
});

🖥 Example Output

Fast API

[GET] / -> 200 -> 302ms

Slow API

⚠️ SLOW API [GET] /slow -> 200 -> 2010ms

⚙️ Configuration

| Option | Type | Default | Description | |---|---|---|---| | slowThreshold | number | 1000 | Time in milliseconds after which API is considered slow |


📚 API

monitor(options)

Parameters

{
  slowThreshold: number
}

Returns

Express middleware function.


🏗 How It Works

The middleware:

  1. Captures request start time
  2. Waits for response completion
  3. Calculates total response time
  4. Logs latency information
  5. Detects slow endpoints automatically

📂 Real-World Use Cases

  • Detect slow database queries
  • Monitor backend performance
  • Analyze API bottlenecks
  • Debug latency spikes
  • Monitor payment APIs
  • Improve Express application performance
  • Track slow endpoints during development

🛠 Production Ready

Designed for:

  • Express.js applications
  • Node.js APIs
  • internal services
  • microservices
  • staging environments
  • production deployments

Lightweight architecture ensures minimal runtime overhead.


📈 Future Roadmap

  • [ ] Average response time tracking
  • [ ] Request analytics dashboard
  • [ ] Error monitoring
  • [ ] File logging support
  • [ ] Live terminal dashboard
  • [ ] WebSocket monitoring
  • [ ] Grafana integration
  • [ ] Request history tracking
  • [ ] Memory usage analytics

📊 Example Monitoring Scenario

Suppose your application has multiple APIs:

/users
/login
/products
/orders
/payments

The middleware automatically tracks latency for every endpoint and highlights slow APIs instantly.

Example:

[GET] /users -> 200 -> 120ms

[POST] /login -> 200 -> 95ms

⚠️ SLOW API [GET] /payments -> 200 -> 2200ms

💡 Why Use This Package?

If you want:

  • quick API visibility
  • lightweight monitoring
  • instant latency tracking
  • backend debugging
  • slow API detection

without using expensive monitoring tools, this package provides a simple and effective solution.


🤝 Contributing

Contributions are welcome!

Feel free to:

  • open issues
  • suggest new features
  • submit pull requests

📄 License

MIT © Harsh Rana


👨‍💻 Author

Harsh Rana

  • GitHub: https://github.com/HarshRana446
  • LinkedIn: https://www.linkedin.com/in/harsh-rana-739878302

⭐ Support

If you found this package useful, consider starring the GitHub repository 🚀