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

hrequests-js

v0.1.18

Published

TypeScript port of hrequests library - Full-featured HTTP client with TLS fingerprinting and browser automation

Readme

hrequests-js

TypeScript port of the hrequests Python library.

hrequests-js is a powerful HTTP client that bridges the gap between simple HTTP requests and full browser automation. It features:

  • TLS Fingerprinting: Mimic real browsers (Chrome, Firefox, etc.) to bypass anti-bot protections. Powered by a lightweight, native Go bridge.
  • Browser Automation: Seamlessly switch to headless browsers (via Playwright, Camoufox, or Patchright) for JavaScript-heavy sites.
  • Requests-like API: Familiar, ergonomic API for Python requests users.

Unlike previous versions, this is a direct port and does not require a separate Python installation or service.

Prerequisites

  • Node.js 18+
  • Go 1.21+ (Required for building the native bridge)
  • Supported Platforms:
    • macOS (x64, arm64)
    • Linux (x64, arm64, arm-7)
    • Windows (x64)

Installation

npm install hrequests-js

Quick Start

Basic Requests

import hrequests from "hrequests-js";

// Simple GET
const response = await hrequests.get("https://httpbin.org/json");
const payload = await response.json();
console.log(payload.slideshow.title);

// POST with data
await hrequests.post("https://httpbin.org/post", {
  data: { hello: "world" }
});

TLS Fingerprinting

Easily impersonate different browsers to avoid detection.

// Create a session that mimics Firefox 120
const session = new hrequests.Session({
  browser: "firefox",
  version: 120
});

const resp = await session.get("https://tls.peet.ws/api/all");
console.log(await resp.json());

Headless Browser Rendering

For pages that require JavaScript, use hrequests.render. This spins up a real browser (via Playwright) to execute scripts and retrieve the final DOM.

// Open a page in a headless browser
const session = await hrequests.render("https://example.com", {
  headless: true
});

// The content is now the fully rendered HTML
console.log(await session.text);

// Cleanup browser resources
await session.close();

How It Works

hrequests-js uses a hybrid architecture to provide the best of both worlds:

  1. TLS/HTTP Requests: For standard requests, it uses a native Go bridge (via FFI) to handle low-level TLS handshakes. This allows it to modify JA3/JA4 fingerprints and header orders to exactly match real browsers. The bridge is built locally on first run (requires Go).
  2. Browser Automation: For render requests, it uses Playwright (with patches like Camoufox/Patchright) to execute JavaScript and retrieve the final DOM.

Advanced Usage

Sessions

Sessions persist cookies and connection pools.

import { Session } from "hrequests-js";

const session = new Session({ browser: "chrome" });

await session.get("https://httpbin.org/cookies/set/session/true");
const resp = await session.get("https://httpbin.org/cookies");

console.log(resp.json()); // Includes the cookie set above

Custom TLS Configuration

You can fine-tune TLS settings if needed.

import { TLSClient } from "hrequests-js";

const client = new TLSClient({
  clientIdentifier: "chrome_120",
  randomTlsExtensionOrder: true
});

Contributing

  1. Clone the repository
  2. Install dependencies: npm install
  3. Run tests: npm test