# Search CMS drug spending

Search and read CMS drug spending records through the Assyro API: what US Medicare spends on a drug (Part D and Part B Spending by Drug: total spending…

Source: https://www.assyro.com/docs/sources/cms-drug-spending

`GET https://api.assyro.com/v1/sources/cms-drug-spending/search`

> **Note:** Preview: `api.assyro.com` is not serving production data yet. This page follows the API's published description and may change before launch.

Search and read CMS drug spending records from your own code: what US Medicare spends on a drug (Part D and Part B Spending by Drug: total spending, claims, beneficiaries, dosage units, average spending per unit, by year) and what pharmacies pay to acquire it (NADAC per unit), in CMS's own column names. Published by Centers for Medicare & Medicaid Services ([data.cms.gov/summary-statistics-on-use-and-payments/medicare-medicaid-spending-by-drug](https://data.cms.gov/summary-statistics-on-use-and-payments/medicare-medicaid-spending-by-drug)); answered from Assyro's copy, refreshed daily 11:10 UTC.

Licence: public domain (see the [terms](https://www.usa.gov/government-works)). Each record links to its page at the source.

Example: "How much did Medicare Part D spend on Eliquis in the latest year?"

## Search

`GET https://api.assyro.com/v1/sources/cms-drug-spending/search` with any of these query parameters. Repeat a parameter for a list (`?phase=PHASE2&phase=PHASE3`). An unknown parameter is refused by name.

### Search parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `dataset` | string | no | Search one dataset only. Omit for all three. One of: `part-d`, `part-b`, `nadac`. |
| `query` | string | no | Words that must all appear in the brand, generic, manufacturer, HCPCS description or NDC description, e.g. "apixaban 5 mg". |
| `brand` | string | no | Brand name, substring match, e.g. "Humira" (in NADAC, matched against the NDC description). |
| `generic` | string | no | Generic name, substring match, e.g. "adalimumab" (in NADAC, matched against the NDC description). |
| `manufacturer` | string | no | Part D manufacturer, substring match (CMS cuts names to 15 characters), e.g. "AbbVie". Returns manufacturer rows, not "Overall". |
| `manufacturers` | boolean | no | Part D: true to return the per-manufacturer rows as well as "Overall". Default false (Overall rows only, so a drug is not counted twice). |
| `hcpcs` | string | no | Part B HCPCS code, exact, e.g. "J9271". |
| `ndc` | string | no | NADAC NDC, 11 digits; dashes ignored ("00003-0894-21"). |
| `year` | string | no | The data year whose columns the records show (Part D and Part B), e.g. "2023". Default: the latest year in CMS's file. |
| `sort` | string | no | relevance (default: exact name matches first), spending (CMS's Tot_Spndng for the year, highest first; Part D and Part B) or name. One of: `relevance`, `spending`, `name`. |
| `limit` | integer | no | Records to return, default 8. total reports every match. |
| `offset` | integer | no | Skip this many results (for paging), default 0. |

Each result is a record; read one in full with [Get a record](https://www.assyro.com/docs/sources/cms-drug-spending/records).

## What a record holds

- `id`, `title`, `url`: the source's identifier, its title and its page at the source, to verify it.
- `authority`, `publishedDate`, `version`: who published it, when, and the edition read.
- `snippet` and `fields`: the matching text and the source's own fields.
- `asOf`: the day Assyro's copy of the source was read.

## Example request

curl:

```bash
curl "https://api.assyro.com/v1/sources/cms-drug-spending/search?dataset=part-d&brand=Eliquis"
```

Python:

```python
import requests

response = requests.get(
    "https://api.assyro.com/v1/sources/cms-drug-spending/search",
    params={
        "dataset": "part-d",
        "brand": "Eliquis"
    },
)
response.raise_for_status()
print(response.json())
```

JavaScript:

```javascript
const response = await fetch("https://api.assyro.com/v1/sources/cms-drug-spending/search?dataset=part-d&brand=Eliquis");
const result = await response.json();
```
