# NPI lookup

> POST /npi checks a National Provider Identifier's check digit and reads its NPPES record: name, credential, specialty, license, addresses and status, or searches by name.

`POST https://api.qelka.com/v1/npi`

Look up a National Provider Identifier (NPI), the 10-digit number every US health care provider uses on claims, or find one from a provider's name: you get the record the provider filed with NPPES, the national registry run by the Centers for Medicare & Medicaid Services (CMS), with name, credential, specialties, licenses, practice and mailing addresses, and status. Each lookup costs 1 credit, found or not; errors and test keys are never billed.

## Request

Send either `npi` or `name`, never both.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `npi` | string | One of `npi` or `name` | none | The NPI to look up: 10 digits, sent as 1 to 20 characters. Spaces and dashes are removed. |
| `name` | string | One of `npi` or `name` | none | A provider name to search, 2 to 120 characters: a person, as first name then last name or as `Last, First`, or an organization. Up to 10 matches are returned, best first, and the full record of the best one. |
| `state` | string | No | none | Two-letter US state code, in any case, that narrows a name search to providers with an address in that state. Only with `name`. |
| `provider_type` | string | No | `any` | Name search only: `individual` searches NPI-1 records (people), `organization` searches NPI-2 records (organizations, groups, facilities), `any` searches both. |
| `fresh` | boolean | No | `false` | `true` skips the 7-day result cache and asks NPPES again. |

A body with both `npi` and `name`, with neither, or with `state` but no `name` is a `400 invalid_request`. The call waits for the NPPES API, so every snippet sets a 30-second client timeout.

```bash title="cURL"
curl https://api.qelka.com/v1/npi \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"npi": "1003000126"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/npi', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ npi: '1003000126' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/npi",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"npi": "1003000126"},
    timeout=30,
)
result = response.json()
print(result)
```
```php title="PHP"
<?php
$ch = curl_init('https://api.qelka.com/v1/npi');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('QELKA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['npi' => '1003000126']),
    CURLOPT_TIMEOUT => 30,
]);
$result = json_decode(curl_exec($ch), true);
print_r($result);
```
```go title="Go"
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{"npi": "1003000126"})
	request, _ := http.NewRequest(http.MethodPost, "https://api.qelka.com/v1/npi", bytes.NewReader(payload))
	request.Header.Set("Authorization", "Bearer "+os.Getenv("QELKA_API_KEY"))
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(response.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result)
}
```
```ruby title="Ruby"
require 'json'
require 'net/http'

uri = URI('https://api.qelka.com/v1/npi')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('QELKA_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate({ npi: '1003000126' })

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 30) do |http|
  http.request(request)
end
result = JSON.parse(response.body)
puts result
```

## Response

