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

request-har

v1.0.0

Published

## Credits Inspiration and some pieces of the code comes from long forgotten repo https://github.com/paulirish/request-capture-har

Readme

request-har

Credits

Inspiration and some pieces of the code comes from long forgotten repo https://github.com/paulirish/request-capture-har

Usage

In order to use this package simply import it and then pass either request or request-promise package into the constructor, which means that it will work for both sync and async calls. In order to perform an actual request simply use the request() method and pass the request options.

Every single request is pushed into the array and can be dumped into a file in any time using save() method.

In order to clear an array use clear() method.

Example

const RequestHar = require('request-har').RequestHar
const har = new RequestHar(require('request-promise'))

let requestOptions = {
  url: 'https://jsonplaceholder.typicode.com/posts',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    foo: 'bar'
  })
}

let response = await har.request(requestOptions)

har.saveFile('./requests/json-placeholder.har')

Saving this will output as following json file which can be used to visualise

{
  "log": {
    "version": "1.2",
    "creator": {
      "name": "request-har",
      "version": "1.0.0"
    },
    "pages": [],
    "entries": [
      {
        "startedDateTime": "2019-07-31T10:43:42.981Z",
        "time": 494,
        "request": {
          "method": "POST",
          "url": "https://jsonplaceholder.typicode.com/posts",
          "httpVersion": "HTTP/1.1",
          "headers": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "content-length",
              "value": "13"
            }
          ],
          "queryString": [],
          "cookies": [],
          "headersSize": -1,
          "bodySize": -1,
          "postData": {
            "mimeType": "application/json",
            "text": "{\"foo\":\"bar\"}"
          }
        },
        "response": {
          "status": 201,
          "statusText": "Created",
          "httpVersion": "HTTP/1.1",
          "headers": [
            {
              "name": "date",
              "value": "Wed, 31 Jul 2019 10:43:43 GMT"
            },
            {
              "name": "content-type",
              "value": "application/json; charset=utf-8"
            },
            {
              "name": "content-length",
              "value": "31"
            },
            {
              "name": "connection",
              "value": "close"
            },
            {
              "name": "set-cookie",
              "value": "__cfduid=dd3eaae029b32807c478244f2c8cd997f1564569823; expires=Thu, 30-Jul-20 10:43:43 GMT; path=/; domain=.typicode.com; HttpOnly"
            },
            {
              "name": "x-powered-by",
              "value": "Express"
            },
            {
              "name": "vary",
              "value": "Origin, X-HTTP-Method-Override, Accept-Encoding"
            },
            {
              "name": "access-control-allow-credentials",
              "value": "true"
            },
            {
              "name": "cache-control",
              "value": "no-cache"
            },
            {
              "name": "pragma",
              "value": "no-cache"
            },
            {
              "name": "expires",
              "value": "-1"
            },
            {
              "name": "access-control-expose-headers",
              "value": "Location"
            },
            {
              "name": "location",
              "value": "http://jsonplaceholder.typicode.com/posts/101"
            },
            {
              "name": "x-content-type-options",
              "value": "nosniff"
            },
            {
              "name": "etag",
              "value": "W/\"1f-sBekL1M+V8GEMnkCGs539pAhjpU\""
            },
            {
              "name": "via",
              "value": "1.1 vegur"
            },
            {
              "name": "expect-ct",
              "value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
            },
            {
              "name": "server",
              "value": "cloudflare"
            },
            {
              "name": "cf-ray",
              "value": "4feef912ec859772-FRA"
            }
          ],
          "cookies": [],
          "content": {
            "size": 31,
            "mimeType": "application/json; charset=utf-8",
            "text": "{\n  \"foo\": \"bar\",\n  \"id\": 101\n}"
          },
          "redirectURL": "",
          "headersSize": -1,
          "bodySize": 31
        },
        "cache": {},
        "timings": {
          "blocked": 18.857,
          "dns": 3.105,
          "connect": 12.983,
          "send": 0,
          "wait": 457.125,
          "receive": 1.506
        }
      }
    ]
  }
}

This file can be used to visualize requests Example