# Data catalog

> Free endpoints that list every dataset, describe every column, show how full each one is, return sample rows and search across all of it.

Source: https://openpipe.health/docs/data/catalog/

The catalog answers "what is in here?" before you spend credits on a search or a question. It lists the 13 datasets, says what one row is, describes every column, reports how full and how varied each column is, and returns sample rows.

Every catalog endpoint is free and takes an API key or a session token. Nothing in it is maintained by hand: structure and descriptions come from the table definitions the API itself uses, source versions from the `sources` table, and statistics from the `catalog_columns` table.

The same descriptions are on the [Tables](https://openpipe.health/docs/data/tables.md) page as one document.

## Limits

These apply per workspace, on top of the [general rate limits](https://openpipe.health/docs/api/errors.md#rate-limits).

| Applies to | Limit |
|---|---|
| Every request under `/api/catalog` | 240 per minute |
| `GET /api/catalog/search` | 180 per minute |
| `GET /api/catalog/:table/sample` | 40 per minute |

The dataset list and the table detail are sent with `Cache-Control: private, max-age=30`. The server re-reads versions and statistics at most once a minute.

## List datasets

```http
GET /api/catalog
```

```sh
curl "$OPH_API/api/catalog" -H "Authorization: Bearer $OPH_KEY"
```

```json
{
  "datasets": [
    {
      "table": "hospitals",
      "group": "Hospitals",
      "title": "Hospital Enrollments + Hospital Provider Cost Report + Hospital All Owners",
      "publisher": "CMS",
      "source_url": "https://data.cms.gov/…/Hospital_Enrollments_2026.11.12.csv",
      "version": "enrollments 2026-11-12, cost report FY2024 final, owners 2026-11-12",
      "data_year": 2024,
      "rows": 9326,
      "loaded_at": "2026-12-05T02:16:33.124Z",
      "profiled_at": "2026-12-05T04:03:58.072Z",
      "summary": "Every Medicare-enrolled hospital: identity and type from its enrollment record, size and financials from its latest cost report, and an ownership summary.",
      "grain": "One row is one hospital, identified by its CMS Certification Number (CCN).",
      "engine": "postgres+lake",
      "caveats": ["About a third of hospitals have no cost report on file, and those columns are NULL for them. …"],
      "column_count": 29,
      "join_keys": ["npi", "ccn"]
    }
  ],
  "credits": 0
}
```

| Field | Meaning |
|---|---|
| `table` | The dataset's name: the one in `sources` arrays and in the other catalog endpoints |
| `group` | The section it sits under: Clinicians, Prescribing, Hospitals, Groups, Industry payments or Rollups |
| `version`, `data_year`, `rows`, `loaded_at` | From the last pipeline load of this dataset |
| `profiled_at` | When the column statistics were computed, or `null` if they have not been |
| `grain` | What one row is |
| `engine` | Where the table is held: `postgres+lake` (both engines) or `lake` (Parquet only, today just `partd_drug`). A `lake` table has no indexes and is always answered by DuckDB. See [which engine ran](https://openpipe.health/docs/receipts.md#which-engine-ran). |
| `join_keys` | Which of the shared keys `npi`, `ccn`, `group_pac_id` and `hcpcs_code` the table carries |

The list holds the 13 datasets. `sources` and `catalog_columns` describe the data and are not datasets, so they are not listed here; they are on the [Tables](https://openpipe.health/docs/data/tables.md#catalog) page.

## Describe a table

```http
GET /api/catalog/:table
```

Returns everything in the dataset's list entry, plus its keys, indexes, notes on how it is read, an example question, join links and one entry per column.

```sh
curl "$OPH_API/api/catalog/hospitals" -H "Authorization: Bearer $OPH_KEY"
```

```json
{
  "table": "hospitals",
  "primary_key": ["ccn"],
  "indexes": [{ "name": "hospitals_state_beds_idx", "method": "btree", "columns": ["state", "beds"] }],
  "tips": ["…"],
  "ask": "…",
  "joins": [{ "key": "ccn", "table": "hospital_owners", "on": "hospitals.ccn = hospital_owners.ccn" }],
  "columns": [
    {
      "name": "ownership",
      "ordinal": 10,
      "type": "text",
      "nullable": true,
      "description": "For-profit status on the enrollment record.",
      "unit": null,
      "values": { "proprietary": "for-profit", "non-profit": "non-profit" },
      "note": "NULL when the enrollment record does not say.",
      "primary_key": false,
      "indexed": false,
      "join_key": false,
      "kind": null,
      "profile": {
        "null_pct": 4.2676,
        "distinct_count": 2,
        "distinct_approx": false,
        "min": null,
        "max": null,
        "median": null,
        "top_values": [{ "v": "non-profit", "n": 6636 }, { "v": "proprietary", "n": 2292 }]
      }
    },
    {
      "name": "beds",
      "ordinal": 20,
      "type": "integer",
      "nullable": true,
      "description": "Number of beds reported on the cost report.",
      "unit": "beds",
      "values": null,
      "note": null,
      "primary_key": false,
      "indexed": true,
      "join_key": false,
      "kind": null,
      "profile": { "null_pct": 36.6609, "distinct_count": 684, "distinct_approx": false, "min": "1", "max": "2863", "median": 62, "top_values": null }
    }
  ],
  "credits": 0
}
```

| Field | Meaning |
|---|---|
| `tips` | Things to know about how this table is read. They are written for whoever writes the SQL, which is the model behind [Ask](https://openpipe.health/docs/api/ask.md). |
| `ask` | A question about this table to send to [Ask](https://openpipe.health/docs/api/ask.md) |
| `joins` | Tables that share a key with this one, with the join condition |
| `columns[].values` | For a coded column, each value and what it means |
| `columns[].indexed` | A filter on an indexed column is answered fastest |
| `columns[].kind` | `id` for an identifier, `personal` for a name, street address or phone number, otherwise `null` |
| `columns[].profile` | The column's statistics, or `null` if the table has not been profiled |

Returns `404` with `No dataset with that name.` for any name that is not one of the 13 datasets. Account tables cannot be reached through the catalog.

### Profile statistics

| Field | Meaning |
|---|---|
| `null_pct` | Percentage of rows where the column is NULL, 0 to 100, to four decimal places |
| `distinct_count` | Number of different values |
| `distinct_approx` | `true` when `distinct_count` is an estimate. Counts are exact for tables up to 50 million rows, which today is every table. |
| `min`, `max` | Smallest and largest value, as text. Number and date columns only. |
| `median` | Number columns only |
| `top_values` | The most common values with their row counts, up to 15. Only for columns chosen as worth listing, such as states, specialties and coded fields, and only when the column has at most 10,000 different values. |

### What the statistics leave out

Some columns hold details of a real person or practice. For those the catalog reports how full and how varied the column is, and nothing that reveals a value.

- **Identifier and personal columns have no `min`, `max`, `median` or `top_values`.** That covers every column whose `kind` is `id` (NPI, CCN, group ids, HCPCS codes, ZIP codes) or `personal` (names of people and practices, street addresses, phone numbers). They carry `null_pct` and `distinct_count` only.
- **A top value is listed only if at least 11 rows carry it.** This is the same floor CMS uses to withhold small counts. Rarer values are left out, so the counts in `top_values` do not add up to the table's rows.
- The rule is applied twice: when the statistics are computed, and again when the API answers.

Sample rows are different: they are rows of the public data as published, so they include names and addresses.

## Sample rows

```http
GET /api/catalog/:table/sample
```

Returns 20 rows of the table with every column.

```sh
curl "$OPH_API/api/catalog/hospitals/sample" -H "Authorization: Bearer $OPH_KEY"
```

```json
{
  "table": "hospitals",
  "columns": ["ccn", "npi", "name", "…"],
  "rows": [{ "ccn": "…", "npi": "…", "name": "…" }],
  "engine": "postgres",
  "ms": 282,
  "limit": 20,
  "credits": 0
}
```

- The rows are whichever 20 the engine returns first. They are not random and not ordered.
- The sample is kept on the server until the table is loaded again, so repeated calls return the same rows and `ms` is the time of the run that produced them.
- Date columns are returned as `YYYY-MM-DD`.

## Search the catalog

```http
GET /api/catalog/search
```

Searches table names, column names, descriptions and the listed top values.

| Parameter | Meaning |
|---|---|
| `q` | Required. At least 2 characters after trimming. Only the first 64 are used, and anything longer than 256 is rejected. Case-insensitive. |

```sh
curl "$OPH_API/api/catalog/search?q=ownership" -H "Authorization: Bearer $OPH_KEY"
```

```json
{
  "q": "ownership",
  "hits": [
    { "kind": "column", "table": "hospitals", "column": "ownership", "value": null, "count": null, "snippet": "For-profit status on the enrollment record.", "score": 80 },
    { "kind": "column", "table": "hospital_owners", "column": "pct_ownership", "value": null, "count": null, "snippet": "Ownership share the party holds, 0 to 100. Officers and directors report 0 or leave it blank (NULL).", "score": 56 },
    { "kind": "value", "table": "hospital_owners", "column": "role", "value": "5% OR GREATER INDIRECT OWNERSHIP INTEREST", "count": 11538, "snippet": "role in hospital_owners", "score": 42 }
  ],
  "capped": false,
  "credits": 0
}
```

| Field | Meaning |
|---|---|
| `q` | The query as it was used: lower case, whitespace collapsed |
| `hits[].kind` | `table`, `column` or `value` |
| `hits[].value`, `hits[].count` | For a `value` hit: the value and how many rows carry it |
| `hits[].snippet` | The table summary, the column description, or where the value was found |
| `hits[].score` | Higher is better. Hits are sorted by it. |
| `capped` | `true` when 30 hits were returned, which is the most a search returns |

Things to know:

- **Names rank above values, and values above descriptions.** Within a field, an exact match beats a prefix, which beats a match at the start of a word, which beats a match inside a word.
- **A space matches an underscore.** `group pac id` finds `group_pac_id`.
- **Value hits come from `top_values` only.** Searching for a clinician's name or an NPI finds nothing here; use the [search endpoints](https://openpipe.health/docs/api/providers.md) for that.

| Status | Message |
|---|---|
| `400` | `Search needs at least 2 characters in ?q=.` |
| `400` | `Search text is too long.` |

## Where the statistics come from

The pipeline's last step, `profile`, computes them from the Parquet copy of each table and replaces that dataset's rows in `catalog_columns`. They describe the data as of `profiled_at`. See [Datasets](https://openpipe.health/docs/data/datasets.md#how-the-pipeline-runs).