Every lookup gets a `200`, found or not. Read `status` first: `found`, `not_found` or `invalid`.

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this lookup: `lkp_` followed by 26 characters. |
| `object` | string | Always `npi`. |
| `input` | string | The `npi` or `name` you sent, without surrounding spaces. |
| `query` | string | `npi` or `name`: how the lookup was made. |
| `valid` | boolean or null | `true` when the NPI has 10 digits, starts with 1 or 2 and has a correct check digit, `false` when it does not. `null` for a name search. |
| `status` | string | `found`, `not_found` or `invalid`. |
| `reason` | string or null | Why no record is returned: `invalid_format`, `invalid_check_digit`, `not_in_nppes` or `no_match`. `null` when one is found. |
| `provider` | object or null | The provider record: the NPI looked up, or the best match of a name search. |
| `provider.npi` | string | The NPI, 10 digits. |
| `provider.type` | string | `individual` for an NPI-1 (a person), `organization` for an NPI-2. |
| `provider.name` | string | Display name: first, middle and last name followed by the credential, or the organization name. |
| `provider.first_name` | string or null | Individuals only. |
| `provider.middle_name` | string or null | Individuals only. |
| `provider.last_name` | string or null | Individuals only. |
| `provider.credential` | string or null | Credential as the provider wrote it, such as `M.D.` or `RN`. Individuals only. |
| `provider.organization_name` | string or null | Organizations only. |
| `provider.sole_proprietor` | boolean or null | Whether the individual reported being a sole proprietor. `null` for organizations or when not reported. |
| `provider.status` | string | `active` or `deactivated`. The NPPES API only publishes active NPIs, so a deactivated NPI is answered `not_found`. |
| `provider.enumeration_date` | string or null | Date the NPI was assigned, `YYYY-MM-DD`. |
| `provider.last_updated` | string or null | Date the record last changed, `YYYY-MM-DD`. |
| `provider.certification_date` | string or null | Date the provider last certified the record, `YYYY-MM-DD`. |
| `provider.primary_taxonomy` | object or null | The specialty the provider marked as primary, or the first one listed when none is marked. Same fields as `provider.taxonomies`. |
| `provider.taxonomies` | array of objects | Every specialty reported, with the license that goes with it. |
| `provider.taxonomies.code` | string | Health Care Provider Taxonomy code, such as `207R00000X`. |
| `provider.taxonomies.description` | string or null | The specialty the code stands for, such as `Internal Medicine`. |
| `provider.taxonomies.primary` | boolean | `true` for the primary specialty. |
| `provider.taxonomies.state` | string or null | State that issued the license reported with this specialty. |
| `provider.taxonomies.license` | string or null | License number reported with this specialty. |
| `provider.location_address` | object or null | The primary practice location. |
| `provider.location_address.lines` | array of strings | Street lines. |
| `provider.location_address.city` | string or null | City. |
| `provider.location_address.state` | string or null | State code. |
| `provider.location_address.postal_code` | string or null | ZIP code, written `12345-6789` when NPPES has nine digits. |
| `provider.location_address.country` | string or null | ISO 3166-1 alpha-2 code. |
| `provider.location_address.phone` | string or null | Phone number. |
| `provider.location_address.fax` | string or null | Fax number. |
| `provider.mailing_address` | object or null | The mailing address, with the same fields as `location_address`. |
| `provider.practice_locations` | integer | Number of secondary practice locations reported. |
| `provider.other_names` | array of objects | Other names on the record, such as a former name or a doing-business-as name. |
| `provider.other_names.type` | string or null | The kind of name, as NPPES labels it. |
| `provider.other_names.name` | string | The name. |
| `provider.authorized_official` | object or null | Organizations only: the person who signed the NPI application for the organization. |
| `provider.authorized_official.name` | string | Name of the official. |
| `provider.authorized_official.title` | string or null | Title or position. |
| `matches` | array of objects or null | For a name search: up to 10 candidates, best first. `null` for a lookup by NPI. |
| `matches.npi` | string | NPI of the candidate. |
| `matches.type` | string | `individual` or `organization`. |
| `matches.name` | string | First and last name, or organization name. |
| `matches.credential` | string or null | Credential. |
| `matches.primary_taxonomy` | string or null | Description of the primary specialty. |
| `matches.city` | string or null | City of the practice location. |
| `matches.state` | string or null | State of the practice location. |
| `credits_used` | integer | Credits debited for this call: 1 with a live key, `0` with a test key. |
| `cached` | boolean | `true` when the answer came from the 7-day cache. |

```json title="Response"
{
  "id": "lkp_01M8CFQ9KB0CNKCG2MQB3RDZ6N",
  "object": "npi",
  "input": "1003000126",
  "query": "npi",
  "valid": true,
  "status": "found",
  "reason": null,
  "provider": {
    "npi": "1003000126",
    "type": "individual",
    "name": "ARDALAN ENKESHAFI, M.D.",
    "first_name": "ARDALAN",
    "middle_name": null,
    "last_name": "ENKESHAFI",
    "credential": "M.D.",
    "organization_name": null,
    "sole_proprietor": false,
    "status": "active",
    "enumeration_date": "2007-08-31",
    "last_updated": "2026-11-17",
    "certification_date": "2026-11-17",
    "primary_taxonomy": {
      "code": "208M00000X",
      "description": "Hospitalist",
      "primary": true,
      "state": "DC",
      "license": "MD600003480"
    },
    "taxonomies": [
      {
        "code": "208M00000X",
        "description": "Hospitalist",
        "primary": true,
        "state": "DC",
        "license": "MD600003480"
      },
      {
        "code": "207R00000X",
        "description": "Internal Medicine",
        "primary": false,
        "state": "VA",
        "license": "0101254037"
      }
    ],
    "location_address": {
      "lines": ["6410 ROCKLEDGE DR STE 304"],
      "city": "BETHESDA",
      "state": "MD",
      "postal_code": "20817-1841",
      "country": "US",
      "phone": "443-602-6207",
      "fax": null
    },
    "mailing_address": {
      "lines": ["601 MEMORY LN"],
      "city": "YORK",
      "state": "PA",
      "postal_code": "17402-2231",
      "country": "US",
      "phone": "717-851-1405",
      "fax": "717-851-6969"
    },
    "practice_locations": 4,
    "other_names": [],
    "authorized_official": null
  },
  "matches": null,
  "credits_used": 1,
  "cached": false
}
```

