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 🙏

© 2025 – Pkg Stats / Ryan Hefner

api-request-profiler

v1.0.0

Published

Lightweight API request profiler for Node.js with Express middleware, CLI tool, and real-time performance monitoring

Readme

ApiRequestProfiler 🚀

npm version License: MIT Node.js Version Downloads

📋 Table of Contents

🎯 Features

  • Real-time Performance Monitoring - Track response times, throughput, error rates
  • Payload Analysis - Monitor request/response sizes and content types
  • Endpoint Profiling - URL-based performance analysis
  • Multiple Integration Options - CLI, Express middleware, Koa middleware, standalone server
  • Historical Data - Time-based trend analysis
  • Minimal Overhead - High performance with minimal dependencies

🚀 Quick Start

CLI Usage

# Profile a single API endpoint
api-profiler --url https://api.example.com/users --method GET

# Profile with custom headers
api-profiler --url https://api.example.com/users --method POST --headers '{"Content-Type": "application/json"}' --body '{"name": "test"}'

# Continuous monitoring
api-profiler --url https://api.example.com/users --method GET --interval 5000 --duration 60000

Express Middleware

import express from 'express';
import { createExpressMiddleware } from 'api-request-profiler/middleware/express.js';

const app = express();
const profiler = createExpressMiddleware();

app.use(profiler);

app.get('/api/users', (req, res) => {
  res.json({ users: [] });
});

app.listen(3000);

Standalone Server

import { createProfilerServer } from 'api-request-profiler/server.js';

const server = createProfilerServer({
  port: 3001,
  host: 'localhost'
});

server.start();

📊 Metrics Collected

  • Response Time: Average, min, max, percentiles
  • Throughput: Requests per second
  • Error Rate: Percentage of failed requests
  • Payload Sizes: Request and response body sizes
  • Status Codes: Distribution of HTTP status codes
  • Content Types: Request and response content type analysis

🛠️ Installation

Requirements: Node.js 18.0.0 or higher

NPM

npm install api-request-profiler

Global CLI Tool

npm install -g api-request-profiler
api-profiler --url https://api.example.com/users

From Source

git clone https://github.com/erencanucarr/api-request-profiler.git
cd api-request-profiler
npm start

📈 Usage Scenarios

Development

Monitor API performance during development to catch performance issues early.

Testing

Analyze load testing results and identify bottlenecks.

Production

Track live system performance and detect performance degradation.

Debugging

Quickly identify performance issues with detailed request profiling.

🔧 Configuration

All configuration is done through environment variables or function parameters:

const profiler = createExpressMiddleware({
  enablePayloadAnalysis: true,
  enableRealTimeMetrics: true,
  retentionPeriod: 24 * 60 * 60 * 1000, // 24 hours
  maxRequests: 10000
});

🤝 Contributing

We welcome contributions! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

git clone https://github.com/erencanucarr/api-request-profiler.git
cd api-request-profiler
npm install
npm run dev

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built with Node.js built-in modules
  • Inspired by the need for simple, effective API performance monitoring
  • Thanks to all contributors and users