# CMS Medicare Spending Scraper | MSPB Provider Data (`parseforge/cms-data-medicare-spending-scraper`) Actor

Export CMS Medicare Spending Per Beneficiary (MSPB) data at hospital, state and national level. Filter by US state. Pull facility ID, name, address, MSPB score and measurement period from the official data.cms.gov API. CSV, Excel, JSON or XML for healthcare research.

- **URL**: https://apify.com/parseforge/cms-data-medicare-spending-scraper.md
- **Developed by:** [ParseForge](https://apify.com/parseforge) (community)
- **Categories:** Other, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $19.00 / 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

![ParseForge Banner](https://github.com/ParseForge/apify-assets/blob/ad35ccc13ddd068b9d6cba33f323962e39aed5b2/banner.jpg?raw=true)

## 🏥 CMS Medicare Spending Scraper

> 🚀 **Export CMS Medicare spending data in seconds.** Pull Medicare Spending Per Beneficiary (MSPB) scores by hospital, state, or national level. CSV, Excel, JSON, or XML.

> 🕒 **Last updated:** 2026-05-26 · **📊 14 fields** per record · **4,600+ US hospitals + state and national rollups** · **CMS Hospital Compare 2024**

The CMS Medicare Spending Scraper pulls Medicare Spending Per Beneficiary (MSPB) data from the official data.cms.gov provider-data API. Records cover hospital-level, state-level, and national spending figures for the Medicare program.

CMS publishes MSPB scores annually for all hospitals participating in Medicare. The MSPB score measures how Medicares spending per patient at a given hospital compares to the national median. Coverage includes 4,600+ US hospitals and rolled-up state and national figures.

**Target Audience / Use Cases**

| Who | Why |
|---|---|
| Healthcare consultancies | Benchmark hospital efficiency |
| Health insurance carriers | Analyze provider cost patterns |
| Hospital admin | Compare against peers |
| Policy researchers | Study Medicare spending variation |
| Investors | Evaluate healthcare providers for M&A |
| Journalists | Cover healthcare cost stories |

---

### 📋 What the CMS Medicare Spending Scraper does

- Queries the data.cms.gov provider-data API for Medicare spending datasets
- Supports four dataset choices: hospital, state, national, and by-claim
- Filters by state code
- Returns 14 fields per record
- Exports to CSV, Excel, JSON, or XML
- Direct source links to CMS pages

> 💡 **Why it matters:** Medicare is the largest US health insurer by far. MSPB scores reveal which hospitals deliver care efficiently and which spend disproportionately. Programmatic access enables benchmarking, policy research, and investment analysis at scale.

---

### 🎬 Full Demo

_🚧 Coming soon_

---

### ⚙️ Input

<table>
<tr><th>Field</th><th>Type</th><th>Default</th><th>Description</th></tr>
<tr><td>maxItems</td><td>integer</td><td>10</td><td>Maximum records</td></tr>
<tr><td>dataset</td><td>select</td><td>rrqw-56er</td><td>Which CMS dataset to pull</td></tr>
<tr><td>state</td><td>string</td><td></td><td>Two-letter US state code</td></tr>
<tr><td>facilityName</td><td>string</td><td></td><td>Partial facility name match</td></tr>
</table>

**Example 1 - California hospital MSPB scores:**
```json
{
    "maxItems": 100,
    "dataset": "rrqw-56er",
    "state": "CA"
}
````

**Example 2 - National Medicare spending rollup:**

```json
{
    "maxItems": 10,
    "dataset": "3n5g-6b7f"
}
```

> ⚠️ **Good to Know:** The MSPB-1 measure has a national mean of 1.00. Scores below 1.00 indicate the hospital spends less per Medicare patient than the national average. Use state filtering to compare hospitals within the same regulatory environment.

***

### 📊 Output

Each record contains up to 14 fields:

| Field | Type | Description |
|---|---|---|
| 🏥 `facility_id` | string | CMS facility ID |
| 🏢 `facility_name` | string | Hospital name |
| 📍 `address` | string | Street address |
| 🏙️ `citytown` | string | City |
| 🌎 `state` | string | US state code |
| 📮 `zip_code` | string | ZIP code |
| 🏛️ `countyparish` | string | County/parish |
| 📞 `telephone_number` | string | Phone |
| 📊 `measure_id` | string | Measure ID (e.g. MSPB-1) |
| 📋 `measure_name` | string | Measure description |
| 💵 `score` | string | MSPB ratio score |
| 📅 `start_date` | string | Measurement period start |
| 📅 `end_date` | string | Measurement period end |
| 🔗 `sourceUrl` | string | CMS source URL |

**Sample record:**

```json
{
  "facility_id": "050441",
  "facility_name": "STANFORD HEALTH CARE",
  "address": "300 PASTEUR DRIVE",
  "citytown": "STANFORD",
  "state": "CA",
  "zip_code": "94305",
  "measure_id": "MSPB-1",
  "measure_name": "Medicare hospital spending per patient",
  "score": "1.02",
  "start_date": "01/01/2024",
  "end_date": "12/31/2024",
  "sourceUrl": "https://data.cms.gov/provider-data/dataset/rrqw-56er",
  "scrapedAt": "2026-05-26T12:00:00.000Z"
}
```

***

### ✨ Why choose this Actor

- 🏥 **Hospital-level granularity** for 4,600+ US facilities
- 🔄 **Real-time** from data.cms.gov
- 🔍 **4 dataset options**
- 📑 **14 fields per record**
- 📦 **Batch export**
- 💰 **Pay-per-result**
- 🚫 **No CMS account required**

***

### 📈 How it compares to alternatives

| Feature | This Actor | CMS Hospital Compare UI | data.cms.gov direct download |
|---|---|---|---|
| Bulk export | Yes | No | Yes (CSV) |
| Filter by state | Yes | Yes | No |
| Pagination | Automatic | Manual | N/A |
| Multiple datasets | Yes | One at a time | Manual download |
| Pay-per-result | Yes | Free | Free |

***

### 🚀 How to use

1. **Create a free account** at [Apify](https://console.apify.com/sign-up?fpr=vmoqkp) (includes $5 free credit)
2. Open the **CMS Medicare Spending Scraper** actor page and click **Try for free**
3. Enter your state code, dataset, and optional facility filter
4. Optionally set **maxItems** and other filters
5. Click **Start** and wait for the run to finish
6. Download your dataset as **CSV, Excel, JSON, or XML**

***

### 💼 Business use cases

#### Hospital Efficiency Benchmarking

Compare MSPB scores across hospitals within a state or region to identify outliers and benchmark best practices.

#### Insurance Network Design

Use spending data to inform provider network composition - favor efficient hospitals to control claims costs.

#### Healthcare Investment Due Diligence

When evaluating hospital systems for acquisition, MSPB scores indicate cost efficiency relative to peers.

#### Policy Research

Study geographic variation in Medicare spending - critical input for value-based payment policy design.

***

### 🔌 Automating CMS Medicare Spending Scraper

Connect this actor to your workflow with no-code tools:

- **Make (Integromat)** - send new records to Google Sheets, Airtable, or Slack
- **Zapier** - automate alerts when new records are found
- **n8n** - build pipelines that run on a schedule and push to your warehouse
- **Webhooks** - get notified when a run completes via Apify webhooks

***

### 🌟 Beyond business use cases

#### Independent Researchers

Patients can compare local hospitals by spending efficiency.

#### Journalism and Investigations

Journalists can cover hospital cost variation stories with publicly verifiable data.

#### Non-Profit and Policy Research

Academic researchers studying healthcare economics can build longitudinal MSPB datasets.

#### Education

Public health programs use MSPB data to identify high-cost regions for intervention.

***

### 🤖 Ask an AI assistant about this scraper

You can ask your AI assistant questions like:

- "How do I get Medicare hospital spending data?"
- "What is MSPB?"
- "How do I compare US hospitals by Medicare cost?"
- "Where does CMS publish MSPB scores?"

The answers will reference this actor and the CMS data.cms.gov provider-data API.

***

### ❓ Frequently Asked Questions

**What is MSPB?**
Medicare Spending Per Beneficiary - a ratio measure of a hospitals Medicare spending relative to the national average.

**What does an MSPB score of 1.00 mean?**
It equals the national median. Above 1.00 means above-average spending, below means more efficient.

**How current is the data?**
CMS updates MSPB annually. The 2024 measurement period covers Jan-Dec 2024.

**Does this require a CMS account?**
No.

**Can I filter by state?**
Yes. Use a 2-letter US state code.

**What is included in MSPB?**
Medicare payments from 3 days before admission through 30 days after discharge.

**Are critical access hospitals included?**
MSPB applies to acute-care hospitals. CAH facilities have separate measures.

**How many records per run?**
Free: 10. Paid: up to 1,000,000.

**Can I export to Excel?**
Yes.

**What are the four available datasets?**
Hospital-level, state-level, national-level, and per-claim Medicare spending.

**Can I run on a schedule?**
Yes.

***

### 🔌 Integrate with any app

Connect your dataset to 1,500+ apps via Apify integrations:

**Analytics:** Google Sheets, Airtable, Microsoft Excel, Tableau, Power BI
**Databases:** PostgreSQL, MySQL, MongoDB, BigQuery, Snowflake
**Communication:** Slack, Microsoft Teams, email notifications
**Storage:** Google Drive, Dropbox, Amazon S3, Azure Blob
**Automation:** Make, Zapier, n8n, Pipedream

***

### 🔗 Recommended Actors

| Actor | What it does |
|---|---|
| [Medicare Hospital Compare Scraper](https://apify.com/parseforge/hospital-compare-medicare-scraper) | Hospital quality ratings |
| [CMS Physician Compare Scraper](https://apify.com/parseforge/cms-physician-compare-scraper) | Medicare-enrolled physicians |
| [Medicare Home Health Compare Scraper](https://apify.com/parseforge/home-health-compare-scraper) | Home health agencies |

> 💡 **Pro Tip:** Browse the complete [ParseForge collection](https://apify.com/parseforge) for more government data, business intelligence, and research scrapers.

***

**Disclaimer:** This tool accesses publicly available CMS Medicare spending data via the official data.cms.gov API. ParseForge is not affiliated with CMS or HHS. Users are responsible for compliance with applicable laws.

# Actor input Schema

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

Free users: 10. Paid: up to 1,000,000

## `dataset` (type: `string`):

Which CMS Medicare Spending dataset to query

## `state` (type: `string`):

Two-letter US state code (e.g. CA, NY, TX)

## `facilityName` (type: `string`):

Partial match on facility name

## Actor input object example

```json
{
  "maxItems": 10,
  "dataset": "rrqw-56er"
}
```

# Actor output Schema

## `results` (type: `string`):

Scraped records

# 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,
    "dataset": "rrqw-56er"
};

// Run the Actor and wait for it to finish
const run = await client.actor("parseforge/cms-data-medicare-spending-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,
    "dataset": "rrqw-56er",
}

# Run the Actor and wait for it to finish
run = client.actor("parseforge/cms-data-medicare-spending-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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,
  "dataset": "rrqw-56er"
}' |
apify call parseforge/cms-data-medicare-spending-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=parseforge/cms-data-medicare-spending-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "CMS Medicare Spending Scraper | MSPB Provider Data",
        "description": "Export CMS Medicare Spending Per Beneficiary (MSPB) data at hospital, state and national level. Filter by US state. Pull facility ID, name, address, MSPB score and measurement period from the official data.cms.gov API. CSV, Excel, JSON or XML for healthcare research.",
        "version": "0.1",
        "x-build-id": "NrklwZjIepFfYnCAv"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/parseforge~cms-data-medicare-spending-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-parseforge-cms-data-medicare-spending-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/parseforge~cms-data-medicare-spending-scraper/runs": {
            "post": {
                "operationId": "runs-sync-parseforge-cms-data-medicare-spending-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/parseforge~cms-data-medicare-spending-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-parseforge-cms-data-medicare-spending-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "maxItems": {
                        "title": "Max Items",
                        "minimum": 1,
                        "maximum": 1000000,
                        "type": "integer",
                        "description": "Free users: 10. Paid: up to 1,000,000"
                    },
                    "dataset": {
                        "title": "Dataset",
                        "enum": [
                            "rrqw-56er",
                            "3n5g-6b7f",
                            "rs6n-9qwg",
                            "nrth-mfg3"
                        ],
                        "type": "string",
                        "description": "Which CMS Medicare Spending dataset to query"
                    },
                    "state": {
                        "title": "State",
                        "type": "string",
                        "description": "Two-letter US state code (e.g. CA, NY, TX)"
                    },
                    "facilityName": {
                        "title": "Facility Name",
                        "type": "string",
                        "description": "Partial match on facility name"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
