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

@hogsend/client

v0.22.0

Published

Typed HTTP client for the Hogsend data plane (contacts, events, emails, lists).

Readme

@hogsend/client

Typed HTTP client for the Hogsend data plane — contacts, events, transactional emails, and lists. Thin wrapper over native fetch, no heavy dependencies, ships compiled ESM + CJS + .d.ts.

Install

pnpm add @hogsend/client

For fully type-checked emails.send, also install @hogsend/email (a type-only optional peer) and augment its template registry in your app. Without it, the emails.send shape degrades to { template: string; props? }.

Note: the shipped .d.ts references @hogsend/email by module name. If you do NOT install the optional peer, keep skipLibCheck: true in your tsconfig (the default for most app scaffolds) — otherwise tsc emits TS2307: Cannot find module '@hogsend/email' from this package's declarations. Installing the peer (even for types only) removes the caveat entirely. The runtime JS has no dependency on @hogsend/email.

Usage

import { Hogsend } from "@hogsend/client";

const hs = new Hogsend({
  baseUrl: "https://api.example.com",
  apiKey: process.env.HOGSEND_DATA_KEY!, // hsk_… key with the `ingest` scope
});

// Contacts ----------------------------------------------------------------
await hs.contacts.upsert({
  email: "[email protected]",
  userId: "u_1",
  properties: { plan: "pro" },
  lists: { newsletter: true },
}); // -> { id, created, linked }

const found = await hs.contacts.find({ email: "[email protected]" }); // Contact[]
await hs.contacts.delete({ userId: "u_1" }); // -> { deleted }

// Events ------------------------------------------------------------------
await hs.events.send({
  userId: "u_1",
  name: "signup",
  eventProperties: { source: "landing" }, // → trigger.where / exitOn
  contactProperties: { country: "GB" }, // → contact record
  idempotencyKey: "evt_abc",
}); // -> { stored, exits: [{ journeyId, stateId, exited }] }

hs.events.track(/* … */); // alias of events.send

// Emails ------------------------------------------------------------------
await hs.emails.send({
  to: "[email protected]",
  template: "welcome",
  props: { name: "Ada" },
}); // -> { emailSendId, status }

// Lists -------------------------------------------------------------------
await hs.lists.list(); // -> ListSummary[]
await hs.lists.subscribe({ list: "newsletter", email: "[email protected]" });
await hs.lists.unsubscribe({ list: "newsletter", userId: "u_1" });

Identity

Every write takes an identity — at least one of email or userId (your external id). Both may be supplied; the type union and a runtime guard enforce that at least one is present.

Options

| Option | Type | Default | Notes | | ----------- | -------------------------- | --------- | ----------------------------------------- | | baseUrl | string | — | API base, e.g. https://api.example.com. | | apiKey | string | — | Data-plane hsk_… key (ingest scope). | | fetch | typeof fetch | global | Override for tests / custom agents. | | timeoutMs | number | 30000 | Per-request timeout (aborts the request). | | headers | Record<string, string> | {} | Extra headers on every request. |

Errors

All non-2xx responses (and transport failures) throw typed errors:

import { HogsendAPIError, RateLimitError } from "@hogsend/client";

try {
  await hs.emails.send({ to: "[email protected]", template: "welcome", props: {} });
} catch (err) {
  if (err instanceof RateLimitError) {
    // 429 — back off for err.retryAfter seconds
  } else if (err instanceof HogsendAPIError) {
    // err.status (0 = transport failure), err.body (parsed JSON or raw text)
  }
}
  • HogsendAPIError{ status, body }. status === 0 means the request never reached the server (DNS/connect/timeout).
  • RateLimitError extends HogsendAPIErrorstatus === 429, with retryAfter (seconds, from the Retry-After header) when present.

License

MIT