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

lite-request

v1.0.2

Published

A minimal HTTP client for Node.js.

Readme

lite-request

A minimal HTTP client for Node.js.

  • Only ~150 lines of code, 0 dependencies
  • Built‑in retry and 3xx redirect following
  • Automatic gzip / deflate / brotli decompression
  • Custom agent support (e.g. SocksProxyAgent, HttpsProxyAgent, etc.)
  • Pure Promise API that returns a native Node IncomingMessage with response.data attached

Install

$ npm i lite-request --save

Basic usage

request is both a function and an object with .get/.post/... shortcuts.

import request from 'lite-request'

;(async () => {
  console.log((await request.get('https://myip.hoa-js.com', { json: true })).data)
  console.log((await request.get({ url: 'https://myip.hoa-js.com', json: true })).data)
  console.log((await request('https://myip.hoa-js.com', { json: true })).data)
  console.log((await request({ url: 'https://myip.hoa-js.com', json: true })).data)

  // JSON body
  const jsonRes = await request({
    method: 'POST',
    url: 'https://httpbin.org/post',
    headers: { 'x-custom-header': 'haha' },
    body: { foo: 'bar' },
    json: true
  })
  console.log(jsonRes.data)

  // x-www-form-urlencoded body
  const formRes = await request.post('https://httpbin.org/post', {
    headers: { 'x-custom-header': 'haha' },
    form: { foo: 'bar' },
    json: true
  })
  console.log(formRes.data)
})()

Redirects & Retry

Default behaviour:

  • maxRedirects: 10:
    • Automatically follows 3xx responses with a Location header.
    • Supports relative redirects, and drops cookie / authorization on cross‑host redirects to avoid leaking secrets.
  • maxRetry: 1:
    • Automatically retries for:
      • Certain status codes: 408 / 429 / 502 / 503 / 504 / 521 / 522 / 524.
      • Common network errors: ETIMEDOUT / ECONNRESET / EADDRINUSE / ECONNREFUSED / EPIPE / ENOTFOUND / ENETUNREACH / EAI_AGAIN, etc.

You can tune this behaviour via:

  • retryOnCode: number[]
  • retryOnError: string[]
  • retryDelay: number (milliseconds)
  • maxRetry: number
  • maxRedirects: number

Automatic decompression

By default, requests send:

  • accept-encoding: gzip, deflate, br

Responses are automatically decompressed based on content-encoding:

  • brzlib.createBrotliDecompress()
  • gzip / deflatezlib.createUnzip()
  • anything else → read the raw body as‑is

The decompressed body is collected and exposed as response.data.

Using a custom agent (proxy)

You can plug in any http.request‑compatible agent, for example a SocksProxyAgent:

import request from 'lite-request'
import { SocksProxyAgent } from 'socks-proxy-agent'

const agent = new SocksProxyAgent('socks://admin:[email protected]:5000')

;(async () => {
  console.log((await request.get('https://myip.hoa-js.com', { json: true, agent })).data)
  console.log((await request.get({ url: 'https://myip.hoa-js.com', json: true, agent })).data)
  console.log((await request('https://myip.hoa-js.com', { json: true, agent })).data)
  console.log((await request({ url: 'https://myip.hoa-js.com', json: true, agent })).data)
})()
  • Without an explicit agent: lite-request chooses an internal keep‑alive agent based on the protocol (http or https).
  • With an explicit agent: your agent is used as‑is and will not be overridden.

Configuring defaults

If you need multiple clients or shared defaults, use the named Request factory:

import request, { Request } from 'lite-request'

const api = Request({
  headers: { 'user-agent': 'my-client' },
  maxRetry: 3
})

const res = await api.get('https://example.com', { json: true })
console.log(res.data)

The default export request is equivalent to Request() called once with no arguments.

Test (100% coverage)

$ npm test

License

MIT