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

@affinity-health/sdk

v2.1.0

Published

Official TypeScript SDK for the Affinity API

Readme

Affinity TypeScript SDK

Typed server-side client for the Affinity API, for Node.js 20+, Bun, AWS Lambda and other Fetch runtimes. It ships an ES module and a CommonJS build, so import and require() both work. It targets API version 2026-11-01 and sends it in Affinity-Version on every request.

Install

bun add @affinity-health/sdk

For npm, use npm install @affinity-health/sdk.

Use

Keep API keys on the server. Never put them in browser bundles, mobile applications or public environment variables.

import { AffinityClient } from "@affinity-health/sdk";

const affinity = new AffinityClient({ token: process.env.AFFINITY_API_KEY! });
const account = await affinity.account.get();
if (account.mode !== "test") throw new Error("Use a Test key for this example");

for await (const medication of await affinity.medications.list())
  console.log(medication.name, medication.pharmacy.name);

The key sets the organization and the Test or Live mode. Test orders go to a test pharmacy.

  • Writes need an idempotencyKey. Save it with the reviewed order before the first request, and reuse it to retry. The client's automatic retries (2 by default, for 408, 429 and 5xx) reuse it.
  • Lists iterate every page. for await reads each next page; page.data is one page.
  • Errors are typed. Affinity.UnprocessableEntityError carries the issues that name each refused field. Every error extends AffinityError with statusCode, body and requestId.
  • Webhooks verify. verifyAffinityWebhook checks the Affinity-Signature of the raw body.

Read the SDK guide for orders, idempotency, pagination, errors and webhooks, and the API reference for every method. The quickstart reads Test data; the EMR example sends a clinician-reviewed order and receives its webhooks.

Build and verify

Fern generates src/generated from spec/affinity.openapi.json, the Affinity API contract; it runs locally in Docker, with no Fern account. Webhook verification in src/webhook-events.ts is written by hand.

bun install --frozen-lockfile
bun run generate      # regenerate after the contract changes (needs Docker)
bun run check         # build, regenerate-and-compare, types, tests, package and examples
AFFINITY_API_KEY=sk_test_... bun run smoke   # every operation against a real API, Test mode only

bun run smoke checks every response against the contract. It creates a Test practice and a Test order and cancels the order. Set AFFINITY_BASE_URL to call another API, and AFFINITY_SMOKE_WEBHOOK_URL to include webhook endpoints.