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

hookfreight

v0.1.2

Published

Official TypeScript SDK for Hookfreight — webhook management platform

Downloads

22

Readme

hookfreight

Official TypeScript SDK for Hookfreight — the webhook management platform.

Capture, inspect, replay, and reliably deliver webhooks with full visibility.

npm License

Installation

npm install hookfreight
yarn add hookfreight
pnpm add hookfreight

Requirements: Node.js 18+

Quick Start

Hookfreight Cloud

import Hookfreight from "hookfreight";

const hf = new Hookfreight({ apiKey: "hf_sk_..." });

// List recent deliveries
const { deliveries } = await hf.deliveries.list({ limit: 10 });

Self-Hosted

import Hookfreight from "hookfreight";

const hf = new Hookfreight({
  baseUrl: "http://localhost:3030/api/v1",
});

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | — | API key for Hookfreight Cloud. Optional for self-hosted. | | baseUrl | string | https://api.hookfreight.com/v1 | Base URL of the API. Override for self-hosted instances. | | timeout | number | 30000 | Request timeout in milliseconds. |

Usage

Apps

Apps group your webhook endpoints together.

// List all apps
const { apps, has_next } = await hf.apps.list({ limit: 10, offset: 0 });

// Create an app
const app = await hf.apps.create({
  name: "My App",
  description: "Handles Stripe webhooks",
});

// Get an app
const app = await hf.apps.get("app_...");

// Update an app
const updated = await hf.apps.update("app_...", { name: "Renamed App" });

// Delete an app (also deletes connected endpoints)
const { app: deleted, connected_endpoints } = await hf.apps.delete("app_...");

Endpoints

Endpoints receive webhooks and forward them to your services.

// List endpoints for an app
const { endpoints } = await hf.endpoints.list("app_...");

// Create an endpoint
const endpoint = await hf.endpoints.create({
  name: "Stripe Webhooks",
  app_id: "app_...",
  forward_url: "https://example.com/webhooks/stripe",
  authentication: {
    header_name: "Authorization",
    header_value: "Bearer my-secret",
  },
});

// Your webhook URL is:
// https://api.hookfreight.com/<endpoint.hook_token>

// Get an endpoint
const ep = await hf.endpoints.get("end_...");

// Update an endpoint
await hf.endpoints.update("end_...", {
  is_active: false, // pause during maintenance
});

// Delete an endpoint
await hf.endpoints.delete("end_...");

Events

Events are captured webhook requests.

// List events with filters
const { events } = await hf.events.list({
  endpoint_id: "end_...",
  method: "POST",
  start_date: "2026-01-01T00:00:00Z",
  end_date: "2026-02-01T00:00:00Z",
  limit: 50,
});

// Get a single event (includes full headers, body, etc.)
const event = await hf.events.get("evt_...");
console.log(event.body); // Original webhook payload

// List events for a specific endpoint
const { events: epEvents } = await hf.events.listByEndpoint("end_...");

// Replay an event (triggers a new delivery)
await hf.events.replay("evt_...");

Deliveries

Deliveries track forwarding attempts for each event.

// List deliveries with filters
const { deliveries } = await hf.deliveries.list({
  status: "failed",
  start_date: "2026-02-01T00:00:00Z",
  limit: 100,
});

// List deliveries for a specific event
const { deliveries: eventDeliveries } = await hf.deliveries.listByEvent("evt_...");

// Retry a failed delivery
await hf.deliveries.retry("dlv_...");

// Get queue statistics
const stats = await hf.deliveries.queueStats();
console.log(stats);
// { waiting: 0, active: 2, completed: 150, failed: 3, delayed: 0 }

Error Handling

The SDK throws typed errors for different failure modes:

import Hookfreight, {
  NotFoundError,
  ValidationError,
  AuthenticationError,
  ConnectionError,
} from "hookfreight";

try {
  await hf.apps.get("app_nonexistent");
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log("App not found");
  } else if (error instanceof ValidationError) {
    console.log("Validation errors:", error.errors);
  } else if (error instanceof AuthenticationError) {
    console.log("Invalid API key");
  } else if (error instanceof ConnectionError) {
    console.log("Network error:", error.message);
  }
}

| Error Class | HTTP Status | When | |-------------|-------------|------| | ValidationError | 400 | Invalid request parameters | | AuthenticationError | 401 | Missing or invalid API key | | PermissionError | 403 | Insufficient permissions | | NotFoundError | 404 | Resource doesn't exist | | APIError | Other | Any other API error | | ConnectionError | — | Network failures, timeouts |

All errors extend HookfreightError, so you can catch all SDK errors with a single type:

import { HookfreightError } from "hookfreight";

try {
  await hf.apps.list();
} catch (error) {
  if (error instanceof HookfreightError) {
    // Any SDK error
  }
}

CommonJS

The SDK supports both ESM and CommonJS:

const { Hookfreight } = require("hookfreight");

const hf = new Hookfreight({ apiKey: "hf_sk_..." });

Examples

See the examples/ directory for runnable scripts:

Run any example with:

HOOKFREIGHT_API_KEY=hf_sk_... npx tsx examples/basic-usage.ts

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

git clone https://github.com/Hookfreight/hookfreight-ts.git
cd hookfreight-ts
npm install
npm run build
npm run typecheck

License

Apache-2.0