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/npi

v1.1.2

Published

A type-safe TypeScript client for the CMS NPPES NPI Registry API.

Readme

Affinity NPI

A small, type-safe TypeScript client for the CMS NPPES NPI Registry API.

It looks up individual and organizational NPI records, searches the registry, validates NPI check digits locally, and handles the API's pagination and transient failures without requiring an API key.

Install

npm install @affinity-health/npi

Look up an NPI

import { NppesClient } from "@affinity-health/npi";

const nppes = new NppesClient();
const provider = await nppes.lookup("1003000126");

if (provider?.basic.status === "A") {
  console.log(provider.basic.first_name, provider.basic.last_name);
}

lookup validates the NPI check digit before making a request and returns null when NPPES has no matching record.

Search the registry

const result = await nppes.search(
  {
    enumerationType: "NPI-1",
    firstName: "Jane",
    lastName: "Smith",
    state: "MI",
  },
  { limit: 25 },
);

for (const provider of result.results) {
  console.log(provider.number, provider.basic.status);
}

Search criteria use camel case. Returned records retain the field names from the NPPES JSON response so it remains straightforward to compare a result with the source API.

The client covers every NPPES 2.1 query parameter: number, enumerationType, taxonomyDescription, namePurpose, firstName, useFirstNameAlias, lastName, organizationName, addressPurpose, city, state, postalCode, and countryCode, plus the limit, skip, and pretty request options.

Use query(criteria, options) when you need the untouched NPPES top-level envelope. It returns either { result_count, results } or { Errors }. The higher-level search method converts successful envelopes to camel case and throws NppesApiError for upstream validation issues.

Use searchAll(criteria) to follow every page CMS makes available for a search. NPPES returns at most 200 records per request and permits skipping at most 1,000 records, so a single search is limited to 1,200 records.

Validate locally

import { isValidNpi, normalizeNpi } from "@affinity-health/npi";

isValidNpi("1003000126"); // true
normalizeNpi("10030-00126"); // "1003000126"

Check-digit validation only proves that a number is structurally valid. Use lookup to determine whether NPPES contains the NPI.

Client options

const nppes = new NppesClient({
  timeoutMs: 10_000,
  retries: 2,
  retryDelayMs: 250,
  fetch: customFetch,
});

The client retries network failures and HTTP 429, 502, 503, and 504 responses with bounded exponential backoff. It honors Retry-After up to 30 seconds. Pass an AbortSignal to lookup, search, or searchAll when you need caller-controlled cancellation.

Runtime support

The package uses the standard Fetch API and works in modern Node.js, Bun, Cloudflare Workers, and similar server or edge runtimes. The NPPES endpoint does not currently allow cross-origin browser requests, so registry calls generally need to run behind your own server. The local validation helpers can run anywhere.

What this verifies

NPPES is a public registry maintained by the Centers for Medicare & Medicaid Services. Its API requires no credentials and retrieves updated NPPES data daily.

An active NPI record does not establish that a provider is licensed, credentialed, enrolled in Medicare, or permitted to prescribe. Those checks require the appropriate primary source, such as a state licensing board.

CMS does not publish an OpenAPI document for this endpoint. The package contract is checked against the official NPPES API documentation, its JSON conversion field map, and representative live NPI-1, NPI-2, foreign, military, endpoint, secondary-location, and error responses.

This project is independently maintained by Affinity Health and is not affiliated with or endorsed by CMS.

Development

vp install
vp check
vp test
vp pack

Run bun run smoke [npi] for an opt-in request against the live registry.

License

MIT