{"_id":"@affinity-health/npi","_rev":"4-d133c5de442716b13cd7c33bed0a19dc","name":"@affinity-health/npi","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.0":{"name":"@affinity-health/npi","version":"1.0.0","keywords":["cms","healthcare","npi","nppes","provider"],"author":"Affinity Health","license":"MIT","_id":"@affinity-health/npi@1.0.0","maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"homepage":"https://github.com/affinity-health/npi#readme","bugs":{"url":"https://github.com/affinity-health/npi/issues"},"dist":{"shasum":"d8940b47fd999c4d2cbccb489597afa374ee9cf2","tarball":"https://registry.npmjs.org/@affinity-health/npi/-/npi-1.0.0.tgz","fileCount":9,"integrity":"sha512-x35Y/bzXGQ8xKAEH74LqawLHeza3OIkV6GZ9XG3kfM+qolHAvPm9beFehUHUuLEGShNQphlWUDNjF1ayss5fTA==","signatures":[{"sig":"MEUCIQCWV+/AAZGYwNQPssU+j9GE3zOX2bmRwj8cqq2Z2W22pgIgFphEulwxDXRFroYUNk0w+0w/+AeNQHj8bklbd7RgGMs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":74325},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","shasum":"d8940b47fd999c4d2cbccb489597afa374ee9cf2","engines":{"node":">=20"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"scripts":{"dev":"vp pack --watch","test":"vp test","build":"vp pack","check":"vp check","smoke":"bun scripts/smoke.ts","verify":"bun run check && bun run test && bun run build","prepublishOnly":"bun run verify"},"_npmUser":{"name":"dawsson","email":"hello@dawson.gg"},"overrides":{"vite":"npm:@voidzero-dev/vite-plus-core@0.2.5"},"_integrity":"sha512-x35Y/bzXGQ8xKAEH74LqawLHeza3OIkV6GZ9XG3kfM+qolHAvPm9beFehUHUuLEGShNQphlWUDNjF1ayss5fTA==","repository":{"url":"git+https://github.com/affinity-health/npi.git","type":"git"},"_npmVersion":"10.8.3","description":"A type-safe TypeScript client for the CMS NPPES NPI Registry API.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"bun@1.3.14","devDependencies":{"vitest":"4.1.10","vite-plus":"0.2.5","typescript":"7.0.2","@types/node":"26.1.1"},"_npmOperationalInternal":{"tmp":"tmp/npi_1.0.0_1784505659420_0.6939851792060245","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@affinity-health/npi","version":"1.1.0","keywords":["cms","healthcare","npi","nppes","provider"],"author":"Affinity Health","license":"MIT","_id":"@affinity-health/npi@1.1.0","maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"homepage":"https://github.com/affinity-health/npi#readme","bugs":{"url":"https://github.com/affinity-health/npi/issues"},"dist":{"shasum":"ec4cf4c7ec6384311524f42232b4d6468f45955b","tarball":"https://registry.npmjs.org/@affinity-health/npi/-/npi-1.1.0.tgz","fileCount":9,"integrity":"sha512-1L9uyWpi3JVBpWW2TCC8fW36v3dvJ17xRZGDb9uTqfnRXcKkw4VDq+F1SGAV8FYQXCP9I/tgsg2/a0BW9TAI4Q==","signatures":[{"sig":"MEQCIAnTNFfrfjUXYAntgZohk1p4XtVaVxxW2Gq0SUuhCbOGAiBllE6qmmkfCLqBg1GfWe126cUUjsUfGkO3J4MPBS5B6w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":80062},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","shasum":"ec4cf4c7ec6384311524f42232b4d6468f45955b","engines":{"node":">=20"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"scripts":{"dev":"vp pack --watch","test":"vp test","build":"vp pack","check":"vp check","smoke":"bun scripts/smoke.ts","verify":"bun run check && bun run test && bun run build","prepublishOnly":"bun run verify"},"_npmUser":{"name":"dawsson","email":"hello@dawson.gg"},"overrides":{"vite":"npm:@voidzero-dev/vite-plus-core@0.2.5"},"_integrity":"sha512-1L9uyWpi3JVBpWW2TCC8fW36v3dvJ17xRZGDb9uTqfnRXcKkw4VDq+F1SGAV8FYQXCP9I/tgsg2/a0BW9TAI4Q==","repository":{"url":"git+https://github.com/affinity-health/npi.git","type":"git"},"_npmVersion":"10.8.3","description":"A type-safe TypeScript client for the CMS NPPES NPI Registry API.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"bun@1.3.14","devDependencies":{"vitest":"4.1.10","vite-plus":"0.2.5","typescript":"7.0.2","@types/node":"26.1.1"},"_npmOperationalInternal":{"tmp":"tmp/npi_1.1.0_1784506238926_0.1403856051114123","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@affinity-health/npi","version":"1.1.1","keywords":["cms","healthcare","npi","nppes","provider"],"author":"Affinity Health","license":"MIT","_id":"@affinity-health/npi@1.1.1","maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"homepage":"https://github.com/affinity-health/npi#readme","bugs":{"url":"https://github.com/affinity-health/npi/issues"},"dist":{"shasum":"6d1508c78cdeca3896393a295c2a94b383c84396","tarball":"https://registry.npmjs.org/@affinity-health/npi/-/npi-1.1.1.tgz","fileCount":9,"integrity":"sha512-QXqI3Lur6HQCbTNzatjdAJtluJxIx6azfeTQdwq8dUlLwQSA86sn7L1UqdqZ8pmEbVHO3IQC8PDvOBEDKv0e2Q==","signatures":[{"sig":"MEUCIBKeyVVUD21+HKq6ypBcE1MsucgvVhrTrazYIMs3UZEvAiEAidjtoKF/jfZBfMnzYTc+fuigE65HAe+0+s109U+aZLU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":80022},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","shasum":"6d1508c78cdeca3896393a295c2a94b383c84396","engines":{"node":">=20"},"exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"scripts":{"dev":"vp pack --watch","test":"vp test","build":"vp pack","check":"vp check","smoke":"bun scripts/smoke.ts","verify":"bun run check && bun run test && bun run build","prepublishOnly":"bun run verify"},"_npmUser":{"name":"dawsson","email":"hello@dawson.gg"},"overrides":{"vite":"npm:@voidzero-dev/vite-plus-core@0.2.5"},"_integrity":"sha512-QXqI3Lur6HQCbTNzatjdAJtluJxIx6azfeTQdwq8dUlLwQSA86sn7L1UqdqZ8pmEbVHO3IQC8PDvOBEDKv0e2Q==","repository":{"url":"git+https://github.com/affinity-health/npi.git","type":"git"},"_npmVersion":"10.8.3","description":"A type-safe TypeScript client for the CMS NPPES NPI Registry API.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"bun@1.3.14","devDependencies":{"vitest":"4.1.10","vite-plus":"0.2.5","typescript":"7.0.2","@types/node":"26.1.1"},"_npmOperationalInternal":{"tmp":"tmp/npi_1.1.1_1784506442929_0.09142347116188554","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@affinity-health/npi","version":"1.1.2","description":"A type-safe TypeScript client for the CMS NPPES NPI Registry API.","keywords":["cms","healthcare","npi","nppes","provider"],"homepage":"https://github.com/affinity-health/npi#readme","bugs":{"url":"https://github.com/affinity-health/npi/issues"},"license":"MIT","author":{"name":"Affinity Health"},"repository":{"type":"git","url":"git+https://github.com/affinity-health/npi.git"},"type":"module","sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.mts","exports":{".":{"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}},"./package.json":"./package.json"},"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"vp check","dev":"vp pack --watch","smoke":"bun scripts/smoke.ts","test":"vp test","verify":"bun run check && bun run test && bun run build","prepublishOnly":"bun run verify"},"devDependencies":{"@types/node":"26.1.1","typescript":"7.0.2","vite-plus":"0.2.5","vitest":"4.1.10"},"overrides":{"vite":"npm:@voidzero-dev/vite-plus-core@0.2.5"},"engines":{"node":">=20"},"packageManager":"bun@1.3.14","gitHead":"05608adb3e0a4b6fca43d89fb6e96822538c4784","_id":"@affinity-health/npi@1.1.2","_nodeVersion":"26.3.1","_npmVersion":"11.16.0","dist":{"integrity":"sha512-W395x1VXbkBvWhNF/r0CdfOrxp7XxwJWks+C2ad/bS8QVSH1462QUQUzd/FH4wUJPXlRTJ0DimB07e8WVRZHKg==","shasum":"c8f58c2eb092b86f35f1cd73cf9ccdfb9497e102","tarball":"https://registry.npmjs.org/@affinity-health/npi/-/npi-1.1.2.tgz","fileCount":9,"unpackedSize":80022,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAgGGKrveNRUUL9pEFuHfFC5vkRYUZVGOJwOFIJbv6JjAiBjMUrYkDpV2LKbuUnQGzX2jJl04RGvLw/s/JzueTtEHA=="}]},"_npmUser":{"name":"dawsson","email":"hello@dawson.gg"},"directories":{},"maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/npi_1.1.2_1784506602359_0.5394408446181729"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-20T00:00:59.150Z","modified":"2026-07-20T00:16:42.673Z","1.0.0":"2026-07-20T00:00:59.565Z","1.1.0":"2026-07-20T00:10:39.078Z","1.1.1":"2026-07-20T00:14:03.071Z","1.1.2":"2026-07-20T00:16:42.493Z"},"bugs":{"url":"https://github.com/affinity-health/npi/issues"},"author":{"name":"Affinity Health"},"license":"MIT","homepage":"https://github.com/affinity-health/npi#readme","keywords":["cms","healthcare","npi","nppes","provider"],"repository":{"type":"git","url":"git+https://github.com/affinity-health/npi.git"},"description":"A type-safe TypeScript client for the CMS NPPES NPI Registry API.","maintainers":[{"name":"dawsson","email":"hello@dawson.gg"}],"readme":"# Affinity NPI\n\nA small, type-safe TypeScript client for the CMS NPPES NPI Registry API.\n\nIt 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.\n\n## Install\n\n```sh\nnpm install @affinity-health/npi\n```\n\n## Look up an NPI\n\n```ts\nimport { NppesClient } from \"@affinity-health/npi\";\n\nconst nppes = new NppesClient();\nconst provider = await nppes.lookup(\"1003000126\");\n\nif (provider?.basic.status === \"A\") {\n  console.log(provider.basic.first_name, provider.basic.last_name);\n}\n```\n\n`lookup` validates the NPI check digit before making a request and returns `null` when NPPES has no matching record.\n\n## Search the registry\n\n```ts\nconst result = await nppes.search(\n  {\n    enumerationType: \"NPI-1\",\n    firstName: \"Jane\",\n    lastName: \"Smith\",\n    state: \"MI\",\n  },\n  { limit: 25 },\n);\n\nfor (const provider of result.results) {\n  console.log(provider.number, provider.basic.status);\n}\n```\n\nSearch 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.\n\nThe 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.\n\nUse `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.\n\nUse `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.\n\n## Validate locally\n\n```ts\nimport { isValidNpi, normalizeNpi } from \"@affinity-health/npi\";\n\nisValidNpi(\"1003000126\"); // true\nnormalizeNpi(\"10030-00126\"); // \"1003000126\"\n```\n\nCheck-digit validation only proves that a number is structurally valid. Use `lookup` to determine whether NPPES contains the NPI.\n\n## Client options\n\n```ts\nconst nppes = new NppesClient({\n  timeoutMs: 10_000,\n  retries: 2,\n  retryDelayMs: 250,\n  fetch: customFetch,\n});\n```\n\nThe 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.\n\n## Runtime support\n\nThe 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.\n\n## What this verifies\n\nNPPES is a public registry maintained by the Centers for Medicare & Medicaid Services. Its API requires no credentials and retrieves updated NPPES data daily.\n\nAn 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.\n\nCMS does not publish an OpenAPI document for this endpoint. The package contract is checked against the official [NPPES API documentation](https://npiregistry.cms.hhs.gov/api-page), its [JSON conversion field map](https://npiregistry.cms.hhs.gov/help-api/json-conversion), and representative live NPI-1, NPI-2, foreign, military, endpoint, secondary-location, and error responses.\n\nThis project is independently maintained by Affinity Health and is not affiliated with or endorsed by CMS.\n\n## Development\n\n```sh\nvp install\nvp check\nvp test\nvp pack\n```\n\nRun `bun run smoke [npi]` for an opt-in request against the live registry.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}