# Providers

> Search clinicians and organizations that bill Medicare, and fetch a full profile by NPI.

Source: https://openpipe.health/docs/api/providers/

## Search providers

```http
GET /api/providers
```

Returns clinicians and organizations that billed Medicare Part B. Costs 1 credit.

The endpoint has two modes. With `hcpcs` it ranks by volume of that one procedure. Without it, it ranks by total Medicare activity.

### Parameters

| Name | Type | Description |
|---|---|---|
| `hcpcs` | string | HCPCS/CPT code, for example `27447`. Switches to procedure mode. Find codes with [Procedures](https://openpipe.health/docs/api/procedures.md). |
| `state` | string | Two-letter state code. Case-insensitive. |
| `city` | string | City name. Case-insensitive, whole-name match. |
| `specialty` | string | Substring of the Medicare specialty, for example `ortho`. |
| `q` | string | Substring of the clinician or organization name. |
| `entity` | string | `I` for individuals, `O` for organizations. Ignored in procedure mode. |
| `min_services` | number | Minimum services. In procedure mode, minimum services of that procedure. |
| `sort` | string | `payment` (default), `services` or `patients`. Ignored in procedure mode, which always sorts by services. |
| `limit` | number | 1 to 200. Default 25. |
| `offset` | number | Rows to skip. Default 0. |

### Example

```sh
curl "$OPH_API/api/providers?state=CO&specialty=cardiology&sort=patients&limit=2" \
  -H "Authorization: Bearer $OPH_KEY"
```

```json
{
  "rows": [
    {
      "npi": "1234567893",
      "name": "Jane Example",
      "credentials": "MD",
      "entity_type": "I",
      "specialty": "Cardiology",
      "city": "Denver",
      "state": "CO",
      "zip5": "80218",
      "patients": 2841,
      "services": 11920,
      "medicare_payment": "612440"
    }
  ],
  "sql": "SELECT m.npi, ... FROM medicare_provider m WHERE m.state = $1 AND m.provider_type ILIKE $2 ORDER BY m.tot_benes DESC NULLS LAST LIMIT 2 OFFSET 0",
  "params": ["CO", "%cardiology%"],
  "sources": ["medicare_provider"],
  "ms": 3,
  "usage": { "credits": 1, "creditsUsed": 7, "creditsLimit": 100, "txid": "81245" }
}
```

In procedure mode each row has `hcpcs_code`, `services`, `patients` and `medicare_payment` for that procedure, and no `entity_type` or `zip5`.

Some numbers arrive as JSON strings, because they are 64-bit integers or exact decimals in the database: `npi` always, `medicare_payment` (rounded to whole dollars) always, and `patients` in procedure mode, where it is a sum. Parse them before doing arithmetic, and keep `npi` as a string.

## Get a provider

```http
GET /api/providers/:npi
```

Returns everything known about one NPI. Costs 1 credit, charged only if the provider exists.

`:npi` must be 10 digits, otherwise the call returns `400` with `NPI must be 10 digits.`

### Response

| Field | Contents |
|---|---|
| `registry` | The NPI registry record: name, credentials, specialty, subspecialty, taxonomy code, address, phone, enumeration date. `null` if the NPI is not in the registry. |
| `medicare` | Medicare Part B totals, one object per data year, newest first: patients, services, charges, payment, drug and medical payment split, average patient age and risk score. |
| `procedures` | Top 15 procedures by service count, with description, place of service (`F` facility, `O` office) and average payment. |
| `groups` | Up to 10 group practices the clinician belongs to, largest first. |
| `drugs` | Top 15 Part D drugs prescribed, by claims. |
| `payments` | Top 15 industry payers from Open Payments, by total amount. |
| `sql` | An object with the six statements, keyed `registry`, `medicare`, `procedures`, `groups`, `drugs`, `payments`. |
| `sources` | The eight datasets read. |

```sh
curl "$OPH_API/api/providers/1234567893" -H "Authorization: Bearer $OPH_KEY"
```

A provider that is in the registry but never billed Medicare returns `registry` with empty arrays elsewhere. An NPI in neither returns `404`.

The hospitals a clinician works at are under [`GET /api/providers/:npi/facilities`](https://openpipe.health/docs/api/hospital-intel.md#list-a-clinicians-facilities), and their trials and NIH grants under [`GET /api/market/experts/:npi`](https://openpipe.health/docs/api/experts.md#get-an-expert).