The provider in this example reported five taxonomy and license pairs; two are shown.

## Act on the status

| `status` | `reason` | What it means | What to do |
|---|---|---|---|
| `found` | `null` | NPPES has a record for the NPI, or for the best match of the name. | Compare `provider.name`, `provider.type` and the licenses in `provider.taxonomies` with what the provider told you. After a name search, confirm that the record is the provider you meant: the other candidates are in `matches`. |
| `invalid` | `invalid_format` | The value is not 10 digits once spaces and dashes are removed. NPPES is not called. | Ask for the NPI again. |
| `invalid` | `invalid_check_digit` | The NPI has 10 digits but does not start with 1 or 2, or its last digit does not match the others. NPPES is not called. | Ask the provider to check each digit: it is usually a typo. |
| `not_found` | `not_in_nppes` | The NPI is well formed but NPPES has no active record of it: it was never assigned, or it was deactivated. | Ask for the NPI again, or search by name. |
| `not_found` | `no_match` | No provider matches the name, in the state when you sent one. `matches` is empty. | Try the legal name as registered, without the credential, or drop `state`. |

Every status is billed 1 credit, because the lookup ran. Answers with `status: "invalid"` are never cached.

Test keys never call NPPES. They know two fictional providers: NPI `1234567893`, `JANE SAMPLE, M.D.`, an internal medicine physician in Springfield, IL, and NPI `1245319599`, `SAMPLE HEALTH CLINIC`, an organization. A name search finds them when every word you send starts a word of their name, any other well-formed NPI is `not_found` with `not_in_nppes`, and NPIs with a wrong check digit are still `invalid`.

## How the check digit works

