# Medicare Hospital Compare Scraper (`brightpath-data/cms-hospital-compare`) Actor

Healthcare analysts and hospital-comparison tools get every CMS-rated hospital's star rating and quality measures as flat records, not a government search page.

- **URL**: https://apify.com/brightpath-data/cms-hospital-compare.md
- **Developed by:** [Nick Randall](https://apify.com/brightpath-data) (community)
- **Categories:** AI, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 hospital records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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 Hospital Compare Scraper

Healthcare analysts and hospital-comparison tools get every CMS-rated hospital's star rating and quality measures as flat records, not a paginated government search page. Filter by state, city, county, ownership or rating and export results ready for a spreadsheet or database.

Get clean, structured hospital records from the CMS Provider Data Catalog as JSON, CSV or Excel, or call it as a tool from Claude, Cursor, ChatGPT or any MCP client. Pay only for the results you receive.

### What you get

One record per Medicare-participating hospital: facility ID, name, address, city, state, zip, county, phone, hospital type and ownership, whether it offers emergency services, whether it meets the birthing-friendly designation, the overall CMS star rating and its footnote, and the measure counts and national-comparison footnotes for each of the five quality groups CMS tracks: mortality, safety, readmission, patient experience, and timely and effective care.

Every result is a flat record with stable field names, so it drops straight into a spreadsheet, a database or an AI agent's context.

### Why use this instead of the website

- Filter by state, city, county, name, hospital type, ownership, minimum rating and emergency services in one call
- Pagination handled for you, with automatic retries and polite rate limiting
- Results in JSON, CSV, Excel or via API, or piped into Zapier, Make, n8n and Google Sheets
- Works as an MCP tool, so AI agents can look up hospitals on demand
- No browser, no proxies, no personal data: fast runs and a tiny cost per result

### Input

| Field | Type | Default | Meaning |
|-------|------|---------|---------|
| `state` | string | | Two-letter state or territory code, e.g. "AZ". Strongly recommended. |
| `city` | string | | City or town name, matched exactly (case-insensitive). |
| `county` | string | | County name. |
| `nameContains` | string | | Only hospitals whose name contains this text. |
| `hospitalType` | string | any | Exact CMS hospital type, e.g. "Acute Care Hospitals". |
| `ownership` | string | any | Exact CMS ownership category, e.g. "Proprietary". |
| `minOverallRating` | integer | | Minimum overall Medicare star rating, 1 to 5. |
| `emergencyServices` | boolean | | true for hospitals with emergency services, false for those without, unset for both. |
| `maxResults` | integer | 100 | Cap on hospitals saved. You are charged per hospital, so this caps your cost. |

Example input:

```json
{ "state": "AZ", "emergencyServices": true, "maxResults": 40 }
```

### Output

Sample rows from a live run:

| facility | city | state | rating |
|---|---|---|---|
| BANNER - UNIVERSITY MEDICAL CENTER PHOE… | PHOENIX | AZ | 3 |
| TUCSON MEDICAL CENTER | TUCSON | AZ | 2 |
| VERDE VALLEY MEDICAL CENTER | COTTONWOOD | AZ | 4 |

Full example result:

```json
{
  "facilityId": "030002",
  "facilityName": "BANNER - UNIVERSITY MEDICAL CENTER PHOENIX",
  "address": "1111 EAST MCDOWELL ROAD",
  "city": "PHOENIX",
  "state": "AZ",
  "zipCode": "85006",
  "countyName": "MARICOPA",
  "phone": "(602) 839-2000",
  "hospitalType": "Acute Care Hospitals",
  "hospitalOwnership": "Voluntary non-profit - Other",
  "emergencyServices": true,
  "birthingFriendly": "Y",
  "overallRating": 3,
  "overallRatingFootnote": null,
  "mortalityMeasureCount": 7,
  "mortalityNationalComparison": null,
  "safetyMeasureCount": 8,
  "safetyNationalComparison": null,
  "readmissionMeasureCount": 11,
  "readmissionNationalComparison": null,
  "patientExperienceMeasureCount": 8,
  "patientExperienceNationalComparison": null,
  "timelyEffectiveCareMeasureCount": 12,
  "timelyEffectiveCareNationalComparison": null
}
```

Field reference: `facilityId`, `facilityName`, `address`, `city`, `state`, `zipCode`, `countyName`, `phone`, `hospitalType`, `hospitalOwnership`, `emergencyServices`, `birthingFriendly`, `overallRating`, `overallRatingFootnote`, `mortalityMeasureCount`, `mortalityNationalComparison`, `safetyMeasureCount`, `safetyNationalComparison`, `readmissionMeasureCount`, `readmissionNationalComparison`, `patientExperienceMeasureCount`, `patientExperienceNationalComparison`, `timelyEffectiveCareMeasureCount`, `timelyEffectiveCareNationalComparison`. `overallRating` is `null` when CMS has not yet published a rating for that hospital. Footnote fields hold CMS's national-comparison note when present, otherwise `null`.

### Pricing

Pay per event. You are charged **$2.00 per 1,000 results** saved to the dataset, plus a fraction of a cent per run start. Nothing is charged for results you do not receive. Set "Max total charge per run" in the run options to cap spending on any run. When a run reaches your cap it stops cleanly and keeps everything it already saved.

Rough guide: 1,000 results cost $2.00 and take about 15 seconds.

### Use it from an AI agent (MCP)

This Actor is available as an MCP tool through the Apify MCP server. Add it to your client, then ask the agent for the data in plain language.

Claude Desktop, Claude Code or Cursor (`mcp.json` / `claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com/?actors=brightpath-data/cms-hospital-compare",
      "headers": { "Authorization": "Bearer YOUR_APIFY_TOKEN" }
    }
  }
}
```

ChatGPT and other clients that support remote MCP servers: add `https://mcp.apify.com/?actors=brightpath-data/cms-hospital-compare` as a connector with your Apify token.

Example prompt once connected: "Find acute care hospitals in Arizona with emergency services and list their overall star rating and ownership."

### Use it from code

```bash
curl -X POST "https://api.apify.com/v2/acts/brightpath-data~cms-hospital-compare/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"state":"AZ","emergencyServices":true,"maxResults":40}'
```

Python:

```python
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("brightpath-data/cms-hospital-compare").call(run_input={"state": "AZ", "emergencyServices": True, "maxResults": 40})
items = client.dataset(run["defaultDatasetId"]).list_items().items
```

### Limits and fair use

- Up to 10,000 hospitals per run. For larger exports, split by state or city.
- Requests are paced at one per 250 ms and fetch up to 500 records per request.
- `minOverallRating` is applied after fetching each page, so a narrow filter on a huge unfiltered run (no state) can take longer than the item count suggests. Set a state for fast runs.

### Data source and legal

Data comes from the CMS Provider Data Catalog (data.cms.gov), the official public API behind Medicare Care Compare, published by the Centers for Medicare & Medicaid Services. The data is public and free to use. This Actor collects public, non-personal data only and does not bypass logins, paywalls or access controls. You are responsible for how you use the data.

### Support

Found a problem or need a field added? Open an issue on the Actor's Issues tab. Fixes for broken runs are prioritized.

# Actor input Schema

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

Two-letter US state or territory code, e.g. "AZ". Strongly recommended: without it the run pages through the entire national dataset.

## `city` (type: `string`):

City or town name, e.g. "Phoenix". Matched exactly (case-insensitive).

## `county` (type: `string`):

County name, e.g. "Maricopa".

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

Only include hospitals whose name contains this text, e.g. "MEMORIAL".

## `hospitalType` (type: `string`):

Exact hospital type category as published by CMS.

## `ownership` (type: `string`):

Exact hospital ownership category as published by CMS.

## `minOverallRating` (type: `integer`):

Only include hospitals with an overall Medicare star rating at or above this value (1 to 5). Hospitals with no rating are excluded when this is set.

## `emergencyServices` (type: `boolean`):

When set, only include hospitals that do (true) or do not (false) offer emergency services. Leave unset for both.

## `maxResults` (type: `integer`):

Maximum number of hospitals to save. You are charged per hospital saved, so this also caps the cost of a run.

## Actor input object example

```json
{
  "state": "AZ",
  "hospitalType": "",
  "ownership": "",
  "maxResults": 100
}
```

# Actor output Schema

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

The dataset with one flat record per result. Append ?format=csv or ?format=xlsx to the URL for other formats.

## `summary` (type: `string`):

OUTPUT record in the key-value store: counts of results pushed and charged, requests, retries and duration.

# 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 = {
    "state": "AZ"
};

// Run the Actor and wait for it to finish
const run = await client.actor("brightpath-data/cms-hospital-compare").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 = { "state": "AZ" }

# Run the Actor and wait for it to finish
run = client.actor("brightpath-data/cms-hospital-compare").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 '{
  "state": "AZ"
}' |
apify call brightpath-data/cms-hospital-compare --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,brightpath-data/cms-hospital-compare"
        }
    }
}
```

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/B4wD7Ru1upE8PnlFj/builds/VHYW00w3n1Hj39orx/openapi.json
