# Facilities

> Search hospitals by size, ownership and location, and fetch one hospital with its owners.

Source: https://openpipe.health/docs/api/facilities/

## Search facilities

```http
GET /api/facilities
```

Returns hospitals. Costs 1 credit.

### Parameters

| Name | Type | Description |
|---|---|---|
| `q` | string | Substring of the hospital name or its "doing business as" name. |
| `state` | string | Two-letter state code. |
| `city` | string | City name. Case-insensitive, whole-name match. |
| `min_beds` | number | Minimum bed count. |
| `ownership` | string | `proprietary` or `non-profit`. |
| `private_equity` | string | `true` to return only hospitals with a private-equity owner. |
| `sort` | string | `beds` (default), `revenue` or `discharges`. Always descending. |
| `limit` | number | 1 to 200. Default 25. |
| `offset` | number | Rows to skip. Default 0. |

### Example

```sh
curl "$OPH_API/api/facilities?state=TX&private_equity=true&sort=revenue&limit=1" \
  -H "Authorization: Bearer $OPH_KEY"
```

```json
{
  "rows": [
    {
      "ccn": "450000",
      "npi": "1234567893",
      "name": "EXAMPLE REGIONAL MEDICAL CENTER",
      "city": "DALLAS",
      "state": "TX",
      "ownership": "proprietary",
      "facility_type": "STH",
      "beds": 412,
      "discharges": 18730,
      "fte": 2104.5,
      "net_patient_revenue": 512000000,
      "net_income": 31000000,
      "fiscal_year_end": "2024-12-31",
      "has_private_equity_owner": true,
      "top_owner": "EXAMPLE HOLDINGS LLC"
    }
  ],
  "sql": "SELECT ccn, npi, name, ... FROM hospitals WHERE state = $1 AND has_private_equity_owner ORDER BY net_patient_revenue DESC NULLS LAST LIMIT 1 OFFSET 0",
  "params": ["TX"],
  "sources": ["hospitals"],
  "ms": 2,
  "usage": { "credits": 1, "creditsUsed": 8, "creditsLimit": 100, "txid": "81246" }
}
```

`facility_type` uses CMS codes, for example `STH` for short-term acute and `CAH` for critical access.

To filter hospitals by EHR vendor, star rating, health system or DRG volume, use [`GET /api/hospital-intel`](https://openpipe.health/docs/api/hospital-intel.md). Nursing homes, hospices and other non-hospital sites are on [Care sites](https://openpipe.health/docs/api/care-sites.md).

## Get a facility

```http
GET /api/facilities/:ccn
```

Returns one hospital by its CMS Certification Number, with its owners. Costs 1 credit, charged only if the hospital exists.

A CCN shorter than six characters is left-padded with zeros, so `/api/facilities/60001` and `/api/facilities/060001` are the same hospital.

### Response

| Field | Contents |
|---|---|
| `hospital` | Every column of the [`hospitals`](https://openpipe.health/docs/data/tables.md#hospitals) table: address, type flags, rural or urban, beds, discharges, staff, revenue, costs, income, owner count. |
| `owners` | Up to 50 owners and managing parties, largest stake first: name, type (`I` individual, `O` organization), role, title, association date, percentage owned, and flags for private equity, REIT and holding company. |
| `sql` | The two statements, keyed `hospital` and `owners`. |
| `sources` | `hospitals`, `hospital_owners`. |

Unknown CCNs return `404` with `No hospital with that CCN.`

Quality, EHR, health system, DRG volume and affiliated clinicians for the same CCN are under [`/api/facilities/:ccn/intel`](https://openpipe.health/docs/api/hospital-intel.md#get-hospital-intel) and the endpoints next to it.
