# Medicare Part D Drug Spending Scraper (`parselab/medicare-part-d-drug-spending-prescribers-scraper`) Actor

Get Medicare Part D spending by drug with five years of price trends, rank changes and growth, plus prescriber profiles with claims, cost, brand and generic share, opioid prescribing rates and the patient mix. Export to CSV or Excel.

- **URL**: https://apify.com/parselab/medicare-part-d-drug-spending-prescribers-scraper.md
- **Developed by:** [ParseLab](https://apify.com/parselab) (community)
- **Categories:** Business, Other
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $16.13 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Medicare Part D Drug Spending and Prescribers Scraper

Get Medicare Part D data in clean rows you can export to CSV or Excel: what Medicare spends on every drug, how that changed over five years, and how doctors and clinics prescribe. The data is published by the Centers for Medicare and Medicaid Services (CMS), and the Actor reads the latest release on every run.

CMS publishes the figures as very large tables with one column group per year and many suppressed cells. This Actor turns them into answers: which drugs gained the most rank since 2020, what share of total Part D spending each drug takes, how fast the price per unit is growing, and for every prescriber the cost per claim, the brand and generic split, the opioid prescribing rate and how that compares with other prescribers of the same specialty in the same state.

### What can you do with this Medicare Part D scraper?

- List the top 100 drugs by Medicare Part D spending in 2024 with claims, patients and cost per claim.
- See which drugs moved up the spending ranking the most since 2020.
- Check the price per unit trend for a drug such as semaglutide or insulin over five years.
- Find drugs whose spending grew more than 100 percent since 2020.
- List all family practice doctors in a state with total claims, drug cost and brand share.
- Find prescribers with an opioid prescribing rate above 10 percent.
- Compare a prescriber with peers of the same specialty in the same state.
- See the patient mix of a prescriber: average age, sex, race, dual eligible patients and risk score.
- Download the drugs a single prescriber wrote, with cost per claim and cost per 30 day fill.
- Build lead lists of high prescribing specialists in a city for pharma sales and market research.

### Three ways to collect data

| Mode | One row is | Best for |
|---|---|---|
| Drug spending and price trends | one drug (or drug and manufacturer) | market sizing, pricing studies, news |
| Prescribers | one doctor or clinic | targeting, benchmarking, research |
| Drugs prescribed by each prescriber | one prescriber and drug | brand share, switching, audits |

### What data do you get for a drug?

- Brand name, generic name, manufacturer and number of manufacturers.
- For each year from 2020 to 2024: total spending, claims, patients, dosage units, average spending per claim, per patient and per dosage unit, and an outlier flag.
- Spending rank in 2024 and 2020 and the change in rank.
- Share of total Part D spending in 2024.
- Spending change in the last year and since 2020, claims change since 2020, unit price change and unit price growth rate per year.

### What data do you get for a prescriber?

- NPI, name, credentials, specialty, address, city, state, ZIP code and rural or urban class.
- Total claims, 30 day fills, drug cost, days supply and patients.
- Brand and generic claims and cost, claims for patients aged 65 and over.
- Opioid claims, cost and prescribing rate, long acting opioid rate, antibiotic claims and antipsychotic claims for older patients.
- Patient profile: average age, women and men, race groups, dual eligible patients and average risk score.
- Derived fields: cost per claim, cost per patient, claims per patient, brand share of claims and cost, opioid share, antibiotic share, share of patients aged 65 and over, dual eligible share, and the percentile of cost per claim among prescribers of the same specialty in the same state.

### Input example

Top drugs by spending growth since 2020:

```json
{
    "mode": "drugSpending",
    "sortBy": "growth",
    "maxItems": 100
}
```

Family practice doctors in Wyoming with at least 1,000 claims:

```json
{
    "mode": "prescribers",
    "states": ["WY"],
    "specialties": ["Family Practice"],
    "minClaims": 1000
}
```

### Output example

A real drug row, shortened:

```json
{
    "brandName": "Ozempic",
    "genericName": "Semaglutide",
    "totalSpending2024": 12970296347,
    "spendingRank2024": 2,
    "spendingRank2020": 20,
    "rankChange2020To2024": 18,
    "shareOfTotalSpending2024Pct": 4.49,
    "spendingChange2020To2024Pct": 790.9,
    "avgSpendingPerClaim2024": 1245.09
}
```

### How much does it cost?

You pay for each row returned, and the price per row drops with higher Apify subscription plans. Free accounts can test the Actor with up to 10 rows per run. A state with thousands of prescribers finishes in under a minute.

### Frequently asked questions

**Which years are covered?**
Drug spending covers 2020 to 2024. Prescriber data covers the latest year CMS has published, which is 2024.

**Why are some prescriber values empty?**
CMS hides counts below 11 to protect patient privacy. Those cells are returned as null, never as text.

**Does Part D include all prescriptions?**
No. It covers prescriptions paid by Medicare Part D plans. Cash, commercial insurance and Medicaid prescriptions are not included.

**Do the numbers include rebates?**
No. Spending is before manufacturer rebates, so it is higher than the net cost to Medicare.

**How do I use the specialty filter?**
Use the exact CMS specialty name, for example Family Practice, Internal Medicine, Cardiology or Nurse Practitioner.

**Can I get every prescriber in the country?**
Add several states. The Actor asks for at least one state, specialty or NPI, because the full table has more than a million prescribers.

### Limits

The Actor covers Medicare Part D only. Spending is before rebates, prescriber counts below 11 are hidden by CMS, and the data is published once a year. The data is public and published by the Centers for Medicare and Medicaid Services.

# Actor input Schema

## `maxItems` (type: `integer`):

Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000.

## `mode` (type: `string`):

Drug spending gives one row per drug with five years of spending, claims and price per unit, rank changes and growth. Prescribers gives one row per doctor or clinic with claims, cost, brand and generic share, opioid prescribing and patient profile. Prescriber drugs gives one row per prescriber and drug.

## `drugContains` (type: `string`):

Keep only drugs whose brand or generic name contains this text, for example Ozempic, semaglutide or insulin.

## `includeManufacturers` (type: `boolean`):

Drug spending mode only. Adds a row for each manufacturer of a drug on top of the overall row.

## `states` (type: `array`):

Prescribers and prescriber drugs only. Two letter state codes such as TX. Add at least one state, specialty or NPI.

## `specialties` (type: `array`):

Prescribers and prescriber drugs only. Exact specialty names as used by CMS, for example Family Practice, Cardiology, Nurse Practitioner or Psychiatry.

## `cities` (type: `array`):

Keep only prescribers in these cities, for example CHEYENNE.

## `zipCodes` (type: `array`):

Prescribers mode only. Five digit ZIP codes.

## `npis` (type: `array`):

Look up specific prescribers by their ten digit National Provider Identifier.

## `nameContains` (type: `string`):

Keep only prescribers whose first name, last name or clinic name contains this text.

## `minClaims` (type: `integer`):

Skip prescribers or prescriber and drug rows with fewer claims.

## `minOpioidRatePct` (type: `integer`):

Prescribers mode only. Keep prescribers whose share of opioid claims is at least this high.

## `sortBy` (type: `string`):

Order of the drug rows.

## Actor input object example

```json
{
  "maxItems": 10,
  "mode": "drugSpending",
  "includeManufacturers": false,
  "sortBy": "spending"
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("parselab/medicare-part-d-drug-spending-prescribers-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "maxItems": 10 }

# Run the Actor and wait for it to finish
run = client.actor("parselab/medicare-part-d-drug-spending-prescribers-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "maxItems": 10
}' |
apify call parselab/medicare-part-d-drug-spending-prescribers-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,parselab/medicare-part-d-drug-spending-prescribers-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/JkRBmN9UvBbShEeEz/builds/vi2EgwZAwtgDOYBW7/openapi.json