An NPI is nine digits followed by a check digit. Put `80840` in front of the first nine digits, the prefix ISO 7812 gives to US health care identifiers, and compute the [Luhn](https://en.wikipedia.org/wiki/Luhn_algorithm) check digit of those 14 digits: it must equal the tenth digit of the NPI. NPIs also start with 1 or 2. A single mistyped digit always fails the check, so the API catches it before any call to NPPES.

## How the name search works

A name with a comma is read as `Last, First`. Otherwise the first word is the first name and the last word the last name; a single word is a last name. An organization name matches the start of registered names, so a short name also finds the longer names that begin with it. With `provider_type: "any"`, people and organizations are both searched, and a name with words such as Clinic, Hospital, Pharmacy or LLC searches organizations first. Candidates are ranked by how close their name is to the one you sent.

## What the API keeps

The request log keeps the NPI with its middle digits hidden (`100***26`), or the first letter of a searched name, never the full name or the state.

## Where the data comes from

Records come from the [NPPES NPI Registry API](https://npiregistry.cms.hhs.gov/api-page) of CMS, queried at request time. NPPES data is published by the U.S. Department of Health and Human Services for public use; works of the U.S. Government are in the public domain. Specialty descriptions are the ones NPPES returns for each taxonomy code. See the [data sources page](https://qelka.com/data-sources).

## Examples

### Search by name

Send `name`, and `state` to narrow the search. The best candidate's full record comes back, and every candidate is in `matches`, best first. With a test key in `QELKA_API_KEY`, this request returns:

```bash title="cURL"
curl https://api.qelka.com/v1/npi \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Jane Sample", "state": "IL"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/npi', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Jane Sample', state: 'IL' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/npi",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"name": "Jane Sample", "state": "IL"},
    timeout=30,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8CGA3WQ4T7N2B9XKD5RZ1HE",
  "object": "npi",
  "input": "Jane Sample",
  "query": "name",
  "valid": null,
  "status": "found",
  "reason": null,
  "provider": {
    "npi": "1234567893",
    "type": "individual",
    "name": "JANE SAMPLE, M.D.",
    "first_name": "JANE",
    "middle_name": null,
    "last_name": "SAMPLE",
    "credential": "M.D.",
    "organization_name": null,
    "sole_proprietor": false,
    "status": "active",
    "enumeration_date": "2010-05-12",
    "last_updated": "2025-03-04",
    "certification_date": "2025-03-04",
    "primary_taxonomy": {
      "code": "207R00000X",
      "description": "Internal Medicine",
      "primary": true,
      "state": "IL",
      "license": "TEST-0001"
    },
    "taxonomies": [
      {
        "code": "207R00000X",
        "description": "Internal Medicine",
        "primary": true,
        "state": "IL",
        "license": "TEST-0001"
      }
    ],
    "location_address": {
      "lines": ["100 TEST AVENUE"],
      "city": "SPRINGFIELD",
      "state": "IL",
      "postal_code": "62701-0000",
      "country": "US",
      "phone": "555-010-0100",
      "fax": null
    },
    "mailing_address": {
      "lines": ["PO BOX 100"],
      "city": "SPRINGFIELD",
      "state": "IL",
      "postal_code": "62701",
      "country": "US",
      "phone": null,
      "fax": null
    },
    "practice_locations": 0,
    "other_names": [],
    "authorized_official": null
  },
  "matches": [
    {
      "npi": "1234567893",
      "type": "individual",
      "name": "JANE SAMPLE",
      "credential": "M.D.",
      "primary_taxonomy": "Internal Medicine",
      "city": "SPRINGFIELD",
      "state": "IL"
    }
  ],
  "credits_used": 0,
  "cached": false
}
```

### Catch a mistyped NPI

The last digit is wrong, so the check digit fails and NPPES is not called. The answer is billed, because the check ran.

```bash title="cURL"
curl https://api.qelka.com/v1/npi \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"npi": "1234567890"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/npi', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ npi: '1234567890' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/npi",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"npi": "1234567890"},
    timeout=30,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8CGA4E8YV6P0M3JQF2SN7TB",
  "object": "npi",
  "input": "1234567890",
  "query": "npi",
  "valid": false,
  "status": "invalid",
  "reason": "invalid_check_digit",
  "provider": null,
  "matches": null,
  "credits_used": 1,
  "cached": false
}
```

## Errors

| Status | Type | When |
|---|---|---|
| 400 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | Both or neither of `npi` and `name`, `state` without `name`, `npi` empty or longer than 20 characters, `name` shorter than 2 or longer than 120 characters, `state` not two letters, `provider_type` not `any`, `individual` or `organization`, a body that is not a JSON object, or a field the request table does not list |
| 401 | [invalid_api_key](https://qelka.com/docs/errors#invalid_api_key) | The key is missing, unknown or revoked |
| 402 | [insufficient_credits](https://qelka.com/docs/errors#insufficient_credits) | Your balance is less than 1 credit (live keys only) |
| 403 | [forbidden](https://qelka.com/docs/errors#forbidden) | The key is restricted to other endpoints |
| 405 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | The method is not `POST` |
| 422 | [unprocessable_input](https://qelka.com/docs/errors#unprocessable_input) | The name has no word of two letters or more |
| 429 | [rate_limited](https://qelka.com/docs/errors#rate_limited) | Too many requests: wait `Retry-After` seconds |
| 500 | [internal_error](https://qelka.com/docs/errors#internal_error) | Unexpected error on our side: retry with backoff |
| 502 | [upstream_unavailable](https://qelka.com/docs/errors#upstream_unavailable) | The NPPES API could not be reached, answered with an error or did not answer within 8 seconds: retry later |

No error is billed. An NPI that NPPES does not know is not an error: it is a `200` with `status: "not_found"`.

## Related

- [NPI registry API](https://qelka.com/products/npi-registry)
- Free tools: [NPI lookup](https://qelka.com/tools/npi-lookup), [NPI registry search](https://qelka.com/tools/npi-registry-search)
- [OIG exclusion screening](https://qelka.com/docs/api-reference/oig-exclusion): check the same NPI against the HHS exclusion list
- [Batch](https://qelka.com/docs/api-reference/batch): up to 100 lookups in one call, each item with `type: "npi"`
- [Bulk](https://qelka.com/docs/api-reference/bulk): a whole file of NPIs or names with `type=npi`
- [Caching](https://qelka.com/docs/caching), [Errors](https://qelka.com/docs/errors), [Test mode](https://qelka.com/docs/test-mode)
