# Medicare Hospital Compare Scraper (`muhammadafzal/medicare-hospital-compare-scraper`) Actor

Retrieve official CMS Hospital Compare profiles with facility details, ownership, emergency services, and overall ratings for research and care-navigation workflows.

- **URL**: https://apify.com/muhammadafzal/medicare-hospital-compare-scraper.md
- **Developed by:** [Muhammad Afzal](https://apify.com/muhammadafzal) (community)
- **Categories:** Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.60 / 1,000 hospital profiles

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

Retrieve current hospital profiles from CMS’s official Medicare Hospital Compare **Hospital General Information** dataset. It is intended for researchers, patient-navigation teams, health-care analysts, and applications that need facility location, ownership, emergency-service availability, birthing-friendly designation, and CMS overall hospital ratings in a clean dataset.

The Actor reads the CMS Provider Data Catalog to discover the current official CSV each run, then filters it locally. It does not scrape patient reviews, make clinical recommendations, or return every individual quality-measure score.

### Free-plan result limit

Verified Apify free-plan runs return at most **5 hospital records per run**, even if `maxResults` is higher. Upgrade your Apify plan to request more than five records in one run; paid users retain the requested `maxResults` cap.

### What it extracts

| Field | Description |
| --- | --- |
| `facilityId` | CMS six-digit Certification Number |
| `facilityName`, `address`, `city`, `state`, `zipCode` | Official CMS facility identity and location |
| `countyOrParish`, `phoneNumber` | CMS contact fields when reported |
| `hospitalType`, `hospitalOwnership` | CMS facility classification |
| `emergencyServices` | Whether emergency services are reported |
| `birthingFriendlyDesignation` | CMS birthing-friendly indicator when reported |
| `hospitalOverallRating` | CMS overall quality star rating (1–5), or `null` |
| `sourceUrl`, `sourceLastModified`, `scrapedAt` | Traceability fields |

### Inputs

Use `facilityIds` when you already know one or more CMS Certification Numbers. You can instead combine `state`, `city`, `nameQuery`, and `overallRating`. All supplied filters are combined with AND logic. Results are limited by `maxResults`.

```json
{
  "state": "AL",
  "overallRating": "4",
  "maxResults": 10
}
```

The Console prefill retrieves CMS facility `010001`. When no filters are supplied, the default run returns the first 10 current CMS hospital profiles. A valid filter with no matching facility succeeds with an empty dataset and a run summary. Bad filter values are rejected before data retrieval. If CMS is unavailable, the Actor uses bounded retries, fails clearly, and does not fabricate records.

### Output example

```json
{
  "facilityId": "010001",
  "facilityName": "SOUTHEAST HEALTH MEDICAL CENTER",
  "city": "DOTHAN",
  "state": "AL",
  "hospitalType": "Acute Care Hospitals",
  "emergencyServices": true,
  "birthingFriendlyDesignation": true,
  "hospitalOverallRating": 4,
  "sourceUrl": "https://data.cms.gov/provider-data/.../Hospital_General_Information.csv",
  "sourceLastModified": "2026-07-22",
  "scrapedAt": "2026-09-02T12:00:00.000Z"
}
```

The default dataset contains only hospital profiles. `OUTPUT` and `SUMMARY` in the default key-value store contain source information, filters, record count, warnings, and expected result events.

### Pricing

This Actor uses **pay-per-event** pricing. These are the current Apify Store event prices:

| Event | Price (USD) | When it is charged |
|---|---:|---|
| `apify-actor-start` | $0.00005 | Actor Start — Charged when the Actor starts running. Number of events charged depends on Actor memory (one event per GB, minimum one event). — Charged once per run. |
| `apify-default-dataset-item` | $0.001 | Hospital profile — One CMS Hospital Compare facility profile written to the default dataset. |

Apify platform usage for this Actor run is included alongside the event prices above; no separate per-run platform-usage fee is passed to users.

This covers Apify platform usage for this Actor run. Other Apify products or usage outside this Actor run may still follow your account plan.

### Reliability and source notes

The source is the public [CMS Provider Data Catalog](https://data.cms.gov/provider-data/topics/hospitals) and its Hospital General Information CSV. CMS updates datasets independently, so individual fields and rating availability can change. The Actor discovers the current CSV from CMS metadata instead of hard-coding a dated file URL. It uses bounded result limits and performs no authenticated access, CAPTCHA bypass, or collection of patient data.

CMS information is useful for comparison and research, not medical advice. Confirm time-sensitive care decisions directly with a provider. CMS data is public; attribute CMS as the source and do not imply CMS endorsement of your product or service.

# Actor input Schema

## `facilityIds` (type: `array`):

Use this when you know CMS Certification Numbers. Enter six-digit IDs such as 010001. Leave empty to search by the filters below; this is not an NPI list.

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

Use this to restrict results to a two-letter U.S. state or territory code, for example AL. Leave empty for all states; this is not a city name.

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

Use this to match a hospital city, for example Dothan. Matching ignores letter case; this field is not a ZIP-code search.

## `nameQuery` (type: `string`):

Use this to find hospitals whose official CMS facility name contains text, for example Southeast Health. Matching ignores letter case; it is not a clinical-measure search.

## `overallRating` (type: `string`):

Use this to return facilities with one reported CMS overall rating from 1 to 5. Leave empty to include ratings that are unavailable; this is not a patient-survey rating.

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

Use this to cap returned hospital profiles. Enter 1-500; the default is 10. Each profile is one default-dataset result event. Verified Apify free-plan runs are capped at 5 records per run; upgrade for more.

## Actor input object example

```json
{
  "facilityIds": [
    "010001"
  ],
  "maxResults": 1
}
```

# Actor output Schema

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

Schema-validated records from the official CMS Hospital General Information dataset.

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

Filtering, source freshness, and delivery details.

# 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 = {
    "facilityIds": [
        "010001"
    ],
    "maxResults": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("muhammadafzal/medicare-hospital-compare-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 = {
    "facilityIds": ["010001"],
    "maxResults": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("muhammadafzal/medicare-hospital-compare-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 '{
  "facilityIds": [
    "010001"
  ],
  "maxResults": 1
}' |
apify call muhammadafzal/medicare-hospital-compare-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,muhammadafzal/medicare-hospital-compare-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/vvwb5PdOyHIOZCGdP/builds/w022YEwR9lppCuAdd/openapi.json
