# Openpipe Health API: complete documentation > Openpipe Health is an API over public data on US healthcare, most of it from CMS: clinicians (NPI registry, Medicare Part B), procedure volumes by HCPCS code, Part D prescribing, hospitals with their owners, quality scores, EHR vendor, health system, DRG volumes and affiliated clinicians, nursing homes and other care sites with their owners, group practices, drug markets in Medicare Part D and Medicaid, Medicare Advantage payers and plans, ACOs, clinical-trial investigators and NIH grants, and industry payments. Use it through REST search and lookup endpoints, a plain-English question that returns a finished dashboard as JSON, or MCP tools. There is no endpoint that accepts SQL. Every data response shows the SQL the server ran, as a read-only receipt. This file holds all 32 pages of the docs, in reading order. Each page starts with a level-one heading, followed by its URL. The index of pages is at https://openpipe.health/docs/llms.txt. --- # Openpipe Health API URL: https://openpipe.health/docs/ Markdown: https://openpipe.health/docs/index.md > Query US clinicians, hospitals, group practices and procedure volumes over REST, MCP, or a plain-English question. > **Building with a coding agent?:** [Copy one prompt](https://openpipe.health/docs/agents.md#copy-this-to-your-agent) into Claude Code, Cursor or any other agent and it has the endpoints, prices, and limits it needs to start. The docs are also available as [`/docs/llms.txt`](https://openpipe.health/docs/llms.txt) and as Markdown, page by page. The Openpipe Health API answers questions about who delivers care in the US and how much of it: clinicians, hospitals and health systems, nursing homes and other care sites, group practices, procedures, prescriptions, drug markets, Medicare payers, ACOs, trial investigators and industry payments. The data comes from public files, most of them from CMS, and every response shows the SQL the server ran to produce it, as a receipt. ## Two ways to use it | You have | Use | Cost | |---|---|---| | A filter in mind (state, specialty, procedure code) | [Search and lookup endpoints](https://openpipe.health/docs/api/providers.md) | 1 credit | | A question the filters cannot express, in plain English | [`POST /api/ask`](https://openpipe.health/docs/api/ask.md): a small dashboard, as one JSON document or a live stream | 25 credits | Large result sets go through [`POST /api/exports`](https://openpipe.health/docs/api/exports.md), which writes every row of a list search or of an answer's tile to a CSV and returns a download link. There is no endpoint that accepts SQL. The server writes the SQL, checks it, and shows it to you with each result. Before spending credits, the free [data catalog](https://openpipe.health/docs/data/catalog.md) lists every dataset and column with sample rows. Answers are stored as [dashboards](https://openpipe.health/docs/api/saved.md) that open and refresh for free. AI clients such as Claude Code and Cursor can use the search and lookup tools and `ask` through the [MCP server](https://openpipe.health/docs/mcp.md), at the same prices. ## What is in the data - **Clinicians and organizations:** every active NPI in the registry (about 9.5 million), plus Medicare Part B totals for the 1.3 million that billed Medicare in 2024. - **Procedures:** 9.8 million rows of volume by clinician and HCPCS code. - **Prescribing:** 28 million rows of Part D claims by prescriber and drug. - **Hospitals:** 9,326 hospitals with beds, discharges, revenue and owners, including private-equity flags. - **Hospital intelligence:** star ratings and quality measures for 5,435 hospitals, the EHR vendor of 4,224, the health system of 3,950, Medicare inpatient volume by MS-DRG, and 2.3 million clinician-to-facility affiliations. See [Hospitals and systems](https://openpipe.health/docs/api/hospital-intel.md). - **Care sites:** 94,745 nursing homes, home health agencies, hospices, dialysis facilities, surgery centers and clinics, with owners for five of the types. See [Care sites](https://openpipe.health/docs/api/care-sites.md). - **Group practices:** 219,703 groups and 3.8 million clinician-to-group links. - **Drug markets:** Part D and Medicaid volume by drug and state, and national spending per drug from 2020 to 2024. See [Drug markets](https://openpipe.health/docs/api/drug-markets.md). - **Payers and ACOs:** 7,582 Medicare Advantage and Part D plans with enrollment by county, and 544 Medicare Shared Savings Program ACOs with their participants. See [Payers and ACOs](https://openpipe.health/docs/api/payers-acos.md). - **Experts:** 165,307 clinical trials and three fiscal years of NIH grants, with investigators linked to an NPI by name. See [Experts](https://openpipe.health/docs/api/experts.md). - **Industry payments:** 4.6 million Open Payments rows, aggregated to clinician and company. See [Datasets](https://openpipe.health/docs/data/datasets.md) for versions and sources, and [Caveats](https://openpipe.health/docs/data/caveats.md) before you quote a number: most utilization is Medicare fee-for-service only, and none of it is commercial insurance. ## Next steps 1. [Build with an AI agent](https://openpipe.health/docs/agents.md): one prompt that sets up Claude Code, Cursor or any coding agent. 2. [Quickstart](https://openpipe.health/docs/quickstart.md): first request in about two minutes. 3. [Authentication](https://openpipe.health/docs/authentication.md): API keys and session tokens. 4. [Workspaces and teams](https://openpipe.health/docs/workspaces.md): who shares credits and keys. 5. [MCP server](https://openpipe.health/docs/mcp.md): connect Claude Code or another MCP client. 6. [Receipts](https://openpipe.health/docs/receipts.md): how to read the `sql` and `sources` fields on every response. --- # Build with an AI agent URL: https://openpipe.health/docs/agents/ Markdown: https://openpipe.health/docs/agents.md > One prompt to paste into Claude Code, Cursor or any coding agent so it can build against the Openpipe Health API, plus llms.txt, Markdown pages and MCP setup. These docs are written to be read by coding agents as well as people. Copy the prompt below into your agent and it knows the endpoints, the prices, the limits, when to search and when to ask, and where to look up the rest. Before you paste it, set two environment variables in the shell your agent runs in. The agent reads the key from there, so it never appears in the conversation. See the [Quickstart](https://openpipe.health/docs/quickstart.md) for how to create a key. ```sh export OPH_API=http://localhost:4318 export OPH_KEY=oph_your_key_here ``` ## Copy this to your agent ```text title="Prompt for your coding agent" wrap You are building against the Openpipe Health API: public data on US healthcare, mostly from CMS (clinicians, hospitals, health systems, care sites, group practices, procedures, drugs, Medicare payers, ACOs, trial investigators, industry payments). Use REST endpoints, a plain-English question endpoint that returns a dashboard as JSON, or MCP tools. Nothing accepts SQL: never send any. DOCS (plain Markdown) - Index of pages and the full endpoint list: https://openpipe.health/docs/llms.txt - Everything in one file: https://openpipe.health/docs/llms-full.txt (shorter: llms-small.txt) - Any page: its path plus .md, for example https://openpipe.health/docs/api/ask.md Fetch an endpoint's page for its full parameters. SETUP - The base URL is in the environment variable OPH_API, the API key in OPH_KEY. Never ask me to paste the key, never print or commit it. If either is unset, stop and ask me. - Send on every request: Authorization: Bearer $OPH_KEY - Errors are JSON, {"error": "message"}. Branch on the HTTP status. - Results are in "rows". Some numbers arrive as JSON strings (npi, sums, money): parse them, but keep npi a string. ENDPOINTS (relative to $OPH_API; GET and 1 credit unless noted) - Free: /api/health, /api/meta, /api/me (credits.used, credits.limit), /api/catalog (what each dataset and column means). - /api/procedures?q=knee: HCPCS/CPT codes. - /api/providers: clinicians and organizations that billed Medicare. Filters: q, state, city, specialty. hcpcs=CODE ranks by volume of that procedure; add specialty to keep assistants out of a surgeon list. - /api/facilities: hospitals. Filters: q, state, min_beds, private_equity=true. /api/groups: group practices. - /api/providers/:npi, /api/facilities/:ccn, /api/groups/:id: one full record. - /api/hospital-intel: hospitals by EHR vendor (ehr), star rating (min_rating), health system (system) or volume in one MS-DRG (drg). /api/health-systems: systems. One hospital: /api/facilities/:ccn/intel, /clinicians, /measures, /drgs. Where a clinician works: /api/providers/:npi/facilities. - /api/care-sites: nursing homes, home health, hospices, dialysis, surgery centers, clinics. Filters include type, state, chain, private_equity, min_stars. One site: /api/care-sites/:id, /:id/owners. - /api/market/drugs?drug=Eliquis: one drug by state, Medicare Part D next to Medicaid. /api/market/drugs/spending: national spending by year. drug is an exact brand or generic name. - /api/market/payers, /api/market/payers/counties/:fips, /api/market/plans: Medicare Advantage and Part D enrollment by parent company, and plans. /api/market/acos, /api/market/acos/:id: Shared Savings Program ACOs. - /api/market/experts?condition=melanoma&state=TX: clinicians ranked by trials led. /api/market/experts/:npi: trials, NIH grants, industry payments. - POST /api/ask, body {"question": "..."}, header Accept: application/json: 25. Takes 5 to 30 seconds. Returns id, title, summary, tiles (each with columns, rows, sources, sql), failed, usage. - /api/dashboards, /api/dashboards/:id: free. Every answer is stored; reopen it by id. - POST /api/exports: 10. A CSV of up to 500,000 rows. The body is a reference: {"list": "providers" | "facilities" | "groups", "params": {search filters as typed JSON}} or {"dashboard": "", "tile": 0}. Searches take limit (default 25) and offset. state is a two-letter code. A 400 or 404 is free; a search that returns zero rows is charged. /api/hospital-intel, /api/health-systems and /api/care-sites reject an unknown parameter with 400; other searches ignore it. HOW TO CHOOSE - A filtered list or one record: a search or lookup (1). Try this first. - A count, total, breakdown, comparison, or a ranking the searches do not sort on: POST /api/ask (25). Name the procedure (with its HCPCS code), drug, specialty and state. - More rows than a page or a tile holds: POST /api/exports (10). CREDITS AND LIMITS - Credits are a monthly workspace allowance. Metered responses carry "usage": {"credits", "creditsUsed", "creditsLimit"}. Ask me before calling /api/ask or /api/exports. - HTTP 502 with "charged": false from ask means nothing was charged: rephrase. If your connection drops, do not ask again: find the stored answer with GET /api/dashboards. - 402: out of credits. Do not retry; tell me. - 429: wait the seconds in the Retry-After header, then retry. Per minute: 300 requests, 10 asks, 10 exports, 120 over MCP. - 400: fix the request; the message says how. 401: bad key; ask me. MCP (prefer it to REST if you support MCP) - Endpoint: $OPH_API/mcp. Streamable HTTP, the same key as a static header, no OAuth. - 27 tools: search_*, get_* and list_* tools for the routes above (1 each), ask (25), list_datasets and describe_data (free). tools/list has the schemas. Arguments are typed JSON: numbers and booleans, not strings. Exports are REST only. - Claude Code: claude mcp add --transport http openpipe "$OPH_API/mcp" --header "Authorization: Bearer $OPH_KEY" RECEIPTS Data responses include the SQL the server ran ("sql"), its values ("params") and the datasets read ("sources"). They are receipts. Show them with any number you show me. For an ask answer, also show its "summary". DATA CAVEATS - Volumes, patients and payments are Medicare fee-for-service only, 2024. Rank and compare with them; never call them totals. Nothing is commercial insurance. - Market responses name their population in "population". Medicaid amounts are before rebates. - Small counts are withheld (under 11 patients, discharges or prescriptions). NULL is not zero. - Hospital EHR is a 2024 attestation; no value means unknown. Clinician-hospital affiliations come from claims, at most five hospitals each: not a staff roster. - NPIs on trials and NIH grants are name matches. Verify "match_confidence": "medium" before outreach. FIRST TASK (2 credits). Run these now and show me the rows with their receipts: 1. curl -s "$OPH_API/api/health" 2. curl -s "$OPH_API/api/procedures?q=knee%20arthroplasty&limit=3" -H "Authorization: Bearer $OPH_KEY" 3. curl -s "$OPH_API/api/providers?hcpcs=27447&state=TX&specialty=orthopedic&limit=3" -H "Authorization: Bearer $OPH_KEY" Then ask me what I want to build. If it needs /api/ask, tell me the question and that it costs 25 credits, and wait for my go-ahead. ``` The same text is served on its own at [`/docs/agent-prompt.txt`](https://openpipe.health/docs/agent-prompt.txt), so you can also pipe it: ```sh curl -s https://openpipe.health/docs/agent-prompt.txt ``` What the prompt asks the agent to do first costs 2 credits: two searches. The health check is free. The agent is told to check with you before it spends 25 credits on a question. ## Use the MCP server If your agent speaks the Model Context Protocol, connect it to the [MCP server](https://openpipe.health/docs/mcp.md) and it gets 27 tools over the same data, at the same prices, with no HTTP code to write. Two of them are free and worth calling first: `list_datasets` shows what is loaded, and `describe_data` says what every dataset and column means. For anything the search tools cannot express, the `ask` tool takes a plain-English question and returns a finished dashboard as JSON for 25 credits. ```sh claude mcp add --transport http openpipe "$OPH_API/mcp" \ --header "Authorization: Bearer $OPH_KEY" ``` The server takes an API key in a static header. It does not support OAuth sign-in, and [exports](https://openpipe.health/docs/api/exports.md) are not available over MCP. ## Give your agent the whole docs Three files follow the [llms.txt](https://llmstxt.org) convention. All are plain Markdown, generated from these pages on every build. | File | Contents | Use it when | |---|---|---| | [`/docs/llms.txt`](https://openpipe.health/docs/llms.txt) | An index: one line per page, linking to its Markdown version | The agent can fetch pages as it needs them | | [`/docs/llms-small.txt`](https://openpipe.health/docs/llms-small.txt) | The essentials in one file: quickstart, authentication, credits, errors and rate limits, every endpoint, MCP, Ask and exports, the tables and the caveats | You want one paste that fits comfortably in context | | [`/docs/llms-full.txt`](https://openpipe.health/docs/llms-full.txt) | Every page, in reading order | You want nothing left out | ```sh curl -s https://openpipe.health/docs/llms-full.txt ``` ## Fetch one page as Markdown Every page has a Markdown version at the same path with `.md` in place of the trailing slash. The home page is `/index.md`. Each page links to its own under the title. | Page | Markdown | |---|---| | `/quickstart/` | [`/quickstart.md`](https://openpipe.health/docs/quickstart.md) | | `/api/ask/` | [`/api/ask.md`](https://openpipe.health/docs/api/ask.md) | | `/data/tables/` | [`/data/tables.md`](https://openpipe.health/docs/data/tables.md) | | `/` | [`/index.md`](https://openpipe.health/docs/index.md) | ```sh curl -s https://openpipe.health/docs/api/providers.md ``` Pages also declare it in their HTML, for tools that look there: ```html ``` ## Set up your tool ### Claude Code Add the MCP server once, from the shell where `OPH_API` and `OPH_KEY` are set: ```sh claude mcp add --transport http openpipe "$OPH_API/mcp" \ --header "Authorization: Bearer $OPH_KEY" ``` Then add this to the `CLAUDE.md` at the root of your project, so every session starts with the rules: ```markdown ## Openpipe Health API - Docs index: https://openpipe.health/docs/llms.txt (every page is Markdown; fetch what you need). What every column means: https://openpipe.health/docs/data/tables.md - Base URL is in `OPH_API`, the key in `OPH_KEY`. Read them from the environment. Never print, log or commit the key. - Use the `openpipe` MCP tools when they are connected. Otherwise call REST with `Authorization: Bearer $OPH_KEY`. - Search and lookup first. For a count, ranking or comparison they cannot give, use `ask` (REST: `POST /api/ask` with `Accept: application/json`). Never send SQL: nothing accepts it. - Costs: search and lookup 1 credit, export 10, Ask 25. Check with me before using Ask or exports. - `402` is out of credits: stop and tell me. `429`: wait `Retry-After` seconds, then retry. - Exports take a reference, not SQL: `{"list", "params"}` or `{"dashboard", "tile"}`. - Show the `sql` and `sources` from the response next to any number you report. - Volumes are Medicare fee-for-service only, and counts under 11 are withheld. Never call them totals. ``` ### Cursor Save the rules as `.cursor/rules/openpipe.mdc`: ```markdown --- description: Rules for calling the Openpipe Health API alwaysApply: true --- - Docs index: https://openpipe.health/docs/llms.txt (every page is Markdown; fetch what you need). What every column means: https://openpipe.health/docs/data/tables.md - Base URL is in `OPH_API`, the key in `OPH_KEY`. Read them from the environment. Never print, log or commit the key. - Use the `openpipe` MCP tools when they are connected. Otherwise call REST with `Authorization: Bearer $OPH_KEY`. - Search and lookup first. For a count, ranking or comparison they cannot give, use `ask` (REST: `POST /api/ask` with `Accept: application/json`). Never send SQL: nothing accepts it. - Costs: search and lookup 1 credit, export 10, Ask 25. Check with me before using Ask or exports. - `402` is out of credits: stop and tell me. `429`: wait `Retry-After` seconds, then retry. - Exports take a reference, not SQL: `{"list", "params"}` or `{"dashboard", "tile"}`. - Show the `sql` and `sources` from the response next to any number you report. - Volumes are Medicare fee-for-service only, and counts under 11 are withheld. Never call them totals. ``` And the MCP server in `.cursor/mcp.json`. Replace `YOUR_HOST` with the host of your base URL: ```json { "mcpServers": { "openpipe": { "url": "https://YOUR_HOST/mcp", "headers": { "Authorization": "Bearer ${env:OPH_KEY}" } } } } ``` `${env:OPH_KEY}` tells Cursor to read the key from its environment. If your version of Cursor does not fill it in, put the key in the file and keep the file out of git. ### Any other agent Paste [the prompt](#copy-this-to-your-agent) at the start of the session. If the agent cannot browse, paste the contents of [`/docs/llms-small.txt`](https://openpipe.health/docs/llms-small.txt) after it. If it has no shell, give it an HTTP tool and the two values some other way than the conversation, such as its secrets or environment settings. The API itself needs nothing agent-specific. It is plain HTTPS and JSON: ```sh curl "$OPH_API/api/providers?hcpcs=27447&state=TX&limit=3" \ -H "Authorization: Bearer $OPH_KEY" ``` ## What an agent must get right The prompt covers these. They are the rules worth checking in whatever your agent builds. | Rule | Why | Details | |---|---|---| | Read the key from `OPH_KEY` | A key in a chat or a commit can spend your workspace's credits | [Authentication](https://openpipe.health/docs/authentication.md) | | Do not retry `402` | The workspace is out of credits until the month resets or the limit is raised | [Credits](https://openpipe.health/docs/credits.md#running-out) | | On `429`, wait `Retry-After` seconds | Limits are per minute, and a request that is rejected still counts | [Rate limits](https://openpipe.health/docs/api/errors.md#rate-limits) | | Search first, ask second, never send SQL | A search is 1 credit and a question 25, and no endpoint accepts SQL | [Ask](https://openpipe.health/docs/api/ask.md) | | Do not ask again after a dropped connection | The answer is charged and stored whether or not the client is listening | [Ask](https://openpipe.health/docs/api/ask.md#when-you-are-charged-and-what-is-stored) | | Show `sql` and `sources` with each number | That is how a person checks the answer | [Receipts](https://openpipe.health/docs/receipts.md) | | Never present a volume as a total | The data is Medicare fee-for-service only | [Caveats](https://openpipe.health/docs/data/caveats.md) | --- # Quickstart URL: https://openpipe.health/docs/quickstart/ Markdown: https://openpipe.health/docs/quickstart.md > Make your first Openpipe Health API request. > **Using a coding agent?:** Skip the typing: [copy one prompt](https://openpipe.health/docs/agents.md#copy-this-to-your-agent) into Claude Code, Cursor or any other agent. It makes these same requests for you once `OPH_API` and `OPH_KEY` are set. ## 1. Set the base URL Every path in these docs is relative to the base URL of your deployment. When you run the repo locally with `bun run dev`, that is `http://localhost:4318`. ```sh export OPH_API=http://localhost:4318 ``` Check that the API is up. This endpoint needs no key: ```sh curl $OPH_API/api/health ``` ## 2. Create an API key Sign in to the app at `/app`, find **API key**, and select **Create a key**. Keys start with `oph_` and are shown once, so copy it straight away. The key belongs to the [workspace](https://openpipe.health/docs/workspaces.md) you created it in and spends that workspace's credits. In an organization workspace, only owners and admins can create keys. ```sh export OPH_KEY=oph_your_key_here ``` ## 3. Search Rank Texas clinicians by the number of total knee replacements (HCPCS `27447`) they billed to Medicare: ```sh curl "$OPH_API/api/providers?hcpcs=27447&state=TX&limit=5" \ -H "Authorization: Bearer $OPH_KEY" ``` The response has the rows, the SQL that produced them, the datasets it read, and what the call cost: ```json { "rows": [ { "npi": "1234567893", "name": "Jane Example", "credentials": "MD", "specialty": "Orthopedic Surgery", "city": "Houston", "state": "TX", "hcpcs_code": "27447", "services": 412, "patients": "398", "medicare_payment": "498213" } ], "sql": "SELECT s.npi, ... FROM medicare_service s JOIN medicare_provider m ...", "params": ["27447", "TX"], "sources": ["medicare_service", "medicare_provider"], "ms": 4, "usage": { "credits": 1, "creditsUsed": 1, "creditsLimit": 100, "txid": "81234" } } ``` Values in example responses throughout these docs are illustrative. Field names and shapes are exact. Identifiers such as `npi`, and sums and money amounts, arrive as JSON strings. ## 4. Ask in plain English ```sh curl "$OPH_API/api/ask" \ -H "Authorization: Bearer $OPH_KEY" \ -H "Content-Type: application/json" -H "Accept: application/json" \ -d '{"question": "Which states do the most cataract surgeries per Medicare patient?"}' ``` With `Accept: application/json` the finished dashboard comes back as one JSON document after 5 to 30 seconds: a title, a summary, and two to four tiles with their columns and rows. Leave the header out and the same answer arrives as server-sent events, one tile at a time. It costs 25 credits either way. See [Ask](https://openpipe.health/docs/api/ask.md). ## 5. Connect an AI client The same key works with the [MCP server](https://openpipe.health/docs/mcp.md), which gives Claude Code, Cursor and other MCP clients the search and lookup tools and `ask` directly: ```sh claude mcp add --transport http openpipe "$OPH_API/mcp" \ --header "Authorization: Bearer $OPH_KEY" ``` [Build with an AI agent](https://openpipe.health/docs/agents.md) has a ready-made prompt, rules files for Claude Code and Cursor, and the docs as [`/docs/llms.txt`](https://openpipe.health/docs/llms.txt). ## Limits to know about Requests are [rate limited](https://openpipe.health/docs/api/errors.md#rate-limits) per workspace: 300 a minute overall, 10 for Ask and 10 for exports. A `429` response has a `Retry-After` header that says how many seconds to wait. --- # Authentication URL: https://openpipe.health/docs/authentication/ Markdown: https://openpipe.health/docs/authentication.md > API keys, session tokens, browser sign-in, and which endpoints need neither. Send a bearer token on every request under `/api/`, except the public endpoints listed below. ```http Authorization: Bearer oph_your_key_here ``` ## Two kinds of token | Token | Looks like | Use it for | |---|---|---| | API key | Starts with `oph_` | Servers, scripts, notebooks and the [MCP server](https://openpipe.health/docs/mcp.md). Everything except key management. | | Session token | A short-lived JWT issued to a signed-in person | The browser app. Required to create or revoke API keys. | The two do not always resolve to the same place: - An **API key** always acts in the [workspace](https://openpipe.health/docs/workspaces.md) that created it. - A **session token** acts in your personal workspace, unless the request also sends `X-Oph-Workspace: ` to pick an organization workspace you belong to. Credits, usage and keys belong to the workspace, so a key and a session share a balance only when they act in the same workspace. ## API keys - Create and revoke keys in the app, or with [`POST /api/keys`](https://openpipe.health/docs/api/account.md#create-a-key) using a session token. - In an organization workspace, only owners and admins can create or revoke keys. Members get `403`. - The full key is returned once, at creation. Only a SHA-256 hash is stored. Afterwards you can see its 12-character prefix, its name and when it was last used. - A workspace can have 20 active keys. Creating a 21st returns `409`. Revoked keys do not count. - A revoked key stops working on the next request. - An API key cannot create or revoke keys. Those calls return `403` with `Sign in to do that; an API key cannot.` - A key is not tied to the person who created it. It keeps working if that person leaves the workspace. Keep keys on a server. Any key can spend its workspace's credits. ### The `X-Oph-Token` header If a proxy between you and the API replaces the `Authorization` header with its own credentials, send the same token in `X-Oph-Token` instead. When both are present, `X-Oph-Token` wins. ```http X-Oph-Token: oph_your_key_here ``` ## Public endpoints These need no token: | Endpoint | Returns | |---|---| | `GET /api/health` | Database and service status | | `GET /api/config` | Values the browser app needs to start | | `GET /api/meta` | The loaded datasets, their versions and row counts | The sign-in endpoints under `/api/auth/` take no bearer token either. They are described next. ## Browser sign-in The endpoints under `/api/auth/` are how the web app signs people in. They are **not for API-key clients**: they work with a cookie, not a bearer token, and they may change without notice. If you are calling the API from code, use an API key and skip this section. How it works: 1. The app posts credentials to one of the sign-in endpoints. On success the server sets an `oph_session` cookie: `HttpOnly`, `SameSite=Lax`, scoped to `/api/auth`, lasting 7 days. 2. The app calls `GET /api/auth/token` with that cookie and gets `{ "token": "…" }`, a short-lived JWT. 3. The app sends the JWT as `Authorization: Bearer …` to the rest of the API, and fetches a new one before it expires. | Endpoint | Body | Does | |---|---|---| | `POST /api/auth/sign-up` | `email`, `password` | Creates an account with a password and signs in | | `POST /api/auth/sign-in` | `email`, `password` | Signs in with a password | | `POST /api/auth/code` | `email`, `purpose` | Emails a 6-digit code. `purpose` is `sign-in` (default), `verify` or `reset`. | | `POST /api/auth/code/sign-in` | `email`, `code` | Signs in with the emailed code, creating the account if there is none. Also confirms the email address. | | `POST /api/auth/code/verify` | `email`, `code` | Confirms the signed-in person's email address. Needed before [accepting an invitation](https://openpipe.health/docs/workspaces.md#invitations). | | `POST /api/auth/code/reset` | `email`, `code`, `password` | Sets a new password using a `reset` code | | `GET /api/auth/token` | | Returns a session token for the cookie | | `GET /api/auth/me` | | Returns `user`: `id`, `email`, `name`, `emailVerified` | | `POST /api/auth/sign-out` | | Ends the session and clears the cookie | Things to know: - Passwords are 8 to 128 characters. - `POST` bodies must be JSON sent as `application/json`, at most about 8 KB. - `POST /api/auth/code` answers `{ "sent": true }` whether or not the email has an account. - Errors carry a `code` next to the message, for example `{ "error": "Wrong email or password.", "code": "INVALID_EMAIL_OR_PASSWORD" }`. - Sign-in attempts are rate limited per client address and per email. See [Rate limits](https://openpipe.health/docs/api/errors.md#rate-limits). Workspaces, members and invitations are also managed under `/api/auth/`. See [Workspace endpoints](https://openpipe.health/docs/workspaces.md#workspace-endpoints). ## Failures | Status | Message | Cause | |---|---|---| | `401` | `Missing Authorization: Bearer .` | No header, or not a bearer token. The response has a `WWW-Authenticate: Bearer` header. | | `401` | `Unknown or revoked API key.` | The `oph_` key does not match an active key | | `401` | `Invalid or expired session token.` | The JWT failed verification | | `403` | `You are not a member of that workspace.` | `X-Oph-Workspace` names an organization you do not belong to, or one that does not exist | | `403` | `Sign in to do that; an API key cannot.` | Key management called with an API key | | `403` | `Only workspace owners and admins can do that.` | Key management called by a member of an organization workspace | ## CORS Under `/api/`, the API allows any origin, the `Authorization`, `Content-Type`, `X-Oph-Token` and `X-Oph-Workspace` headers, and `GET`, `POST`, `DELETE` and `OPTIONS`. The [rate limit headers](https://openpipe.health/docs/api/errors.md#rate-limits) are exposed to browser code. Calling the API from a browser works, but puts your key in front of your users; prefer a session token there. --- # MCP server URL: https://openpipe.health/docs/mcp/ Markdown: https://openpipe.health/docs/mcp.md > Connect Claude Code, Cursor and other MCP clients to the same data, with the same API keys and credit prices. The API includes a remote [Model Context Protocol](https://modelcontextprotocol.io) server. It gives an MCP client (Claude Code, Cursor, or any client that speaks Streamable HTTP) 27 tools over the same data as the REST API: 24 search and lookup tools, a plain-English `ask` that returns a finished dashboard, and two free tools that describe the data. Each tool calls the same function as the matching REST endpoint and is metered the same way. No tool takes SQL. ```http POST /mcp ``` The path is `/mcp` on your base URL, not under `/api/`. - **Stateless.** There are no sessions. Every request stands alone, and the server never sends an `Mcp-Session-Id`. - **JSON only.** Every response is one `application/json` body. The server does not open an event stream. - **Tools only.** No resources, prompts or sampling. The tool list never changes during a connection. ## Authentication Send an [API key](https://openpipe.health/docs/authentication.md#api-keys) as a bearer token on every request: ```http Authorization: Bearer oph_your_key_here ``` **OAuth is not supported.** The server has no authorization endpoints and no client registration, so a client that can only connect through an OAuth sign-in flow cannot use it. Your client must be able to send a static header. The key acts in the [workspace](https://openpipe.health/docs/workspaces.md) that created it and spends that workspace's credits. ## Add it to Claude Code With `OPH_API` and `OPH_KEY` set as in the [Quickstart](https://openpipe.health/docs/quickstart.md): ```sh claude mcp add --transport http openpipe "$OPH_API/mcp" \ --header "Authorization: Bearer $OPH_KEY" ``` ## Other clients Clients that read a `{ "mcpServers": { ... } }` config take a URL and headers. Replace `YOUR_HOST` with the host of your base URL: ```json { "mcpServers": { "openpipe": { "url": "https://YOUR_HOST/mcp", "headers": { "Authorization": "Bearer oph_your_key_here" } } } } ``` Some clients need a transport named as well, for example `"type": "http"`. Check your client's documentation for the exact key. ## Tools | Tool | What it does | Credits | |---|---|---| | `search_providers` | Find clinicians and organizations that billed Medicare Part B. Filter by `q`, `state`, `city`, `specialty`, `entity`; pass `hcpcs` to rank by volume of one procedure. Same as [`GET /api/providers`](https://openpipe.health/docs/api/providers.md). | 1 | | `get_provider` | Full profile for one provider by 10-digit `npi`. | 1, free if not found | | `search_facilities` | Find hospitals. Filter by `q`, `state`, `city`, `min_beds`, `ownership`, `private_equity`. Same as [`GET /api/facilities`](https://openpipe.health/docs/api/facilities.md). For EHR, star rating, health system or DRG volume use `search_hospital_intel`. | 1 | | `get_facility` | One hospital by `ccn`, with its owners. | 1, free if not found | | `search_groups` | Find group practices. Filter by `q`, `state`, `min_members`, `specialty`. Same as [`GET /api/groups`](https://openpipe.health/docs/api/groups.md). | 1 | | `get_group` | One group practice by `id` (its `group_pac_id`), with specialty mix and top 50 members. | 1, free if not found | | `search_procedures` | Look up HCPCS/CPT codes by code prefix or description. Same as [`GET /api/procedures`](https://openpipe.health/docs/api/procedures.md). | 1 | | `search_hospital_intel` | Find hospitals by primary EHR vendor (`ehr`, `ehr_changed`, `uses_product`), star rating (`min_rating`, `max_rating`), health system (`system`, `system_id`), `hospital_type`, `min_beds`, or Medicare volume in one MS-DRG (`drg`, `min_discharges`). Same as [`GET /api/hospital-intel`](https://openpipe.health/docs/api/hospital-intel.md#search-hospitals-by-ehr-rating-system-or-drg). | 1 | | `get_hospital_intel` | Account research for one hospital by `ccn`. `section` picks the result: `summary` (default) is [`GET /api/facilities/:ccn/intel`](https://openpipe.health/docs/api/hospital-intel.md#get-hospital-intel), `measures` is [`/api/facilities/:ccn/measures`](https://openpipe.health/docs/api/hospital-intel.md#list-a-hospitals-quality-measures) (with `domain`), `drgs` is [`/api/facilities/:ccn/drgs`](https://openpipe.health/docs/api/hospital-intel.md#list-a-hospitals-drg-volume) (with `limit`, `offset`). | 1 per call, free if not found | | `list_hospital_clinicians` | The clinicians affiliated with one hospital by `ccn`, highest Medicare payment first. Filter by `specialty`. Same as [`GET /api/facilities/:ccn/clinicians`](https://openpipe.health/docs/api/hospital-intel.md#list-a-hospitals-clinicians). | 1, free if not found | | `get_clinician_hospitals` | The hospitals and other facilities one clinician works at, by `npi`. Same as [`GET /api/providers/:npi/facilities`](https://openpipe.health/docs/api/hospital-intel.md#list-a-clinicians-facilities). | 1, free if not found | | `search_health_systems` | Find health systems. Filter by `q`, `state` (home office), `min_hospitals`. Same as [`GET /api/health-systems`](https://openpipe.health/docs/api/hospital-intel.md#search-health-systems). | 1 | | `get_health_system` | One health system by `system_id`, with its EHR vendor mix and hospitals. Same as [`GET /api/health-systems/:id`](https://openpipe.health/docs/api/hospital-intel.md#get-a-health-system). | 1, free if not found | | `search_care_sites` | Find nursing homes, home health agencies, hospices, dialysis facilities, surgery centers, clinics and other non-hospital sites. Filter by `types`, `q`, `state`, `city`, `zip`, `chain`, `npi`, `ownership`, `min_beds`, `min_stars`, `min_patients`, `private_equity`, `reit`, `changed_ownership_since`. Same as [`GET /api/care-sites`](https://openpipe.health/docs/api/care-sites.md#search-care-sites). | 1 | | `get_care_site` | One care site by `id`. `section` picks the result: `profile` (default) is [`GET /api/care-sites/:id`](https://openpipe.health/docs/api/care-sites.md#get-a-care-site), `owners` is [`/api/care-sites/:id/owners`](https://openpipe.health/docs/api/care-sites.md#list-a-care-sites-owners) (with `equity_only`, `limit`, `offset`). | 1 per call, free if not found | | `list_care_site_types` | The facility types `search_care_sites` accepts, with national counts. Same as [`GET /api/care-sites/types`](https://openpipe.health/docs/api/care-sites.md#list-care-site-types). | 1 | | `get_drug_market` | One `drug` by state: Medicare Part D next to Medicaid. Optional `state` and `medicaid_year`. Same as [`GET /api/market/drugs`](https://openpipe.health/docs/api/drug-markets.md#get-a-drugs-market-by-state). | 1 | | `get_drug_spending` | One `drug`'s national spending per year, 2020 to 2024, in Part D, Part B and Medicaid. Optional `program` and `by_manufacturer`. Same as [`GET /api/market/drugs/spending`](https://openpipe.health/docs/api/drug-markets.md#get-a-drugs-national-spending-by-year). | 1 | | `get_medicare_payers` | Medicare private-plan enrollment and share by parent company. National by default and [`GET /api/market/payers`](https://openpipe.health/docs/api/payers-acos.md#get-medicare-payers-in-a-state-or-the-nation) with `state`, `category`, `parent`, `limit`. With `county_fips` it is [`GET /api/market/payers/counties/:fips`](https://openpipe.health/docs/api/payers-acos.md#get-medicare-payers-in-a-county). | 1, free if the county is not found | | `search_ma_plans` | Find Medicare Advantage and Part D plans. Filter by `q`, `parent`, `state`, `category`, `plan_type`, `snp`. Same as [`GET /api/market/plans`](https://openpipe.health/docs/api/payers-acos.md#search-medicare-advantage-and-part-d-plans). | 1 | | `search_acos` | Find Medicare Shared Savings Program ACOs. Filter by `q`, `state`, `track`, `participating`, `group_pac_id`. Same as [`GET /api/market/acos`](https://openpipe.health/docs/api/payers-acos.md#search-acos). | 1 | | `get_aco` | One ACO by `id`, with its participant organizations. Same as [`GET /api/market/acos/:id`](https://openpipe.health/docs/api/payers-acos.md#get-an-aco). | 1, free if not found | | `search_experts` | Rank clinicians by the trials they lead. At least one of `condition`, `sponsor`, `state`; optional `confidence`. Same as [`GET /api/market/experts`](https://openpipe.health/docs/api/experts.md#search-experts). | 1 | | `get_expert` | One clinician's trials, NIH grants and industry payments, by `npi`. Same as [`GET /api/market/experts/:npi`](https://openpipe.health/docs/api/experts.md#get-an-expert). | 1, free if not found | | `ask` | Answer a plain-English `question` (5 to 500 characters) with a finished dashboard: title, summary, and 2 to 4 tiles with their columns and rows. For aggregates, rankings, comparisons and market sizing that the search tools cannot do. Takes 5 to 30 seconds. Same as [`POST /api/ask`](https://openpipe.health/docs/api/ask.md#json-mode) in JSON mode. | 25, nothing if no answer can be planned | | `list_datasets` | The loaded datasets with publisher, version, data year, row count and load time. Same as [`GET /api/meta`](https://openpipe.health/docs/api/meta.md). | Free | | `describe_data` | What the data means. With no arguments: every dataset with its summary, what one row is and its join keys. With `dataset`: that dataset's caveats and its columns (type, description, unit, coded values). Use it to read the columns in a result or to word an `ask` question. | Free | `tools/list` returns the full JSON Schema for each tool. Things to know: - Arguments are strict. An unknown argument, or one of the wrong type, is rejected before anything runs or is charged. This holds for every tool, including those whose REST route ignores unknown query parameters. - Arguments are typed JSON. Send numbers and booleans as such (`"min_rating": 4`, `"private_equity": true`), not as the strings a query string carries. - Three arguments are named or shaped differently from REST. `search_care_sites` takes `types` as an array (`["nursing_home", "hospice"]`) where REST takes a comma-separated `type`. `get_drug_spending` takes a boolean `by_manufacturer` where REST takes `manufacturers=true`. `get_medicare_payers` takes `county_fips` as an argument where REST has it in the path, and it cannot be combined with `state`, `parent` or `limit`. - `section` arguments are checked. On `get_hospital_intel`, `domain` is accepted only with `section: "measures"`, and `limit` and `offset` only with `section: "drgs"`. On `get_care_site`, `equity_only`, `limit` and `offset` are accepted only with `section: "owners"`. - `limit` defaults to 25. The maximum is 200, except 100 for `search_procedures`, `get_medicare_payers`, `search_ma_plans`, `search_acos` and `search_experts`. Two tools differ: `get_aco` returns 200 participants by default and up to 500, and `get_care_site` with `section: "owners"` returns 50 by default. - `offset` pages through results, up to 100,000. On the care site, plan, ACO and expert tools the maximum is 10,000. - The values, ranges and caveats of each argument are those of the matching REST parameter. The linked reference pages describe them. - `run_sql` and `get_schema` were removed. Calling either is an unknown-tool error (`-32602`). - [Exports](https://openpipe.health/docs/api/exports.md) are not available over MCP. Use the REST API, with the `id` that `ask` returns. - `ask` shares the workspace's limit of 10 questions a minute with `POST /api/ask`. - Every tool is marked read-only. ### Results A successful tool call returns the same object as the REST endpoint, twice: as JSON text in `content[0].text`, and parsed in `structuredContent`. It includes `sql` (a read-only [receipt](https://openpipe.health/docs/receipts.md)), `sources` and the [usage object](https://openpipe.health/docs/credits.md#the-usage-object). ### The `ask` result `ask` returns the same document as [JSON mode](https://openpipe.health/docs/api/ask.md#json-mode): `id`, `question`, `title`, `summary`, `followups`, `model`, `tiles`, `failed`, `sources`, `ms` and `usage`. Each tile also has `row_count`. The charge follows the same rules: once, when a plan exists, and nothing if the model cannot plan. The answer is stored as a dashboard. `id` opens it again for free at [`GET /api/dashboards/:id`](https://openpipe.health/docs/api/saved.md#open-a-dashboard). A dashboard can be larger than one tool result. When it is, every tile is kept and its rows are cut to the same smaller number (100, then 50, 25, 10, 5, 1) until the result fits. A cut tile has `rows_truncated: true`, `row_count` still gives the full count, and the result says where the rest is: ```json "response_truncated": { "reason": "Tiles are cut to 25 rows to fit the response size limit. The stored dashboard has every row.", "dashboard": "/api/dashboards/df706628-076f-4fa8-9797-c5f6028915ab" } ``` Calls made over MCP appear in [`GET /api/usage`](https://openpipe.health/docs/api/account.md#list-usage) with `meta.via` set to `mcp` and `meta.tool` set to the tool name. ## Raw requests You do not need an MCP library to call the server. It is JSON-RPC 2.0, one message per `POST`. Initialize: ```sh curl "$OPH_API/mcp" \ -H "Authorization: Bearer $OPH_KEY" \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}' ``` ```json { "jsonrpc": "2.0", "id": 1, "result": { "protocolVersion": "2025-06-18", "capabilities": { "tools": { "listChanged": false } }, "serverInfo": { "name": "openpipe-health", "title": "Openpipe Health", "version": "1.0.0" }, "instructions": "US healthcare provider data from public CMS files …" } } ``` Because the server is stateless, `initialize` is optional when you call it by hand. You can send `tools/call` straight away: ```sh curl "$OPH_API/mcp" \ -H "Authorization: Bearer $OPH_KEY" \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"search_procedures","arguments":{"q":"knee","limit":2}}}' ``` ```json { "jsonrpc": "2.0", "id": 2, "result": { "content": [{ "type": "text", "text": "{\"rows\":[{\"code\":\"27447\", … }" }], "structuredContent": { "rows": [ { "code": "27447", "description": "Total knee arthroplasty", "is_drug": false, "providers": 9120, "tot_srvcs": 231400 } ], "sql": "SELECT code, description, is_drug, providers, tot_srvcs FROM hcpcs WHERE …", "params": ["knee%", "%knee%"], "sources": ["hcpcs"], "ms": 1, "usage": { "credits": 1, "creditsUsed": 11, "creditsLimit": 100, "txid": "81249" } } } } ``` ### Methods | Method | Result | |---|---| | `initialize` | Protocol version, capabilities, server info and instructions | | `ping` | `{}` | | `tools/list` | All 27 tools with their input schemas | | `tools/call` | A tool result | Supported protocol versions are `2025-11-25`, `2025-06-18`, `2025-03-26` and `2024-11-05`. An `initialize` that asks for any other version is answered with the newest. On later requests, an `MCP-Protocol-Version` header that names an unsupported version gets `400`. A message without an `id` is a notification. It is answered with `202` and an empty body, and it never runs anything: a `tools/call` without an `id` is not executed. ## Errors There are two kinds, and they arrive differently. ### Tool errors A tool that fails still returns HTTP `200` and a normal JSON-RPC result, with `isError` set to `true` and the message as text. This is so the model can read the message and correct itself. ```json { "jsonrpc": "2.0", "id": 3, "result": { "content": [{ "type": "text", "text": "NPI must be 10 digits." }], "isError": true } } ``` Tool errors cover: - Invalid arguments: `Invalid arguments. state: must be a two-letter USPS state code` - A record that does not exist: `No provider with NPI 1234567893.` - An argument that does not fit the section: `domain applies only to section=measures.` - A question that could not be planned: `The model could not plan an answer for that question. Nothing was charged.` - Too many questions: `Too many questions. A workspace can ask 10 a minute; try again in 41s. Nothing was charged.` - A dataset that does not exist: `No dataset named "accounts". Datasets: …` - Out of credits: `Out of credits: 100 of 100 used this month, this call costs 1.` Paid tools check the balance for their own price before doing any work, so `ask` needs 25 credits left. `list_datasets` and `describe_data` keep working. - A result too large to return even after trimming. - An unexpected failure: `Internal error.` ### Protocol and transport errors These use a JSON-RPC `error` object, `{ "jsonrpc": "2.0", "id": null, "error": { "code": -32001, "message": "…" } }`, and the HTTP status tells you what went wrong. | Status | JSON-RPC code | Cause | |---|---|---| | `401` | `-32001` | No key, or an unknown or revoked key. The response has a `WWW-Authenticate: Bearer realm="Openpipe Health"` header, with `error="invalid_token"` added when a key was sent but not accepted. | | `405` | `-32000` | Any method other than `POST` (or a CORS `OPTIONS`). `GET` does not open a stream and `DELETE` has no session to end. The response has `Allow: POST, OPTIONS`. | | `415` | `-32000` | `Content-Type` is not `application/json` | | `406` | `-32000` | An `Accept` header that allows neither `application/json` nor a wildcard | | `413` | `-32000` | Request body larger than 256 KB | | `400` | `-32700` | The body is not valid JSON | | `400` | `-32600` | Not a JSON-RPC 2.0 object, a bad `id`, or a batch. Batches are not supported: send one message per `POST`. | | `400` | `-32000` | Unsupported `MCP-Protocol-Version` header | | `200` | `-32601` | Unknown method | | `200` | `-32602` | Unknown tool name, or `params` that is not an object | | `429` | none | Rate limited. See below. | | `500` | `-32603` | `Internal error.` | The key is checked before the body is read, so a request without a valid key gets `401` whatever it contains. ## Limits | Limit | Value | |---|---| | Requests | 120 per minute, counted per API key and client address together | | Request body | 256 KB | | Tool result | About 100 KB | | `ask` | 10 questions per minute per workspace, counted together with `POST /api/ask` | | `ask` question | 5 to 500 characters | **Rate limit.** Responses carry the `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` headers described under [Rate limits](https://openpipe.health/docs/api/errors.md#rate-limits). Past the limit the server returns `429` with a `Retry-After` header. This one response is not JSON-RPC. It has the REST error shape: ```json { "error": "Too many requests. Try again in 23s.", "code": "RATE_LIMITED" } ``` The limit is checked before the key is, so requests with a bad key count too. **Result size.** When a search or lookup result is too large, the server drops rows from the end of its largest array until it fits, and adds a `response_truncated` field that says what was cut: ```json "response_truncated": { "fields": { "rows": { "returned": 212, "of": 1000 } }, "reason": "Result exceeded the response size limit. Narrow the search with a filter, or page with limit/offset." } ``` If the result cannot be made to fit, the tool returns an error instead. Either way the call has already run and is charged, so keep `limit` modest on wide searches. An `ask` result is trimmed [per tile](#the-ask-result) instead. ## CORS `/mcp` allows any origin, so browser-based clients such as the MCP Inspector can connect. No cookies are involved: the key travels in the `Authorization` header. --- # Workspaces and teams URL: https://openpipe.health/docs/workspaces/ Markdown: https://openpipe.health/docs/workspaces.md > Personal and organization workspaces, roles, invitations, and how a request picks the workspace it acts in. Every request acts in one workspace. The workspace owns the credits, the API keys, the usage history, the dashboards and the exports. People belong to workspaces; data does not belong to people. ## Two kinds of workspace | Kind | Who is in it | How it is created | |---|---|---| | Personal | You alone | Automatically, on your first signed-in request | | Organization | You and the people you invite | You create it and become its owner | Each workspace has its own plan and its own monthly [credit](https://openpipe.health/docs/credits.md) allowance. A new workspace of either kind starts on the `free` plan with 100 credits a month. Credits spent in an organization workspace do not touch your personal one, and the other way round. You can belong to several organization workspaces as well as your personal one. ## Which workspace a request acts in | You send | Workspace | |---|---| | An API key | Always the workspace that created the key. This cannot be changed per request. | | A session token | Your personal workspace | | A session token and `X-Oph-Workspace: ` | That organization workspace, if you are a member | ```http GET /api/me Authorization: Bearer X-Oph-Workspace: 5b0c9a52-7f1e-4a4e-9d1c-2f6f0c1d8e11 ``` - The header value is the organization's id, as returned by `GET /api/auth/orgs`. - If you are not a member, or the organization does not exist, the response is `403` with `You are not a member of that workspace.` The two cases are not told apart. - The header is ignored when the token is an API key. [`GET /api/me`](https://openpipe.health/docs/api/account.md#get-your-account) reports the workspace a request resolved to, and your role in it. ## Roles An organization workspace has three roles. In your personal workspace you are always the owner. | | Owner | Admin | Member | |---|---|---|---| | Use the data: search, lookup, Ask, exports | Yes | Yes | Yes | | See the workspace's balance, usage, keys list, dashboards and exports | Yes | Yes | Yes | | Refresh a dashboard, save a dashboard | Yes | Yes | Yes | | Rename or delete a recent (unsaved) dashboard | Yes | Yes | Yes | | Rename, unsave or delete a saved dashboard | Yes | Yes | Only one they saved | | Create and revoke API keys | Yes | Yes | No | | Invite people, cancel invitations | Yes | Yes | No | | Change a person's role, remove a person | Yes | Yes | No | The key rows and the dashboard rows are enforced by this API. The invitation and people rows are enforced by the sign-in service (Neon Auth), which holds the membership records. Things to know: - **Members share everything they can see.** Usage history, dashboards and export links are per workspace, not per person. Any member can open and refresh them. - **Saved dashboards have an owner.** A member can change or delete only the dashboards they saved. Owners and admins can change or delete anyone's. An API key can list, open and refresh, but never save, change or delete. See [who can do what](https://openpipe.health/docs/api/saved.md#who-can-do-what). - **An onboarding profile is the exception to "data does not belong to people".** A [profile](https://openpipe.health/docs/api/profile.md) belongs to the person and is the same in every workspace they open. - **Key management needs a signed-in person.** An API key can never create or revoke keys, whatever the role of the person who made it. See [Create a key](https://openpipe.health/docs/api/account.md#create-a-key). - **A workspace must keep an owner.** The only owner cannot leave until someone else is made an owner. - **Removal is quick but not instant.** A removed member's session token can keep working in that workspace for up to 30 seconds. The same delay applies to a role change. - **Keys outlive their creator.** An API key belongs to the workspace. It keeps working after the person who created it leaves or is removed, until an owner or admin revokes it. ## Invitations Owners and admins invite people by email address, as a `member` or an `admin`. **The platform does not email the invitation.** Creating one returns an invite code, and the person who created it passes it on themselves: 1. An owner or admin creates the invitation for an email address. The response includes a `code` and an expiry time. 2. They send the code to the invitee by whatever channel they like. 3. The invitee signs in with the invited email address. An account with a different email cannot accept: `That invitation was sent to a different email address.` 4. The invitee's email must be confirmed first. Signing in with an [emailed code](https://openpipe.health/docs/authentication.md#browser-sign-in) confirms it; an account that only ever used a password confirms it with a `verify` code. 5. The invitee accepts or rejects. On accept they become a member with the invited role, and can then send `X-Oph-Workspace` with that organization's id. An invitation can be cancelled by an owner or admin while it is pending. An expired or cancelled code returns `That invitation does not exist or has expired.` ## Workspace endpoints These endpoints are part of the browser sign-in surface under `/api/auth`. They are for the web app: they authenticate with the sign-in cookie, not with a bearer token, so **an API key cannot call them**. They are listed here so the behaviour is clear, and may change without notice. | Endpoint | Does | |---|---| | `GET /api/auth/orgs` | Lists your organization workspaces: `id`, `name`, `slug` | | `POST /api/auth/orgs` | Creates one. Body `{ "name": "…" }`, 2 to 60 characters. Returns `201` with `org`. | | `GET /api/auth/orgs/:id` | Returns `org`, `members` (`id`, `userId`, `role`, `email`, `name`, `joinedAt`) and pending `invitations` (`id`, `email`, `role`, `expiresAt`) | | `POST /api/auth/orgs/:id/invitations` | Invites. Body `{ "email": "…", "role": "member" }`; `role` is `member` (default) or `admin`. Returns `201` with `invitation`: `id`, `email`, `role`, `expiresAt`, `code`. | | `GET /api/auth/invitations/:id` | What an invite code points at: `email`, `role`, `status`, `orgId`, `orgName`, `invitedBy`. Needs the signed-in, confirmed recipient. | | `POST /api/auth/invitations/:id/accept` | Accepts. Returns `{ "accepted": true, "orgId": "…" }`. | | `POST /api/auth/invitations/:id/reject` | Rejects. Returns `{ "rejected": true, "orgId": "…" }`. | | `POST /api/auth/invitations/:id/cancel` | Cancels a pending invitation | | `POST /api/auth/orgs/:id/members/:memberId/role` | Changes a role. Body `{ "role": "member" }`; `member`, `admin` or `owner`. | | `POST /api/auth/orgs/:id/members/:memberId/remove` | Removes a person | | `POST /api/auth/orgs/:id/leave` | Leaves the workspace | The invite `code` is the invitation's `id`. `:memberId` is the member's `id` from `GET /api/auth/orgs/:id`, not their `userId`. `POST` bodies must be sent as `application/json`. Errors on these endpoints carry a machine-readable `code` next to the message, for example: ```json { "error": "Only owners and admins can invite people.", "code": "YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION" } ``` Creating workspaces, inviting, and answering invitations are rate limited per client address. See [Rate limits](https://openpipe.health/docs/api/errors.md#rate-limits). --- # Credits URL: https://openpipe.health/docs/credits/ Markdown: https://openpipe.health/docs/credits.md > What each call costs, how the monthly limit works, and how to check your balance. Every metered call spends credits from a monthly allowance. The allowance belongs to the [workspace](https://openpipe.health/docs/workspaces.md), not to a person or a key: every key and every member of a workspace draws on the same balance. A new workspace, personal or organization, is on the `free` plan with 100 credits a month. ## Prices | Action | Endpoints | Credits | |---|---|---| | Search | `GET /api/providers`, `/api/facilities`, `/api/groups`, `/api/procedures` | 1 | | Lookup | `GET /api/providers/:npi`, `/api/facilities/:ccn`, `/api/groups/:id` | 1 | | [Hospitals and systems](https://openpipe.health/docs/api/hospital-intel.md) | `GET /api/hospital-intel`, `/api/health-systems`, `/api/health-systems/:id`, `/api/facilities/:ccn/intel`, `/api/facilities/:ccn/clinicians`, `/api/facilities/:ccn/measures`, `/api/facilities/:ccn/drgs`, `/api/providers/:npi/facilities` | 1 each | | [Care sites](https://openpipe.health/docs/api/care-sites.md) | `GET /api/care-sites`, `/api/care-sites/types`, `/api/care-sites/:id`, `/api/care-sites/:id/owners` | 1 each | | [Drug markets](https://openpipe.health/docs/api/drug-markets.md) | `GET /api/market/drugs`, `/api/market/drugs/spending` | 1 each | | [Payers and ACOs](https://openpipe.health/docs/api/payers-acos.md) | `GET /api/market/payers`, `/api/market/payers/counties/:fips`, `/api/market/plans`, `/api/market/acos`, `/api/market/acos/:id` | 1 each | | [Experts](https://openpipe.health/docs/api/experts.md) | `GET /api/market/experts`, `/api/market/experts/:npi` | 1 each | | Export | `POST /api/exports` | 10 | | Ask | `POST /api/ask` | 25 | | [Ask (instant)](https://openpipe.health/docs/api/ask2.md), answered from a recipe | `POST /api/ask2/ask`, `/api/ask2/edit` | 5 | | Ask (instant), answered by the planner | `POST /api/ask2/ask`, `/api/ask2/edit` | 25 | | Open a predicted dashboard | `POST /api/ask2/open` | 5 | [MCP tools](https://openpipe.health/docs/mcp.md#tools) cost the same as the endpoint they match: 1 credit for the `search_*` and `get_*` tools and for `list_hospital_clinicians` and `list_care_site_types`, 25 for `ask`. `list_datasets` and `describe_data` are free. Not metered: `/api/health`, `/api/config`, `/api/meta`, `/api/me`, `/api/usage`, `/api/keys`, `GET /api/exports`, `GET /api/ask2/preview`, `POST /api/ask2/predict`, `GET /api/ask2/d/:id`, `GET /api/ask2/about` and everything under `/api/auth/`. Three more groups are free and have their own rate limits in place of a price: - [`/api/dashboards`](https://openpipe.health/docs/api/saved.md): listing, opening, saving, renaming and deleting, and also refreshing. A refresh runs the stored SQL again at no charge, up to 20 refreshes a minute per workspace and 2 at a time. - [`/api/catalog`](https://openpipe.health/docs/data/catalog.md): the dataset list, column descriptions and statistics, sample rows and search. - [`/api/profile`](https://openpipe.health/docs/api/profile.md): the onboarding profile. Session tokens only. ## When you are charged - **Search** on providers, facilities, groups and procedures is charged when the request arrives. - **Lookup** is charged only if the record exists. A `404` is free. - **Hospitals and systems, care sites, drug markets, payers, ACOs and experts** are charged only when the call succeeds. A `400` or a `404` is free. A search that returns no rows is a success and is charged. - **Exports** run first. An export that is rejected, fails or times out is free. - **Ask** is charged once, when the model has produced a plan and before any tile runs. If the model cannot plan an answer, nothing is charged. If a tile fails afterwards, the call is still charged, and [refreshing](https://openpipe.health/docs/api/saved.md#refresh-a-dashboard) the stored dashboard retries the tile for free. - **Ask (instant)** is charged 5 credits when a recipe answers, once, when the first tile has a result and before any row is sent. If every tile fails, or you disconnect before that point, nothing is charged. When the planner answers it is charged 25, the same way as Ask. A retry with the same `rid` and a second open of the same prediction are free. See [when you are charged](https://openpipe.health/docs/api/ask2.md#when-you-are-charged-and-what-is-stored). ## The usage object Every metered response carries what the call cost and where the workspace stands: ```json "usage": { "credits": 1, "creditsUsed": 42, "creditsLimit": 100, "txid": "81240" } ``` | Field | Meaning | |---|---| | `credits` | Cost of this call | | `creditsUsed` | Total the workspace has spent this calendar month, including this call | | `creditsLimit` | The workspace's monthly allowance | | `txid` | Postgres transaction id of the usage record. The app uses it to know when its live usage feed has caught up. You can ignore it. | ## Running out The balance is checked twice, and both checks answer `402`. **Before any work.** Every metered endpoint first checks whether the workspace can cover the price of the call. If it cannot, the request stops there: no query runs, and nothing else about the request is looked at. A malformed request or an unknown id gets `402` too, not `400` or `404`. ```json { "error": "Out of credits: 92 of 100 used this month, this call costs 10." } ``` The message is the same whether the allowance is spent or there is only too little left for this call. In the example, eight credits remain: a 1-credit search still works, a 10-credit export does not. **At the moment of charging.** The same check runs again, together with the usage record, and answers with the same message. It matters when several calls arrive at once: a call that passed the first check can still be refused here if others spent the balance in between. It is not charged. For an export the statement has already run by then; its result is discarded and no file is written. For Ask the plan is discarded and no tile runs. Charging is atomic. The balance check and the usage record happen together under one lock per workspace, so concurrent calls cannot spend past the limit between them. The limit is read fresh on every call, so a plan change applies to the next request. Over [MCP](https://openpipe.health/docs/mcp.md#errors), both cases come back as a tool error with the same message, not as an HTTP `402`. The count resets at the start of each calendar month, by the database clock. Check the balance any time with [`GET /api/me`](https://openpipe.health/docs/api/account.md#get-your-account). ## Older usage records `POST /api/sql` (5 credits) was removed. Calls made before that still appear in [`GET /api/usage`](https://openpipe.health/docs/api/account.md#list-usage) with `kind` set to `sql`, and still count toward the month they were made in. --- # Receipts URL: https://openpipe.health/docs/receipts/ Markdown: https://openpipe.health/docs/receipts.md > Every response shows the SQL the server ran and the datasets it read. A number about healthcare is only useful if someone can check it. Every data response from the API therefore includes its own receipt: the exact SQL the server ran, its parameters, and the datasets it touched. The receipt is for reading. The server writes every statement, either from the filters of a search or, for [Ask](https://openpipe.health/docs/api/ask.md), with a model whose SQL is checked before it runs. No endpoint accepts SQL from a caller. ## Fields | Field | On | Meaning | |---|---|---| | `sql` | All data endpoints | The statement that ran. On lookups, an object of named statements. | | `params` | Search endpoints | Values bound to `$1`, `$2`, … in `sql` | | `sources` | Search, lookup, Ask tiles | Names of the datasets the statement read | | `ms` | All data endpoints | Time the query took, in milliseconds | | `engine` | Exports, Ask tiles | `postgres` or `duckdb`. See [which engine ran](#which-engine-ran). | ## Follow a receipt to its source 1. Take a name from `sources`, for example `medicare_service`. 2. Find it in [`GET /api/meta`](https://openpipe.health/docs/api/meta.md#list-datasets). That gives you the publisher, the file version and the URL the file was downloaded from. 3. Read the `sql` against the [Tables](https://openpipe.health/docs/data/tables.md) page to see which columns and filters produced the number. ```sh curl "$OPH_API/api/providers?hcpcs=27447&state=TX&limit=3" \ -H "Authorization: Bearer $OPH_KEY" | jq '{sql, params, sources}' ``` ```json { "sql": "SELECT s.npi,\n trim(coalesce(m.first_name || ' ', '') || m.last_org_name) AS name, ...", "params": ["27447", "TX"], "sources": ["medicare_service", "medicare_provider"] } ``` Search statements use numbered placeholders; `params` holds the values in order. ## Get every row behind a receipt A receipt comes with a page of rows or a tile of at most 100. For all of them, ask for an [export](https://openpipe.health/docs/api/exports.md) by reference: the filters of the search, or the dashboard id and tile index of an answer. The server runs the same statement without the page limit and writes a CSV. ## Which engine ran The same tables are held in two engines. Postgres answers indexed lookups in about a millisecond. DuckDB, reading a columnar copy of the same data, is much faster at scanning tens of millions of rows. For each statement the model writes, the API asks Postgres for its cost estimate, without running anything. Cheap plans stay on Postgres. Plans over a cost threshold (10,000 by default) go to DuckDB, and so does anything that reads a table held only in the columnar store, such as `partd_drug`. If DuckDB is unavailable or rejects valid Postgres syntax, the statement runs on Postgres. `engine` tells you which one answered. Both hold the same rows, so results match. ## How model-written SQL is checked A statement planned for an Ask tile is treated as untrusted. Before it runs: - It must be one statement that starts with `SELECT` or `WITH`, at most 8,000 characters. - Write and session keywords, functions that reach outside the query, system schemas and the account tables (workspaces, keys, usage, dashboards, profiles, exports) are rejected wherever they appear. - It runs as a database login that can only `SELECT` the data tables, inside a read-only transaction, with a 5-second limit and a row cap. A statement that fails any of these becomes a failed tile. The same checks run again every time a stored dashboard is refreshed or one of its tiles is exported. --- # Providers URL: https://openpipe.health/docs/api/providers/ Markdown: https://openpipe.health/docs/api/providers.md > Search clinicians and organizations that bill Medicare, and fetch a full profile by NPI. ## Search providers ```http GET /api/providers ``` Returns clinicians and organizations that billed Medicare Part B. Costs 1 credit. The endpoint has two modes. With `hcpcs` it ranks by volume of that one procedure. Without it, it ranks by total Medicare activity. ### Parameters | Name | Type | Description | |---|---|---| | `hcpcs` | string | HCPCS/CPT code, for example `27447`. Switches to procedure mode. Find codes with [Procedures](https://openpipe.health/docs/api/procedures.md). | | `state` | string | Two-letter state code. Case-insensitive. | | `city` | string | City name. Case-insensitive, whole-name match. | | `specialty` | string | Substring of the Medicare specialty, for example `ortho`. | | `q` | string | Substring of the clinician or organization name. | | `entity` | string | `I` for individuals, `O` for organizations. Ignored in procedure mode. | | `min_services` | number | Minimum services. In procedure mode, minimum services of that procedure. | | `sort` | string | `payment` (default), `services` or `patients`. Ignored in procedure mode, which always sorts by services. | | `limit` | number | 1 to 200. Default 25. | | `offset` | number | Rows to skip. Default 0. | ### Example ```sh curl "$OPH_API/api/providers?state=CO&specialty=cardiology&sort=patients&limit=2" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "npi": "1234567893", "name": "Jane Example", "credentials": "MD", "entity_type": "I", "specialty": "Cardiology", "city": "Denver", "state": "CO", "zip5": "80218", "patients": 2841, "services": 11920, "medicare_payment": "612440" } ], "sql": "SELECT m.npi, ... FROM medicare_provider m WHERE m.state = $1 AND m.provider_type ILIKE $2 ORDER BY m.tot_benes DESC NULLS LAST LIMIT 2 OFFSET 0", "params": ["CO", "%cardiology%"], "sources": ["medicare_provider"], "ms": 3, "usage": { "credits": 1, "creditsUsed": 7, "creditsLimit": 100, "txid": "81245" } } ``` In procedure mode each row has `hcpcs_code`, `services`, `patients` and `medicare_payment` for that procedure, and no `entity_type` or `zip5`. Some numbers arrive as JSON strings, because they are 64-bit integers or exact decimals in the database: `npi` always, `medicare_payment` (rounded to whole dollars) always, and `patients` in procedure mode, where it is a sum. Parse them before doing arithmetic, and keep `npi` as a string. ## Get a provider ```http GET /api/providers/:npi ``` Returns everything known about one NPI. Costs 1 credit, charged only if the provider exists. `:npi` must be 10 digits, otherwise the call returns `400` with `NPI must be 10 digits.` ### Response | Field | Contents | |---|---| | `registry` | The NPI registry record: name, credentials, specialty, subspecialty, taxonomy code, address, phone, enumeration date. `null` if the NPI is not in the registry. | | `medicare` | Medicare Part B totals, one object per data year, newest first: patients, services, charges, payment, drug and medical payment split, average patient age and risk score. | | `procedures` | Top 15 procedures by service count, with description, place of service (`F` facility, `O` office) and average payment. | | `groups` | Up to 10 group practices the clinician belongs to, largest first. | | `drugs` | Top 15 Part D drugs prescribed, by claims. | | `payments` | Top 15 industry payers from Open Payments, by total amount. | | `sql` | An object with the six statements, keyed `registry`, `medicare`, `procedures`, `groups`, `drugs`, `payments`. | | `sources` | The eight datasets read. | ```sh curl "$OPH_API/api/providers/1234567893" -H "Authorization: Bearer $OPH_KEY" ``` A provider that is in the registry but never billed Medicare returns `registry` with empty arrays elsewhere. An NPI in neither returns `404`. The hospitals a clinician works at are under [`GET /api/providers/:npi/facilities`](https://openpipe.health/docs/api/hospital-intel.md#list-a-clinicians-facilities), and their trials and NIH grants under [`GET /api/market/experts/:npi`](https://openpipe.health/docs/api/experts.md#get-an-expert). --- # Facilities URL: https://openpipe.health/docs/api/facilities/ Markdown: https://openpipe.health/docs/api/facilities.md > Search hospitals by size, ownership and location, and fetch one hospital with its owners. ## 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. --- # Hospitals and systems URL: https://openpipe.health/docs/api/hospital-intel/ Markdown: https://openpipe.health/docs/api/hospital-intel.md > Search hospitals by EHR vendor, star rating, health system and DRG volume, and fetch one hospital's quality scorecard, EHR, clinicians, measures and Medicare inpatient volume. These endpoints add account research to the hospitals on [Facilities](https://openpipe.health/docs/api/facilities.md): the CMS quality scorecard, the EHR each hospital attested to, the health system it reports to, its Medicare inpatient volume by MS-DRG, and the clinicians affiliated with it. Cost-report financials and owners stay on [`GET /api/facilities/:ccn`](https://openpipe.health/docs/api/facilities.md#get-a-facility). Every endpoint on this page costs 1 credit, charged only when the call succeeds. A `400` or a `404` is free. The two searches and the clinician, measure and DRG lists reject a query parameter they do not know with `400`: ```json { "error": "Invalid request. Unrecognized key: \"foo\"." } ``` Text filters are substring matches that ignore case, 1 to 120 characters. `%` and `_` are matched literally. ## Search hospitals by EHR, rating, system or DRG ```http GET /api/hospital-intel ``` Returns hospitals with their EHR, star rating and health system on one row. Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `q` | string | Substring of the hospital name. | | `state` | string | Two-letter state code. Case-insensitive. | | `ehr` | string | Substring of the primary EHR vendor, for example `epic`, `oracle` or `meditech`. | | `ehr_changed` | string | `true` for hospitals whose primary EHR vendor changed between program years 2023 and 2024, `false` for those where it did not. | | `uses_product` | string | Substring of any certified health IT product or developer on the hospital's latest attestation. | | `system` | string | Substring of the health system name. | | `system_id` | string | Exact health system id from [`GET /api/health-systems`](#search-health-systems). Up to 160 characters. | | `min_rating` | number | Minimum CMS overall star rating, 1 to 5. Must not be greater than `max_rating`. | | `max_rating` | number | Maximum CMS overall star rating, 1 to 5. | | `hospital_type` | string | Substring of the Care Compare hospital type, for example `critical access`. | | `min_beds` | number | Minimum bed count, 0 to 100,000. | | `drg` | string | A 1 to 3 digit MS-DRG code, for example `470`. Keeps only hospitals that report this DRG and adds its Medicare discharges to each row. `3` and `003` are the same DRG. | | `min_discharges` | number | Minimum Medicare discharges in `drg`, 0 to 1,000,000. Needs `drg`: without it the request is a `400`. | | `sort` | string | `beds` (default), `revenue`, `rating` or `discharges`. Always descending. `discharges` needs `drg`: without it the request is a `400`. | | `limit` | number | 1 to 200. Default 25. | | `offset` | number | Rows to skip, 0 to 100,000. Default 0. | ### Example ```sh curl "$OPH_API/api/hospital-intel?state=TX&ehr=epic&min_rating=4&limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "ccn": "450358", "name": "HOUSTON METHODIST HOSPITAL", "city": "HOUSTON", "state": "TX", "beds": 1000, "net_patient_revenue": "3100740283", "hospital_type": "Acute Care Hospitals", "overall_rating": 5, "hcahps_star": 4, "ehr_vendor": "Epic", "ehr_product": "EpicCare Inpatient Base", "ehr_year": 2024, "ehr_vendor_changed": false, "ehr_previous_vendor": "Epic", "system_id": "HO9828", "system_name": "THE METHODIST HOSPITAL- CORPORATE DI" } ], "sql": "SELECT h.ccn, h.name, ... FROM hospitals h LEFT JOIN hospital_quality q ON q.ccn = h.ccn LEFT JOIN hospital_ehr e ON e.ccn = h.ccn LEFT JOIN hospital_systems s ON s.ccn = h.ccn WHERE h.state = $1 AND e.vendor ILIKE $2 AND q.overall_rating >= $3 ORDER BY h.beds DESC NULLS LAST, h.ccn LIMIT 1 OFFSET 0", "params": ["TX", "%epic%", 4], "sources": ["hospitals", "hospital_quality", "hospital_ehr", "hospital_systems"], "ms": 38, "usage": { "credits": 1, "creditsUsed": 1659, "creditsLimit": 5000, "txid": "11165" } } ``` With `drg`, each row also has `drg_code`, `drg_discharges` and `drg_avg_medicare_payment`. For `drg=470&state=TX&sort=discharges` the first row ends: ```json "drg_code": "470", "drg_discharges": 409, "drg_avg_medicare_payment": "9843" ``` Things to know: - The search reads the 9,326 hospitals in [`hospitals`](https://openpipe.health/docs/data/tables.md#hospitals). EHR, rating and system columns are `null` where that hospital has no row in the matching table. A `null` EHR means unknown. - A filter on EHR, rating, hospital type or system drops every hospital with no value for it. - `net_patient_revenue` and `drg_avg_medicare_payment` arrive as JSON strings, rounded to whole dollars. - `sql` is the statement the server ran, as a read-only [receipt](https://openpipe.health/docs/receipts.md). ## Search health systems ```http GET /api/health-systems ``` Returns health systems with their size, home office, the EHR most of their hospitals run and their average star rating. Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `q` | string | Substring of the system name. | | `state` | string | Two-letter code of the home office state. | | `min_hospitals` | number | Minimum number of hospitals, 1 to 10,000. | | `sort` | string | `hospitals` (default), `beds` or `revenue`. Always descending. | | `limit` | number | 1 to 200. Default 25. | | `offset` | number | Rows to skip, 0 to 100,000. Default 0. | ### Example ```sh curl "$OPH_API/api/health-systems?state=TX&min_hospitals=5&limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "system_id": "HB0557", "system_name": "TENET HEALTHCARE CORPORATION", "hospitals": 47, "home_office_city": "DALLAS", "home_office_state": "TX", "beds": 11306, "net_patient_revenue": "14060057290", "top_ehr_vendor": "Oracle Health (Cerner)", "avg_overall_rating": "2.19" } ], "sql": "SELECT s.system_id, s.system_name, count(*)::int AS hospitals, ... FROM hospital_systems s LEFT JOIN hospitals h ON h.ccn = s.ccn ... GROUP BY s.system_id, s.system_name HAVING mode() WITHIN GROUP (ORDER BY s.home_office_state) = $1 AND count(*) >= $2 ORDER BY hospitals DESC NULLS LAST, s.system_id LIMIT 1 OFFSET 0", "params": ["TX", 5], "sources": ["hospital_systems", "hospitals", "hospital_ehr", "hospital_quality"], "ms": 60, "usage": { "credits": 1, "creditsUsed": 1661, "creditsLimit": 5000, "txid": "11169" } } ``` `top_ehr_vendor` is the most common vendor among the system's hospitals that have EHR data. `avg_overall_rating` averages only the hospitals that have a star rating. Both are `null` when no hospital in the system has a value. Systems are derived, not published. See [Health systems are derived](#health-systems-are-derived) before you store a `system_id`. ## Get a health system ```http GET /api/health-systems/:id ``` Returns one system and its hospitals. Costs 1 credit, charged only if the system exists. `:id` is a `system_id` exactly as a search returned it, up to 160 characters. Some ids start with `N:` followed by a name, so URL-encode the id. ### Response | Field | Contents | |---|---| | `system_id` | The id you sent. | | `system` | Name, number of hospitals, home office city and state, total beds and total net patient revenue. | | `ehr_vendors` | Primary EHR vendors across the system's hospitals, with the number of hospitals on each, most common first. | | `hospitals` | Up to 500 hospitals, most beds first: CCN, name, city, state, beds, net patient revenue, overall star rating, EHR vendor, and `reported_name`, the home office name as that hospital typed it. | | `sql` | The three statements, keyed `system`, `ehr_vendors` and `hospitals`. | | `sources` | `hospital_systems`, `hospitals`, `hospital_quality`, `hospital_ehr`. | ```sh curl "$OPH_API/api/health-systems/HO9828" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "system_id": "HO9828", "system": { "system_id": "HO9828", "system_name": "THE METHODIST HOSPITAL- CORPORATE DI", "hospitals": 8, "home_office_city": "HOUSTON", "home_office_state": "TX", "beds": 2822, "net_patient_revenue": "7027192220" }, "ehr_vendors": [{ "vendor": "Epic", "hospitals": 7 }], "hospitals": [ { "ccn": "450358", "name": "HOUSTON METHODIST HOSPITAL", "city": "HOUSTON", "state": "TX", "beds": 1000, "net_patient_revenue": "3100740283", "overall_rating": 5, "ehr_vendor": "Epic", "reported_name": "THE METHODIST HOSPITAL- CORPORATE DI" } ], "sql": { "system": "SELECT s.system_id, ...", "ehr_vendors": "SELECT e.vendor, ...", "hospitals": "SELECT s.ccn, h.name, ..." }, "sources": ["hospital_systems", "hospitals", "hospital_quality", "hospital_ehr"], "ms": 162, "usage": { "credits": 1, "creditsUsed": 1672, "creditsLimit": 5000, "txid": "11192" } } ``` An unknown id returns `404` with `No health system with that id.` ## Get hospital intel ```http GET /api/facilities/:ccn/intel ``` Returns the account-level picture of one hospital: quality scorecard, EHR, health system, top DRGs and affiliated clinicians. Costs 1 credit, charged only if the hospital exists. A CCN shorter than six characters is left-padded with zeros. A CCN that is not 1 to 6 letters or digits returns `400` with `CCN must be up to 6 letters or digits.` ### Response | Field | Contents | |---|---| | `ccn` | The CCN, padded and upper-cased. | | `hospital` | CCN, name, city, state, beds and facility type from [`hospitals`](https://openpipe.health/docs/data/tables.md#hospitals). `null` for the Veterans Affairs and military hospitals that are in Care Compare only. | | `quality` | Every column of `hospital_quality`: hospital type, overall star rating, patient-survey stars and percentages, counts of measures better and worse than national, readmission and mortality rates, infection ratios, emergency department volume and wait, spending ratio. `null` if the hospital is not in Care Compare. | | `ehr` | Program year, primary vendor, developer, product, `basis`, product and developer counts, other vendors, previous vendor and `vendor_changed`. `null` means unknown. | | `ehr_products` | Up to 100 certified products on the same attestation, core EHR first. | | `system` | The health system: id, name, number of hospitals, the name as reported, home office and fiscal year end. `null` means independent or unknown. | | `top_drgs` | The 15 MS-DRGs with the most Medicare discharges, with average and total Medicare payment. | | `affiliated_clinicians` | Number of clinicians affiliated with the hospital. | | `clinician_specialties` | The 15 most common specialties among them, with counts. | | `sql` | The eight statements, keyed `hospital`, `quality`, `ehr`, `ehr_products`, `system`, `top_drgs`, `clinicians` and `clinician_specialties`. | | `sources` | The eight datasets read. | ```sh curl "$OPH_API/api/facilities/450358/intel" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "ccn": "450358", "hospital": { "ccn": "450358", "name": "HOUSTON METHODIST HOSPITAL", "city": "HOUSTON", "state": "TX", "beds": 1000, "facility_type": "STH" }, "quality": { "hospital_type": "Acute Care Hospitals", "overall_rating": 5, "hcahps_star": 4, "recommend_pct": 82, "readmission_rate": 15.2, "mortality_rate": 2.1, "ed_median_minutes": 160, "spending_ratio": 0.98 }, "ehr": { "year": 2024, "vendor": "Epic", "product": "EpicCare Inpatient Base", "basis": "core_product", "product_count": 5, "other_vendors": "SCC Soft Computer", "previous_vendor": "Epic", "vendor_changed": false }, "ehr_products": [ { "year": 2024, "vendor": "Epic", "developer": "Epic Systems Corporation", "product": "EpicCare Inpatient Base", "is_core_ehr": true, "listings": 1 } ], "system": { "system_id": "HO9828", "system_name": "THE METHODIST HOSPITAL- CORPORATE DI", "system_hospitals": 8 }, "top_drgs": [ { "drg_code": "871", "drg_description": "SEPTICEMIA OR SEVERE SEPSIS WITHOUT MV >96 HOURS WITH MCC", "discharges": 808, "avg_medicare_payment": "16752", "total_medicare_payment": "13535350" } ], "affiliated_clinicians": 2337, "clinician_specialties": [{ "specialty": "Internal Medicine", "clinicians": 828 }], "sql": { "hospital": "SELECT ccn, name, ... FROM hospitals WHERE ccn = $1", "quality": "SELECT * FROM hospital_quality WHERE ccn = $1" }, "sources": ["hospitals", "hospital_quality", "hospital_ehr", "hospital_ehr_products", "hospital_systems", "hospital_drgs", "clinician_facilities", "providers"], "ms": 931, "usage": { "credits": 1, "creditsUsed": 1673, "creditsLimit": 5000, "txid": "11194" } } ``` The example is trimmed: `quality`, `ehr` and `system` have more fields, the arrays have more rows, and `sql` has all eight statements. A CCN in neither `hospitals` nor Care Compare returns `404` with `No hospital with that CCN.` ## List a hospital's clinicians ```http GET /api/facilities/:ccn/clinicians ``` Returns the clinicians affiliated with one hospital, highest Medicare payment first. Costs 1 credit, charged only if the hospital exists. ### Parameters | Name | Type | Description | |---|---|---| | `specialty` | string | Substring of the registry specialty or the Medicare specialty, for example `cardio`. | | `limit` | number | 1 to 200. Default 25. | | `offset` | number | Rows to skip, 0 to 100,000. Default 0. | ### Example ```sh curl "$OPH_API/api/facilities/450358/clinicians?specialty=cardio&limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "ccn": "450358", "total": 184, "limit": 1, "offset": 0, "rows": [ { "npi": "1234567890", "name": "JANE EXAMPLE", "credentials": "M.D.", "specialty": "Internal Medicine", "medicare_specialty": "Interventional Cardiology", "city": "HOUSTON", "state": "TX", "facility_type": "Hospital", "medicare_patients": 1278, "medicare_payment": "2320325" } ], "sql": "SELECT f.npi, coalesce(p.name, ...) AS name, ... FROM clinician_facilities f LEFT JOIN providers p ON p.npi = f.npi LEFT JOIN medicare_provider m ON m.npi = f.npi WHERE f.ccn = $1 AND (p.specialty ILIKE $2 OR m.provider_type ILIKE $2) ORDER BY m.tot_payment DESC NULLS LAST, f.npi LIMIT 1 OFFSET 0", "params": ["450358", "%cardio%"], "sources": ["clinician_facilities", "providers", "medicare_provider"], "ms": 500, "usage": { "credits": 1, "creditsUsed": 1674, "creditsLimit": 5000, "txid": "11196" } } ``` `total` is the number of clinicians that match, before paging. `medicare_patients` and `medicare_payment` are the clinician's Medicare Part B totals for 2024 across every place they work, not their activity at this hospital. The list is a floor, not a staff roster. See [Affiliations come from claims](#affiliations-come-from-claims). A CCN with no hospital, Care Compare or affiliation record returns `404` with `No hospital or facility with that CCN.` ## List a hospital's quality measures ```http GET /api/facilities/:ccn/measures ``` Returns every Care Compare measure CMS scored for one hospital. Costs 1 credit, charged only if the hospital exists. ### Parameters | Name | Type | Description | |---|---|---| | `domain` | string | One of `mortality`, `safety`, `readmission`, `infection`, `timely_care`, `patient_experience` or `spending`. Omit for all. | There is no paging. A hospital has at most 113 measures and all of them come back, ordered by domain and measure id. ### Example ```sh curl "$OPH_API/api/facilities/450358/measures?domain=mortality" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "ccn": "450358", "rows": [ { "measure_id": "MORT_30_HF", "measure_name": "Death rate for heart failure patients", "domain": "mortality", "score": 6, "compared_to_national": null, "denominator": 1264, "period_start": "2022-07-01T00:00:00.000Z", "period_end": "2025-06-30T00:00:00.000Z" } ], "sql": "SELECT measure_id, measure_name, domain, score, compared_to_national, denominator, period_start, period_end FROM hospital_measures WHERE ccn = $1 AND domain = $2 ORDER BY domain, measure_id LIMIT 300", "params": ["450358", "mortality"], "sources": ["hospital_measures"], "ms": 35, "usage": { "credits": 1, "creditsUsed": 1675, "creditsLimit": 5000, "txid": "11198" } } ``` Things to know: - Scores are not on one scale. Rates, percentages, minutes, ratios and star ratings share the `score` column. Do not compare or average scores across different `measure_id` values. - A measure with no row was not scored for that hospital: too few cases, not reported or not applicable. Missing is not zero. - `compared_to_national` is published only for some measures. CMS left it blank for the mortality measures in this release. - Each measure has its own measurement period, in `period_start` and `period_end`. ## List a hospital's DRG volume ```http GET /api/facilities/:ccn/drgs ``` Returns Medicare inpatient discharges and payments for one hospital by MS-DRG, most discharges first. Costs 1 credit, charged only if the hospital exists. ### Parameters | Name | Type | Description | |---|---|---| | `limit` | number | 1 to 200. Default 25. | | `offset` | number | Rows to skip, 0 to 100,000. Default 0. | ### Example ```sh curl "$OPH_API/api/facilities/450358/drgs?limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "ccn": "450358", "total": 227, "total_discharges": 10386, "limit": 1, "offset": 0, "rows": [ { "drg_code": "871", "drg_description": "SEPTICEMIA OR SEVERE SEPSIS WITHOUT MV >96 HOURS WITH MCC", "year": 2024, "discharges": 808, "avg_covered_charges": "156750", "avg_total_payment": "22289", "avg_medicare_payment": "16752", "total_medicare_payment": "13535350" } ], "sql": "SELECT drg_code, drg_description, year, discharges, ... FROM hospital_drgs WHERE ccn = $1 ORDER BY discharges DESC, drg_code LIMIT 1 OFFSET 0", "params": ["450358"], "sources": ["hospital_drgs"], "ms": 23, "usage": { "credits": 1, "creditsUsed": 1676, "creditsLimit": 5000, "txid": "11200" } } ``` `total` is the number of DRGs published for the hospital and `total_discharges` is their sum. Both leave out every DRG with fewer than 11 discharges, so `total_discharges` is lower than the hospital's real Medicare discharge count. A hospital with no DRG data returns an empty `rows` and is still charged. Payments are averages per discharge. `total_medicare_payment` is the average Medicare payment multiplied by discharges. Charges are list prices, far above what is paid. ## List a clinician's facilities ```http GET /api/providers/:npi/facilities ``` Returns the hospitals and other facilities one clinician is affiliated with, hospitals first, each with beds, star rating, EHR vendor and health system. Costs 1 credit, charged only if the provider exists. `:npi` must be 10 digits, otherwise the call returns `400` with `NPI must be 10 digits.` There are no query parameters. At most 200 rows come back. ### Example ```sh curl "$OPH_API/api/providers/1234567890/facilities" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "npi": 1234567890, "rows": [ { "ccn": "450358", "facility_type": "Hospital", "parent_ccn": null, "name": "HOUSTON METHODIST HOSPITAL", "city": "HOUSTON", "state": "TX", "beds": 1000, "overall_rating": 5, "ehr_vendor": "Epic", "system_id": "HO9828", "system_name": "THE METHODIST HOSPITAL- CORPORATE DI" } ], "sql": "SELECT f.ccn, f.facility_type, f.parent_ccn, coalesce(h.name, fa.name) AS name, ... FROM clinician_facilities f LEFT JOIN hospitals h ON h.ccn = f.ccn LEFT JOIN facilities fa ON fa.facility_id = f.ccn ... WHERE f.npi = $1 ORDER BY (f.facility_type = 'Hospital') DESC, h.beds DESC NULLS LAST, f.ccn LIMIT 200", "params": [1234567890], "sources": ["clinician_facilities", "hospitals", "facilities", "hospital_quality", "hospital_ehr", "hospital_systems"], "ms": 32, "usage": { "credits": 1, "creditsUsed": 1679, "creditsLimit": 5000, "txid": "11206" } } ``` Things to know: - A provider in the registry with no published affiliation returns an empty `rows` and is charged. An empty list means none were published, not that the clinician works nowhere. An NPI that is not in the registry and has no affiliation returns `404`. - Name, city, state and beds come from `hospitals` for hospital rows and from `facilities` for nursing homes, home health agencies, hospices and dialysis facilities (about one nursing home row in ten has no match and stays `null`). Rating, EHR and system exist for hospitals only. For the full record of a non-hospital row, pass its `ccn` to [`GET /api/care-sites/:id`](https://openpipe.health/docs/api/care-sites.md#get-a-care-site). - The top-level `npi` is a JSON number here. ## Caveats ### Volumes are Medicare fee-for-service only DRG discharges and payments, and the clinicians' `medicare_patients` and `medicare_payment`, come from traditional Medicare claims. Commercial insurance, Medicare Advantage, Medicaid and self-pay are not counted. Use the figures to rank and compare, not as totals. DRG data is calendar year 2024. It covers about 2,900 hospitals paid under the inpatient prospective payment system. Critical access hospitals and Maryland hospitals are not included. CMS leaves out any hospital and DRG with fewer than 11 discharges. ### EHR data is a 2024 attestation `ehr` and `ehr_products` are what each hospital attested to CMS for the Medicare Promoting Interoperability program, decoded by ONC against its certified product list and published in January 2026. - The program year is 2024 for most hospitals and 2023 where 2024 is missing. A go-live since 2024 is not reflected. - About 4,200 hospitals are covered, which is 85% of acute care hospitals. Psychiatric, rehabilitation, long-term, children's and federal hospitals are mostly absent. No row means unknown, not "no EHR". - `vendor` is the developer of the core inpatient EHR product (`basis` is `core_product` on 97% of rows). About 50 hospitals attest core products from two developers (`multiple_core_products`) and about 50 have no recognisable core product (`most_products`). Treat both as uncertain. - `vendor_changed` compares program years 2023 and 2024. It is `null` unless `basis` is `core_product` in both years. A hospital that attests under a new parent system's ID can show as changed. - Only ONC-certified products are listed. Most revenue-cycle, ERP, imaging and analytics software never appears, so `ehr_products` is not a full technology stack. ### Quality data is the November 2026 Care Compare release Each figure has its own measurement period. Most are 2024 or 2025. Readmission and mortality cover July 2024 to June 2025. `null` means CMS published no value: too few cases, not reported, or not applicable to that hospital type. About 40% of hospitals have no overall star rating, mostly critical access, psychiatric and federal hospitals. Care Compare includes about 170 Veterans Affairs and Department of Defense hospitals that are not in `hospitals`. They do not appear in `GET /api/hospital-intel`, and `GET /api/facilities/:ccn/intel` returns them with `hospital` set to `null`. ### Health systems are derived CMS does not publish a list of health systems. A system here is the home office a hospital names on its Medicare cost report for fiscal year 2024. - Hospitals that report no chain, or filed no 2024 cost report, have no system. No system means independent or unknown. - Each hospital types the name itself, so `system_id` and `system_name` are resolved from the home office number and the name spellings. A few systems are split, for example a regional division that reports its own home office, and their hospital counts are low. - The home office is the legal or operating parent as reported to Medicare. It can differ from the consumer brand. - `system_id` is a CMS home office number where one was reported, otherwise `N:` followed by the cleaned name. It is stable only within one load of the data. Do not store it as a permanent key. - Physician groups, clinics and other non-hospital sites of a system are not included. ### Affiliations come from claims Clinician affiliations are from the CMS Doctors and Clinicians release of November 2026. CMS lists a facility for a clinician when the clinician billed Medicare for services to patients there in recent months. - It shows where a clinician practices. It is not employment, admitting privileges or a medical-staff roster. - CMS publishes at most five hospitals per clinician, so the busiest multi-hospital clinicians are cut short. - Clinicians who see no Medicare patients, and most residents, are absent. --- # Care sites URL: https://openpipe.health/docs/api/care-sites/ Markdown: https://openpipe.health/docs/api/care-sites.md > Search nursing homes, home health agencies, hospices, dialysis facilities, surgery centers, clinics and other non-hospital sites, and fetch one site with its detail and owners. A care site is a facility that is not an acute-care hospital: a nursing home, home health agency, hospice, dialysis facility, ambulatory surgery center, rehabilitation or long-term care hospital, clinic, or one of the smaller certified types. There are 94,745 of them. Acute-care hospitals are on [Facilities](https://openpipe.health/docs/api/facilities.md). Every endpoint on this page costs 1 credit, charged only when the call succeeds. A `400` or a `404` is free. The search and the owners list reject a query parameter they do not know with `400`: ```json { "error": "Unknown parameter: foo." } ``` ## Search care sites ```http GET /api/care-sites ``` Returns care sites, highest Medicare payment first unless `sort` says otherwise. Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `type` | string | One or more [facility types](#facility-types), comma-separated, for example `nursing_home,hospice`. Omit for all types. | | `q` | string | Substring of the facility name or its legal name. 1 to 80 characters. | | `state` | string | Two-letter state code. Case-insensitive. | | `city` | string | City name. Case-insensitive, whole-name match. 1 to 80 characters. | | `zip` | string | Five-digit ZIP code. | | `chain` | string | Substring of the chain or affiliated-entity name. 1 to 80 characters. | | `npi` | string | The facility's own 10-digit organization NPI. | | `ownership` | string | `for_profit`, `non_profit`, `government` or `other`. | | `min_beds` | number | Minimum bed count, 0 to 100,000. | | `min_stars` | number | Minimum CMS star rating, 1 to 5. Half stars are allowed, for example `3.5`. | | `min_patients` | number | Minimum Medicare patients, 0 to 10,000,000. | | `private_equity` | string | `true` for sites with a private-equity owner, `false` for sites disclosed as having none. | | `reit` | string | `true` for sites with a real-estate investment trust owner, `false` for sites disclosed as having none. | | `changed_ownership_since` | string | A date as `YYYY-MM-DD`. Keeps sites whose ownership changed on or after it. | | `sort` | string | `payment` (default), `patients`, `beds`, `stars`, `census`, `stations`, `operating_rooms`, `newest` or `name`. All descending except `name`. `newest` is by certification date. | | `limit` | number | 1 to 200. Default 25. | | `offset` | number | Rows to skip, 0 to 10,000. Default 0. | ### Facility types | `type` | Sites | Detail table | |---|---|---| | `health_center_site` | 18,389 | `health_center_sites` | | `nursing_home` | 14,697 | `nursing_homes` | | `fqhc` | 13,049 | none | | `home_health_agency` | 12,589 | `home_health_agencies` | | `dialysis_facility` | 7,537 | `dialysis_facilities` | | `ambulatory_surgery_center` | 6,710 | `surgery_centers` | | `hospice` | 6,327 | `hospices` | | `rural_health_clinic` | 5,816 | none | | `intermediate_care_facility_iid` | 5,196 | none | | `outpatient_therapy_provider` | 1,664 | none | | `inpatient_rehab_facility` | 1,222 | none | | `portable_xray_supplier` | 531 | none | | `psychiatric_residential_treatment_facility` | 390 | none | | `long_term_care_hospital` | 311 | none | | `outpatient_rehab_facility` | 137 | none | | `community_mental_health_center` | 126 | none | | `organ_procurement_organization` | 54 | none | Counts are a snapshot from 5 December 2026. [`GET /api/care-sites/types`](#list-care-site-types) has the current ones. ### Example ```sh curl "$OPH_API/api/care-sites?type=nursing_home&private_equity=true&min_beds=100&limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "facility_id": "555287", "facility_type": "nursing_home", "name": "DIAMOND RIDGE HEALTHCARE CENTER", "city": "PITTSBURG", "state": "CA", "zip5": "94565", "npi": "1447821467", "ownership_type": "for_profit", "beds": 120, "star_rating": 3, "avg_daily_census": 113.1, "medicare_patients": 167, "medicare_payment": 9036059, "certified_date": "1987-10-02T00:00:00.000Z", "ownership_change_date": "2021-07-01T00:00:00.000Z", "has_private_equity_owner": true, "has_reit_owner": false, "top_owner": "DIAMOND RIDGE POST ACUTE LLC" } ], "limit": 1, "offset": 0, "sql": "SELECT facility_id, facility_type, name, ... FROM facilities WHERE facility_type = ANY($1::text[]) AND beds >= $2 AND has_private_equity_owner = $3 ORDER BY medicare_payment DESC NULLS LAST, facility_id LIMIT 1 OFFSET 0", "params": [["nursing_home"], 100, true], "sources": ["facilities"], "ms": 25, "usage": { "credits": 1, "creditsUsed": 1671, "creditsLimit": 5000, "txid": "11190" } } ``` Each row also has `phone`, `chain_name`, `stations` and `operating_rooms`. `sql` is the statement the server ran, as a read-only [receipt](https://openpipe.health/docs/receipts.md). Things to know: - A search that matches nothing returns an empty `rows` and is still charged. - Columns that do not apply to a type are `null`: `beds` for a hospice, `stations` for anything but dialysis, `operating_rooms` for anything but a surgery center. - A filter on a column drops every site where that column is `null`. `private_equity=false` returns only the types that have owner data. - `star_rating` means something different per type. Compare within one type only. See [Caveats](#caveats). ## List care site types ```http GET /api/care-sites/types ``` Returns the 17 facility types with national counts. Costs 1 credit. It takes no parameters. ```sh curl "$OPH_API/api/care-sites/types" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "facility_type": "nursing_home", "facilities": 14697, "states": 53, "beds": "1567140", "medicare_patients": "1300290", "medicare_payment": "25206526112", "detail_table": "nursing_homes" }, { "facility_type": "fqhc", "facilities": 13049, "states": 55, "beds": null, "medicare_patients": null, "medicare_payment": null, "detail_table": null } ], "sql": "SELECT facility_type, count(*)::int AS facilities, count(DISTINCT state)::int AS states, sum(beds)::bigint AS beds, ... FROM facilities GROUP BY facility_type ORDER BY facilities DESC", "params": [], "sources": ["facilities"], "ms": 150, "usage": { "credits": 1, "creditsUsed": 1663, "creditsLimit": 5000, "txid": "11173" } } ``` `states` counts distinct state codes, which include DC and the territories. `detail_table` names the table that holds the type's extra columns, or `null` when it has none. The sums arrive as JSON strings. A `null` sum means no site of that type has a published figure. ## Get a care site ```http GET /api/care-sites/:id ``` Returns one care site with its type-specific detail and its top owners. Costs 1 credit, charged only if the site exists. `:id` is a `facility_id` from a search: - A CMS Certification Number: six characters, or ten for surgery centers and portable X-ray suppliers. - For `health_center_site`, the HRSA site number, for example `BPS-H80-015078`. The id is upper-cased. A five-digit number is left-padded with a zero, so `15009` and `015009` are the same site. An id that is not 5 to 20 letters, digits and hyphens returns `400`: ```json { "error": "Facility id must be a CCN (for example 335020) or an HRSA site number (for example BPS-H80-015078)." } ``` ### Response | Field | Contents | |---|---| | `facility_id` | The id, normalized. | | `facility` | Every column of the [`facilities`](https://openpipe.health/docs/data/tables.md#facilities) table: type, names, address, county, phone, NPI, ownership, chain, beds, star rating, census, Medicare patients, days and payment, certification and ownership-change dates, coordinates and the owner summary. | | `detail_table` | The table `detail` came from, or `null` for a type that has none. | | `detail` | Every column of that table for this site. For a nursing home: rating components, occupancy, nurse staffing and turnover, inspection results and penalties. `null` if the type has no detail table or the site has no row in it. | | `owners` | Up to 25 owners and managing parties, largest stake first. The fields are those of [the owners list](#list-a-care-sites-owners). | | `hospital` | For an inpatient rehab facility or long-term care hospital, its row in `hospitals`: CCN, name, city, state, beds, discharges, net patient revenue, fiscal year end. `null` otherwise. | | `health_center_sites` | Only for an `fqhc`: up to 25 HRSA health center sites that bill under its number. | | `sql` | The statements that ran, keyed `facility`, `owners`, and `detail`, `hospital` and `health_center_sites` when they apply. | | `sources` | The datasets read. | ```sh curl "$OPH_API/api/care-sites/555287" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "facility_id": "555287", "facility": { "facility_id": "555287", "facility_type": "nursing_home", "name": "DIAMOND RIDGE HEALTHCARE CENTER", "legal_name": "DIAMOND RIDGE POST ACUTE LLC", "city": "PITTSBURG", "state": "CA", "county_fips": "06013", "ownership_type": "for_profit", "ownership_detail": "For profit - Limited Liability company", "beds": 120, "star_rating": 3, "medicare_patients": 167, "medicare_service_days": 8824, "medicare_payment": 9036059, "owner_count": 22, "has_private_equity_owner": true, "top_owner": "DIAMOND RIDGE POST ACUTE LLC" }, "detail_table": "nursing_homes", "detail": { "overall_rating": 3, "staffing_rating": 4, "occupancy_pct": 94.3, "total_nurse_hours_per_resident_day": 4.37721, "health_deficiencies": 12, "chain_facilities": 50 }, "owners": [ { "owner_name": "DIAMOND RIDGE POST ACUTE LLC", "owner_type": "O", "role": "5% OR GREATER DIRECT OWNERSHIP INTEREST", "pct_ownership": 100, "is_private_equity": false, "source": "pecos" } ], "hospital": null, "sql": { "facility": "SELECT * FROM facilities WHERE facility_id = $1", "owners": "SELECT owner_name, ...", "detail": "SELECT * FROM nursing_homes WHERE facility_id = $1" }, "sources": ["facilities", "facility_owners", "nursing_homes"], "ms": 51, "usage": { "credits": 1, "creditsUsed": 1680, "creditsLimit": 5000, "txid": "11208" } } ``` The example is trimmed: `facility`, `detail` and each owner have more fields, and this site has 22 owner rows. An unknown id returns `404`. The message names the id and adds `Hospitals are under /api/facilities.` ## List a care site's owners ```http GET /api/care-sites/:id/owners ``` Returns every owner and managing party a care site disclosed to CMS, largest stake first. Costs 1 credit, charged only if the site exists. ### Parameters | Name | Type | Description | |---|---|---| | `equity_only` | string | `true` to keep only parties with an ownership percentage above zero. | | `limit` | number | 1 to 200. Default 50. | | `offset` | number | Rows to skip, 0 to 10,000. Default 0. | ### Example ```sh curl "$OPH_API/api/care-sites/555287/owners?equity_only=true&limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "facility": { "facility_id": "555287", "facility_type": "nursing_home", "name": "DIAMOND RIDGE HEALTHCARE CENTER", "city": "PITTSBURG", "state": "CA" }, "total": 22, "with_equity": 4, "rows": [ { "owner_name": "DIAMOND RIDGE POST ACUTE LLC", "owner_type": "O", "owner_associate_id": "0244629038", "role": "5% OR GREATER DIRECT OWNERSHIP INTEREST", "title": null, "association_date": "2022-02-03T00:00:00.000Z", "pct_ownership": 100, "is_private_equity": false, "is_reit": false, "is_holding_company": false, "is_management_company": false, "is_chain_home_office": false, "is_for_profit": false, "source": "pecos" } ], "limit": 1, "offset": 0, "sql": "SELECT owner_name, owner_type, owner_associate_id, role, ... FROM facility_owners WHERE facility_id = $1 AND pct_ownership > 0 ORDER BY pct_ownership DESC NULLS LAST, owner_name, id LIMIT 1 OFFSET 0", "params": ["555287"], "sources": ["facilities", "facility_owners"], "ms": 43, "usage": { "credits": 1, "creditsUsed": 1681, "creditsLimit": 5000, "txid": "11210" } } ``` `total` counts every owner row for the site and `with_equity` those with a percentage above zero. Neither changes with `equity_only`, so page against `with_equity` when you set it. `owner_type` is `I` for an individual and `O` for an organization. The same party appears once per role, so a person can have several rows. A site of a type with no owner data returns an empty `rows` with `total` 0, and is charged. ## Caveats ### Acute-care hospitals are not here They are in `hospitals`, on [Facilities](https://openpipe.health/docs/api/facilities.md) and [Hospitals and systems](https://openpipe.health/docs/api/hospital-intel.md). Inpatient rehab facilities and long-term care hospitals appear in both: `hospital_ccn` on the care site points at the hospital row. ### Health center sites and FQHCs overlap HRSA health center sites and CMS-certified FQHCs are two registries of largely the same clinics. A `health_center_site` carries the id of its `fqhc` row in `fqhc_facility_id` when HRSA publishes it, which is about 40% of the time. Count one type or the other, not both. ### Volumes are Medicare fee-for-service only `medicare_patients`, `medicare_service_days` and `medicare_payment` are traditional Medicare, calendar year 2024. Commercial insurance, Medicare Advantage, Medicaid and self-pay are not counted. - Nursing homes: Part A stays, which are short rehab stays, not long-term residents. - Home health and hospice: episodes. - Surgery centers: Part B facility claims billed under the site's NPI. - An inpatient rehab unit carries the figures of its whole unit, reported under the parent hospital. `null` means no published figure, not zero. The types with no figure at all are `null` in [the types list](#list-care-site-types). ### Owner flags are self-reported Owners come from the ownership disclosures facilities file with CMS. - The private-equity, REIT, holding-company and management-company flags are the filer's own answers. CMS has said the reporting is incomplete. A `false` or `null` flag does not prove the absence of such an owner. - Owner data exists only for nursing homes, home health agencies, hospices, FQHCs and rural health clinics. Dialysis facilities, surgery centers and the other types have none, and their owner columns are `null`. - Most rows are directors, officers and managing employees with a 0% or blank share. Use `equity_only=true` to find equity owners. - About 4% of rows have no owner name in the source and read `UNKNOWN`. - 166 Medicaid-only nursing homes have owners from the Care Compare ownership file (`source` is `care_compare`), which has no investor flags. ### Star ratings differ by type `star_rating` is the overall rating for a nursing home, the quality-of-patient-care rating for home health (half stars), the five-star rating for dialysis, and the family caregiver survey rating for a hospice. Other types have none. A third of home health agencies are too small or too new to have one, and only a third of hospices have enough survey responses for one. ### Release dates | Data | Release | |---|---| | Certification (the list of sites, beds, dates) | Provider of Services file, third quarter of 2026 | | Listings and ratings | Care Compare, September to November 2026 | | Nursing home detail | Care Compare, November 2026 | | Home health and dialysis detail | Care Compare, October 2026 | | Hospice detail | Care Compare, November 2026 | | Surgery center detail | Provider of Services file, third quarter of 2026. It is what each center reported at its last certification survey, which can be several years old. | | HRSA health center sites | 4 December 2026 | | Nursing home owners | 12 November 2026 | | Home health, hospice, FQHC and rural health clinic owners | 29 September 2026 | | Medicare patients, days and payment | Calendar year 2024 | A facility that Care Compare still lists but the Provider of Services file marks terminated is left out. A few certified sites are not on Care Compare and have no `detail`: 16 nursing homes, 388 home health agencies, 98 hospices and 88 dialysis facilities. --- # Groups URL: https://openpipe.health/docs/api/groups/ Markdown: https://openpipe.health/docs/api/groups.md > Search group practices and list their members. ## Search groups ```http GET /api/groups ``` Returns group practices, largest first. Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `q` | string | Substring of the group name. | | `state` | string | Two-letter state code. | | `min_members` | number | Minimum number of clinicians in the group. | | `specialty` | string | Substring of the group's most common specialty. | | `limit` | number | 1 to 200. Default 25. | | `offset` | number | Rows to skip. Default 0. | ### Example ```sh curl "$OPH_API/api/groups?state=OH&specialty=cardio&min_members=20" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "group_pac_id": "1234567890", "name": "EXAMPLE HEART PHYSICIANS INC", "state": "OH", "member_count": 148, "top_specialty": "Cardiovascular Disease (Cardiology)" } ], "sql": "SELECT group_pac_id, name, state, member_count, top_specialty FROM groups WHERE state = $1 AND member_count >= $2 AND top_specialty ILIKE $3 ORDER BY member_count DESC LIMIT 25 OFFSET 0", "params": ["OH", 20, "%cardio%"], "sources": ["groups"], "ms": 2, "usage": { "credits": 1, "creditsUsed": 9, "creditsLimit": 100, "txid": "81247" } } ``` ## Get a group ```http GET /api/groups/:id ``` `:id` is the `group_pac_id` from a search. Costs 1 credit, charged only if the group exists. ### Response | Field | Contents | |---|---| | `group` | The group record. | | `specialties` | Up to 20 specialties with the number of members in each. | | `members` | Up to 50 members ranked by Medicare payment: NPI, name, specialty, city, state, `tot_payment`. Members who did not bill Medicare have `null` name and payment. | | `sql` | The three statements, keyed `group`, `specialties`, `members`. | | `sources` | `groups`, `group_members`, `medicare_provider`. | Unknown ids return `404` with `No group with that id.` --- # Procedures URL: https://openpipe.health/docs/api/procedures/ Markdown: https://openpipe.health/docs/api/procedures.md > Look up HCPCS and CPT codes by code prefix or description. ## Search procedures ```http GET /api/procedures ``` Finds procedure codes, most-performed first. Use it to turn "knee replacement" into the code you pass to [`/api/providers?hcpcs=`](https://openpipe.health/docs/api/providers.md). Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `q` | string | Matches codes that start with it, or descriptions that contain it. | | `limit` | number | 1 to 100. Default 25. | ### Example ```sh curl "$OPH_API/api/procedures?q=knee&limit=2" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "code": "27447", "description": "Total knee arthroplasty", "is_drug": false, "providers": 9120, "tot_srvcs": 231400 } ], "sql": "SELECT code, description, is_drug, providers, tot_srvcs FROM hcpcs WHERE (code ILIKE $1 OR description ILIKE $2) ORDER BY tot_srvcs DESC NULLS LAST LIMIT 2", "params": ["knee%", "%knee%"], "sources": ["hcpcs"], "ms": 1, "usage": { "credits": 1, "creditsUsed": 10, "creditsLimit": 100, "txid": "81248" } } ``` | Field | Meaning | |---|---| | `is_drug` | `true` for drug codes (mostly J-codes) | | `providers` | Clinicians who billed the code | | `tot_srvcs` | Services billed to Medicare nationally in the data year | The dictionary holds the 6,471 codes that appear in the Medicare data, not the full HCPCS code set. --- # Drug markets URL: https://openpipe.health/docs/api/drug-markets/ Markdown: https://openpipe.health/docs/api/drug-markets.md > One drug's volume by state in Medicare Part D and Medicaid, and its national spending per year in Part D, Part B and Medicaid. These two endpoints size a drug's market beyond the prescriber-level Part D data on [Providers](https://openpipe.health/docs/api/providers.md). One gives volume by state in two public programs side by side. The other gives national spending per year, with the manufacturer and the unit price trend. Both cost 1 credit, charged only when the call succeeds. A `400` is free. Three rules apply to both: - `drug` is required and must equal a brand name or a generic name, ignoring case. It is not a substring search. A generic name covers every brand of it. A name that matches nothing returns an empty `rows` and is still charged. - Query parameters the endpoint does not know are ignored. - None of this is commercial insurance. ## Get a drug's market by state ```http GET /api/market/drugs ``` Returns one row per state for one drug: Medicare Part D claims, cost and patients for 2024 next to Medicaid prescriptions and reimbursement. Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `drug` | string | Required. Brand or generic name, exact, 2 to 80 characters. For example `Eliquis` or `apixaban`. | | `state` | string | Two-letter state code. Omit for every state. | | `medicaid_year` | number | `2024` or `2025`. Default `2025`. The Part D columns are always 2024. | There is no paging. At most 70 rows come back, largest combined volume first. ### Example ```sh curl "$OPH_API/api/market/drugs?drug=Eliquis&state=TX" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "state": "TX", "partd_claims": "1400866", "partd_drug_cost": "1219765992", "partd_patients": "288812", "partd_claims_named_prescribers": "1330168", "medicaid_prescriptions": "51917", "medicaid_reimbursed": "28940660", "medicaid_ffs_prescriptions": "1706", "medicaid_mco_prescriptions": "50211", "medicaid_suppressed_cells": "11" } ], "sql": "WITH d AS (SELECT state, sum(total_claims) AS partd_claims, ... FROM rollup_drug_state WHERE (lower(brand_name) = lower($1) OR lower(generic_name) = lower($1)) AND ($2::text IS NULL OR state = $2) GROUP BY state), m AS (SELECT state, sum(prescriptions) AS medicaid_prescriptions, ... FROM rollup_medicaid_drug_state WHERE year = $3 AND ...) SELECT ... FROM d FULL JOIN m ON m.state = d.state ORDER BY ... LIMIT 70", "params": ["Eliquis", "TX", 2025], "sources": ["rollup_drug_state", "rollup_medicaid_drug_state"], "ms": 308, "years": { "partd": 2024, "medicaid": 2025 }, "population": { "partd": "Medicare Part D (stand-alone and Medicare Advantage drug plans), 2024. No commercial or Medicaid.", "medicaid": "Medicaid, fee-for-service plus managed care, all ages. Amounts are before manufacturer rebates. Cells under 11 prescriptions are withheld and not in the sums." }, "note": "drug matches a brand name or a generic name exactly, ignoring case; a generic name covers every brand. NULL means not published, not zero. partd_patients counts a patient once per brand.", "usage": { "credits": 1, "creditsUsed": 1664, "creditsLimit": 5000, "txid": "11175" } } ``` ### Columns | Field | Meaning | |---|---| | `partd_claims`, `partd_drug_cost`, `partd_patients` | CMS's own state totals over every Part D prescriber, 2024. Use these for market size. | | `partd_claims_named_prescribers` | Claims summed from the prescriber-level file, which leaves out any prescriber with 10 or fewer claims of the drug. It is lower than `partd_claims`; the gap is the volume written by low-volume prescribers. | | `medicaid_prescriptions`, `medicaid_reimbursed` | Medicaid prescriptions and the amount reimbursed to pharmacies in `medicaid_year`, fee-for-service and managed care together. | | `medicaid_ffs_prescriptions`, `medicaid_mco_prescriptions` | The same prescriptions split by delivery system. | | `medicaid_suppressed_cells` | Number of withheld Medicaid cells that are missing from the sums. | Every figure is a sum and arrives as a JSON string. `sql` is the statement the server ran, as a read-only [receipt](https://openpipe.health/docs/receipts.md). `years` and `population` repeat which year and which patients each half covers. The Medicaid year defaults to 2025 and Part D is 2024. To compare like with like, send `medicaid_year=2024`, or say that the years differ. ## Get a drug's national spending by year ```http GET /api/market/drugs/spending ``` Returns national spending on one drug per year, 2020 to 2024, in Medicare Part D, Medicare Part B and Medicaid. Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `drug` | string | Required. Brand or generic name, exact, 2 to 80 characters. | | `program` | string | `part_d`, `part_b` or `medicaid`. Omit for all three. | | `manufacturers` | string | `true` for one row per manufacturer. Default `false`: one row per brand and year across all manufacturers. | There is no paging. At most 500 rows come back, ordered by program, brand, manufacturer and year. ### Example ```sh curl "$OPH_API/api/market/drugs/spending?drug=Eliquis&program=part_d" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "program": "part_d", "brand_name": "Eliquis", "generic_name": "Apixaban", "manufacturer": "Overall", "hcpcs_code": null, "year": 2024, "total_spending": "20774929225", "claims": "24061332", "patients": "4424796", "avg_spend_per_unit": 9.6370356894, "avg_spend_per_claim": 863.41559248, "unit_price_change_1y": -0.011048166, "unit_price_cagr": 0.0510230439 } ], "sql": "SELECT program, brand_name, generic_name, manufacturer, hcpcs_code, year, round(total_spending::numeric, 0) AS total_spending, ... FROM drug_spending WHERE (lower(brand_name) = lower($1) OR lower(generic_name) = lower($1)) AND ($2::text IS NULL OR program = $2) AND (program = 'part_b' OR ($3::boolean AND manufacturer <> 'Overall') OR (NOT $3::boolean AND manufacturer = 'Overall')) ORDER BY program, brand_name, manufacturer, year LIMIT 500", "params": ["Eliquis", "part_d", false], "sources": ["drug_spending"], "ms": 161, "population": "National totals per program: Medicare Part D, Medicare Part B fee-for-service, Medicaid; 2020 to 2024, before rebates. No commercial.", "note": "By default one row per brand and year across all manufacturers. manufacturers=true returns the per-manufacturer rows instead; do not add the two together.", "usage": { "credits": 1, "creditsUsed": 1665, "creditsLimit": 5000, "txid": "11177" } } ``` The call returns five rows, 2020 to 2024. The example shows the last. Things to know: - `manufacturer` is `Overall` on the default rows. With `manufacturers=true` the `Overall` rows are replaced by one row per manufacturer. Never add the two sets together: that doubles the drug. - Part B rows are per HCPCS code and have no manufacturer. They come back the same way whatever `manufacturers` is, with the code in `hcpcs_code`. - `unit_price_change_1y` is the change in average spending per unit from 2023 to 2024, as a fraction: `-0.011` is a fall of 1.1%. `unit_price_cagr` is the yearly growth rate from 2020 to 2024. Both are repeated on every year's row of a drug. They do not describe that row's year. - A drug with no spending in a year has no row for that year. - `patients` is `null` for Medicaid, which publishes no patient counts. - `total_spending`, `claims` and `patients` arrive as JSON strings. ## Caveats ### Three populations, none of them commercial | Columns | Population | Period | |---|---|---| | `partd_*` and `program` `part_d` | Medicare Part D: stand-alone drug plans and Medicare Advantage drug plans together | By state: 2024. Spending: 2020 to 2024. | | `program` `part_b` | Medicare Part B fee-for-service: drugs given in a clinic or outpatient department | 2020 to 2024 | | `medicaid_*` and `program` `medicaid` | Medicaid, fee-for-service and managed care, all ages | By state: 2024 or 2025. Spending: 2020 to 2024. | Commercial insurance and self-pay are in none of them. Do not add the programs together and call the sum a market total. ### Amounts are before rebates Medicaid amounts are what Medicaid and other payers reimbursed pharmacies, before manufacturer rebates. Rebates are large in Medicaid. Do not read the amounts as net spending. Part D and Part B spending is gross as well. ### Small cells are withheld - **Medicaid.** A cell is one product in one state, quarter and delivery system. A cell with fewer than 11 prescriptions is suppressed. Suppressed cells are left out of the sums, and `medicaid_suppressed_cells` counts them. When every cell is suppressed the figures are `null`, not zero. - **Part D.** The state totals are `null` where CMS suppressed the cell. `partd_claims_named_prescribers` is `null` where no prescriber in the state reached 11 claims. `null` means not published. It never means zero. ### Coverage - The Medicaid data covers outpatient drugs that states report for the Medicaid Drug Rebate Program, calendar years 2024 and 2025, both updated July 2026. Drugs outside that program are missing. No prescriber or pharmacy is identified. - Medicaid drug names come from the FDA NDC Directory and are spelled like the Part D names where the drug exists there. That is 87% of prescriptions in 2025. The rest carry the FDA name in title case, or the source's name cut to 10 characters, and match only under that spelling. - Part D by state is the 2024 release (RY26). `partd_patients` counts a patient once per brand, so a generic name that covers several brands counts some patients more than once. - Spending by year comes from the CMS drug spending dashboards, 2024 release (RY26). It is national only: no state and no prescriber. --- # Payers and ACOs URL: https://openpipe.health/docs/api/payers-acos/ Markdown: https://openpipe.health/docs/api/payers-acos.md > Medicare Advantage and Part D enrollment by parent company for the nation, a state or a county, individual plans, and Medicare Shared Savings Program ACOs with their participants. These endpoints describe who insures and who manages Medicare patients in a market: private-plan enrollment by parent company, the plans themselves, and the accountable care organizations (ACOs) in the Medicare Shared Savings Program. Every endpoint on this page costs 1 credit, charged only when the call succeeds. A `400` or a `404` is free. Two rules apply to all of them: - Text filters are substring matches that ignore case, 2 to 80 characters. A shorter value returns `400`. - Query parameters the endpoint does not know are ignored. Plan categories are `MA` (Medicare Advantage), `PDP` (stand-alone Part D drug plans) and `OTHER` (cost, PACE and demonstration plans). ## Get Medicare payers in a state or the nation ```http GET /api/market/payers ``` Returns private-plan enrollment by parent company, largest first, with each company's share and the area's total Medicare population. Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `state` | string | Two-letter state code. Omit for the nation. | | `category` | string | `MA` (default), `PDP` or `OTHER`. | | `parent` | string | Substring of the parent organization. Applied after shares are computed, so `share_pct` is still the share of the whole market. | | `limit` | number | 1 to 100. Default 25. | There is no `offset`. ### Example ```sh curl "$OPH_API/api/market/payers?state=FL&limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "parent_organization": "Humana Inc.", "enrollment": "1162900", "snp_enrollment": "346521", "plans": "555", "states": "1", "suppressed_cells": "5176", "share_pct": "38.02" } ], "sql": "SELECT parent_organization, sum(enrollment) AS enrollment, sum(snp_enrollment) AS snp_enrollment, sum(plans) AS plans, count(DISTINCT state) AS states, sum(suppressed_cells) AS suppressed_cells, round((100.0 * sum(enrollment) / nullif(sum(sum(enrollment)) OVER (), 0))::numeric, 2) AS share_pct FROM ma_enrollment_state WHERE plan_category = $1 AND ($2::text IS NULL OR state = $2) GROUP BY parent_organization ORDER BY enrollment DESC NULLS LAST, 1 LIMIT 400", "params": ["MA", "FL"], "sources": ["ma_enrollment_state", "medicare_enrollment_state"], "ms": 34, "medicare": { "year": 2026, "month": 8, "total_benes": "5359102", "original_medicare_benes": "2303736", "ma_other_benes": "3055366", "ma_share": "0.5701" }, "population": "Medicare beneficiaries in private plans (Medicare Advantage, cost, PACE, stand-alone Part D), November 2026. Plan-county cells of 10 or fewer enrollees are withheld and not in the sums. No commercial or Medicaid plans.", "note": "share_pct is the share of published enrollment in the chosen plan category and state (or nationally). medicare gives the area's total Medicare population and Medicare Advantage share from CMS enrollment counts.", "usage": { "credits": 1, "creditsUsed": 1666, "creditsLimit": 5000, "txid": "11179" } } ``` Things to know: - `enrollment` is enrollees in the chosen category. `snp_enrollment` is the part of it in special needs plans. `suppressed_cells` counts the withheld plan-county cells that are missing from `enrollment`. - `share_pct` is a share of published enrollment in that category and area. - `medicare` is the area's whole Medicare population for the latest month CMS has published: `original_medicare_benes` in fee-for-service, `ma_other_benes` in Medicare Advantage and other private health plans, and `ma_share` as a fraction. It is a different file from the plan enrollment, for August 2026 where the plans are November 2026. - `sql` is the statement behind `rows`, as a read-only [receipt](https://openpipe.health/docs/receipts.md). The statement behind `medicare` is not included. - Sums arrive as JSON strings. ## Get Medicare payers in a county ```http GET /api/market/payers/counties/:fips ``` Returns the same breakdown for one county, with the county's Medicare totals. Costs 1 credit, charged only if the county exists. `:fips` is the five-digit county FIPS code, for example `12086` for Miami-Dade. Anything else returns `400` with `County FIPS must be 5 digits, for example 12086.` An unknown county returns `404`. ### Parameters | Name | Type | Description | |---|---|---| | `category` | string | `MA` (default), `PDP` or `OTHER`. | At most 100 parent companies come back. There is no paging. ### Example ```sh curl "$OPH_API/api/market/payers/counties/12086" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "county": { "county_fips": "12086", "state": "FL", "county": "Miami-Dade County", "year": 2026, "month": 8, "total_benes": "526505", "original_medicare_benes": "131543", "ma_other_benes": "394962", "ma_share": 0.7502 }, "rows": [ { "parent_organization": "UnitedHealth Group, Inc.", "enrollment": "119260", "plans": "230", "suppressed_plans": "201", "share_pct": "30.17" } ], "sql": "SELECT p.parent_organization, sum(e.enrollment) AS enrollment, count(*) AS plans, count(*) FILTER (WHERE e.enrollment IS NULL) AS suppressed_plans, ... FROM ma_enrollment_county e JOIN ma_plans p ON p.contract_id = e.contract_id AND p.plan_id = e.plan_id WHERE e.county_fips = $1 AND p.plan_category = $2 GROUP BY p.parent_organization ORDER BY enrollment DESC NULLS LAST, 1 LIMIT 100", "params": ["12086", "MA"], "sources": ["ma_enrollment_county", "ma_plans", "medicare_enrollment_county"], "ms": 94, "population": "Medicare beneficiaries in private plans (Medicare Advantage, cost, PACE, stand-alone Part D), November 2026. Plan-county cells of 10 or fewer enrollees are withheld and not in the sums. No commercial or Medicaid plans.", "usage": { "credits": 1, "creditsUsed": 1667, "creditsLimit": 5000, "txid": "11181" } } ``` `plans` counts every plan of that parent with at least one enrollee living in the county. `suppressed_plans` is how many of them have 10 or fewer and are withheld. In the example 201 of 230 plans are withheld: most are a handful of members who live outside the plan's service area. `enrollment` is the sum over the other 29. `county` is `null` when CMS publishes no Medicare total for the county. ## Search Medicare Advantage and Part D plans ```http GET /api/market/plans ``` Returns individual plans, largest enrollment first. Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `q` | string | Substring of the plan name, organization name or marketing name, or of a contract id such as `H1036`. | | `parent` | string | Substring of the parent organization. | | `state` | string | Two-letter state code. Keeps plans with enrollees living in the state and ranks by enrollment there. | | `category` | string | `MA`, `PDP` or `OTHER`. Omit for all. | | `plan_type` | string | Substring of the plan type, for example `HMO`, `PPO` or `PACE`. 2 to 40 characters. | | `snp` | string | `true` for special needs plans only, `false` for the rest. | | `limit` | number | 1 to 100. Default 25. | | `offset` | number | Rows to skip, 0 to 10,000. Default 0. | ### Example ```sh curl "$OPH_API/api/market/plans?state=FL&snp=true&limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "contract_id": "H1045", "plan_id": "039", "plan_name": "UHC Dual Complete FL-D002 (HMO-POS D-SNP)", "plan_category": "MA", "plan_type": "HMO/HMOPOS", "organization_name": "PREFERRED CARE PARTNERS, INC.", "marketing_name": "UnitedHealthcare", "parent_organization": "UnitedHealth Group, Inc.", "offers_part_d": true, "is_snp": true, "is_employer_plan": false, "state_enrollment": "62534", "state_counties": "24", "total_enrollment": 62534 } ], "sql": "SELECT p.contract_id, p.plan_id, p.plan_name, ..., s.enrollment AS state_enrollment, s.counties AS state_counties, p.enrollment AS total_enrollment FROM (SELECT contract_id, plan_id, sum(enrollment) AS enrollment, count(enrollment) AS counties FROM ma_enrollment_county WHERE state = $6 GROUP BY contract_id, plan_id) s JOIN ma_plans p ON p.contract_id = s.contract_id AND p.plan_id = s.plan_id WHERE ... ORDER BY s.enrollment DESC NULLS LAST, p.contract_id, p.plan_id LIMIT $7 OFFSET $8", "params": [null, null, null, null, true, "FL", 1, 0], "sources": ["ma_plans", "ma_enrollment_county"], "ms": 896, "population": "Medicare beneficiaries in private plans (Medicare Advantage, cost, PACE, stand-alone Part D), November 2026. Plan-county cells of 10 or fewer enrollees are withheld and not in the sums. No commercial or Medicaid plans.", "usage": { "credits": 1, "creditsUsed": 1668, "creditsLimit": 5000, "txid": "11183" } } ``` The enrollment columns depend on `state`: | Request | Columns | |---|---| | With `state` | `state_enrollment` (enrollees living in the state), `state_counties` (counties in the state with a published figure) and `total_enrollment` (the plan everywhere). | | Without `state` | `total_enrollment`, `counties` (counties with a published figure) and `suppressed_counties` (counties withheld). | A plan is one contract id plus one plan id. `state_enrollment` is a sum and arrives as a JSON string. `total_enrollment` is a JSON number. ## Search ACOs ```http GET /api/market/acos ``` Returns Medicare Shared Savings Program ACOs, most assigned patients first, with their latest financial and quality results. Costs 1 credit. ### Parameters | Name | Type | Description | |---|---|---| | `q` | string | Substring of the ACO name. | | `state` | string | Two-letter state code. Matches the ACO's office state or any state in its service area. | | `track` | string | `BASIC` or `ENHANCED`. Lower case is accepted. | | `participating` | string | `true` for ACOs in the program in 2026, `false` for those that left after 2025. | | `group_pac_id` | number | Only the ACOs this [group practice](https://openpipe.health/docs/api/groups.md) takes part in. | | `limit` | number | 1 to 100. Default 25. | | `offset` | number | Rows to skip, 0 to 10,000. Default 0. | ### Example ```sh curl "$OPH_API/api/market/acos?state=TX&limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "aco_id": "A2164", "name": "CommonSpirit ACO I", "participating": true, "state": "AR", "city": "Little Rock", "service_area": "AR, AZ, CA, CO, IA, NE, OH, TN, TX, WA", "track": "ENHANCED", "basic_track_level": null, "revenue_class": "high", "participants": 85, "results_year": 2025, "assigned_benes": 207343, "benchmark": "2804581470", "generated_savings": "117609353", "earned_savings": "86442874", "savings_rate": 0.0419, "quality_score": 0.8701 } ], "sql": "SELECT a.aco_id, a.name, a.participating, a.state, ... FROM acos a WHERE ($1::text IS NULL OR a.name ILIKE $1) AND ($2::text IS NULL OR a.state = $2 OR a.service_area ILIKE '%' || $2 || '%') AND ... ORDER BY a.assigned_benes DESC NULLS LAST, a.aco_id LIMIT $6 OFFSET $7", "params": [null, "TX", null, null, null, 1, 0], "sources": ["acos"], "ms": 30, "population": "Medicare Shared Savings Program ACOs, performance year 2026, with performance year 2025 results. Assigned patients are Original Medicare only.", "usage": { "credits": 1, "creditsUsed": 1669, "creditsLimit": 5000, "txid": "11185" } } ``` Things to know: - The example ACO has its office in Arkansas. It matches `state=TX` because Texas is in its `service_area`. - `generated_savings` is the benchmark minus actual expenditure. `earned_savings` is what CMS paid the ACO. Both are negative for a loss. `savings_rate` is generated savings over the benchmark, as a fraction, and `quality_score` runs from 0 to 1. - `revenue_class` is `high` (typically hospital-led) or `low` (typically physician-led). `basic_track_level` is A to E within the BASIC track, where A and B carry no downside risk. - The dollar amounts arrive as JSON strings, rounded to whole dollars. ## Get an ACO ```http GET /api/market/acos/:id ``` Returns one ACO with its participant organizations. Costs 1 credit, charged only if the ACO exists. `:id` is an `aco_id`: one letter and four digits, for example `A2164`. Case is ignored. Anything else returns `400` with `ACO id looks like A1234.` An unknown id returns `404`. ### Parameters | Name | Type | Description | |---|---|---| | `limit` | number | Participants to return, 1 to 500. Default 200. | | `offset` | number | Participants to skip, 0 to 10,000. Default 0. | ### Response | Field | Contents | |---|---| | `aco_id` | The id, upper-cased. | | `aco` | Every column of the `acos` table: the search columns plus address, assignment method, agreement period and dates, the skilled-nursing waiver, website, total expenditures, and the executive and medical director contacts each ACO must publish through CMS. | | `participants` | The participant organizations, those linked to the largest group practice first: `participant_name`, `entries` (times the name is listed, for separate tax IDs under one name), and, where a link exists, `group_pac_id`, `group_name`, `group_state`, `group_clinicians` and `group_top_specialty`. | | `sql`, `params` | The participants statement and its values. The statement that reads `acos` is not included. | | `sources` | `acos`, `aco_participants`, `groups`. | ```sh curl "$OPH_API/api/market/acos/A2164?limit=1" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "aco_id": "A2164", "aco": { "aco_id": "A2164", "name": "CommonSpirit ACO I", "participating": true, "service_area": "AR, AZ, CA, CO, IA, NE, OH, TN, TX, WA", "track": "ENHANCED", "assignment": "retrospective", "agreement_period": 6, "snf_waiver": true, "participants": 85, "results_year": 2025, "assigned_benes": 207343, "benchmark": 2804581470, "expenditures": 2686972117, "generated_savings": 117609353, "earned_savings": 86442874, "savings_rate": 0.0419, "quality_score": 0.8701 }, "participants": [ { "participant_name": "FRANCISCAN MEDICAL GROUP", "entries": 1, "group_pac_id": "547173866", "group_name": "Franciscan Medical Group", "group_state": "WA", "group_clinicians": 1765, "group_top_specialty": "Nurse Practitioner" } ], "sql": "SELECT ap.participant_name, ap.entries, ap.group_pac_id, g.name AS group_name, ... FROM aco_participants ap LEFT JOIN groups g ON g.group_pac_id = ap.group_pac_id WHERE ap.aco_id = $1 ORDER BY g.member_count DESC NULLS LAST, ap.participant_name LIMIT $2 OFFSET $3", "params": ["A2164", 1, 0], "sources": ["acos", "aco_participants", "groups"], "ms": 91, "population": "Medicare Shared Savings Program ACOs, performance year 2026, with performance year 2025 results. Assigned patients are Original Medicare only.", "note": "CMS publishes participant names only. group_pac_id is our link by exact name, present for about three in four participants; unlinked does not mean the participant has no clinicians.", "usage": { "credits": 1, "creditsUsed": 1677, "creditsLimit": 5000, "txid": "11202" } } ``` The example leaves out the address and contact fields of `aco`. In `aco` the dollar amounts are JSON numbers, not strings. `aco.participants` is the count of participants. Page through the list with `limit` and `offset` until you have that many. Pass a `group_pac_id` to [`GET /api/groups/:id`](https://openpipe.health/docs/api/groups.md) for the group's members. ## Caveats ### Medicare private plans only Plans and enrollment come from the CMS Monthly Enrollment by Contract/Plan/State/County file for November 2026. It holds Medicare Advantage, cost and PACE plans and stand-alone Part D plans. Employer commercial insurance, exchange plans and Medicaid managed care are not included, so an insurer's commercial and Medicaid members are not counted. `parent_organization` is the name CMS records: `UnitedHealth Group, Inc.`, `Humana Inc.`, `CVS Health Corporation` for Aetna, `Elevance Health, Inc.` for Anthem. ### Small plan-county cells are withheld CMS withholds any plan-county cell with 10 or fewer enrollees. A withheld cell means 1 to 10 people, not zero. - 94% of plan-county cells are withheld. Most are a handful of members living outside the plan's service area, and the published cells hold almost all enrollees. - Every enrollment figure on this page is a sum of published cells, so it is slightly low. For a state figure the true number lies between `enrollment` and `enrollment` plus 10 times `suppressed_cells`. - County is where the enrollee lives. ### Medicare totals are a separate file `medicare` and `county` come from CMS Medicare Monthly Enrollment for August 2026, the latest month published. A county figure based on fewer than 11 people is `null`. The national figure is the sum of states, DC and territories, and is slightly below the US total because CMS's "foreign" and "unknown" rows are left out. Use `ma_share` to read the fee-for-service data elsewhere in the API. Where it is above one half, the claims-based endpoints see under half of the area's Medicare patients. ### ACOs are the Shared Savings Program only ACO REACH, Medicare Advantage and commercial ACO contracts are not included. - Organization details are performance year 2026. Results, from `assigned_benes` to `quality_score`, are performance year 2025, the latest CMS has published. - An ACO new in 2026 has no results. An ACO that left after 2025 is kept with `participating` set to `false`. - Assigned patients are Original Medicare patients attributed to the ACO's clinicians. They are not members who enrolled. ### Participants are linked to groups by name CMS publishes participant names only, with no tax ID and no NPI. `group_pac_id` is a link made here, only when the participant's name equals exactly one group practice in the ACO's service-area states. - About 75% of participants are linked. Solo practitioners listed under a person's name, and ambiguous names, are not. - An unlinked participant still has clinicians. The link is missing, not the practice. - A participant's clinicians, reached through the group, are those who bill through that group. It is not CMS's official ACO provider list. --- # Experts URL: https://openpipe.health/docs/api/experts/ Markdown: https://openpipe.health/docs/api/experts.md > Rank clinicians by the clinical trials they lead, and fetch one clinician's trials, NIH grants and industry payments. These endpoints find clinical experts by their research: the trials they are named on at ClinicalTrials.gov and the grants they hold from the National Institutes of Health (NIH). For clinical activity, such as procedures, prescribing and group practices, use [Providers](https://openpipe.health/docs/api/providers.md). Both cost 1 credit, charged only when the call succeeds. A `400` or a `404` is free. Neither source publishes an NPI. Every link from a trial or a grant to a clinician is made here by matching names. Read [Links are made by name](#links-are-made-by-name) before you act on a result. ## Search experts ```http GET /api/market/experts ``` Returns clinicians ranked by the number of matching trials they are named on. Costs 1 credit. ### Parameters At least one of `condition`, `sponsor` or `state` is required. Without one the call returns `400` with `Give at least one of condition, sponsor or state.` | Name | Type | Description | |---|---|---| | `condition` | string | Substring of the trial's conditions, for example `melanoma` or `heart failure`. 2 to 80 characters. | | `sponsor` | string | Substring of the trial sponsor, for example `Pfizer`. 2 to 80 characters. | | `state` | string | Two-letter state code of the investigator on the trial. | | `confidence` | string | `any` (default) or `high`. `high` counts only links where the registry address is in the investigator's city or ZIP. | | `limit` | number | 1 to 100. Default 25. | | `offset` | number | Rows to skip, 0 to 10,000. Default 0. | Text filters ignore case. Query parameters the endpoint does not know are ignored. ### Example ```sh curl "$OPH_API/api/market/experts?condition=melanoma&state=TX&limit=1" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "npi": "1234567890", "name": "JANE EXAMPLE", "credentials": "MD", "specialty": "Internal Medicine", "city": "HOUSTON", "state": "TX", "trials": "17", "active_trials": "7", "industry_trials": "1", "latest_start": "2026-09-01T00:00:00.000Z", "match_confidence": "high" } ], "sql": "WITH hits AS (SELECT i.npi, count(DISTINCT i.nct_id) AS trials, ... FROM trial_investigators i JOIN trials t ON t.nct_id = i.nct_id WHERE i.npi IS NOT NULL AND ($1::text IS NULL OR t.conditions ILIKE $1) AND ($2::text IS NULL OR t.sponsor ILIKE $2) AND ($3::text IS NULL OR i.state = $3) AND ($4::boolean IS NOT TRUE OR i.match_confidence = 'high') GROUP BY i.npi ORDER BY trials DESC, i.npi LIMIT $5 OFFSET $6) SELECT h.npi, p.name, ... FROM hits h JOIN providers p ON p.npi = h.npi ORDER BY h.trials DESC, h.npi", "params": ["%melanoma%", null, "TX", false, 1, 0], "sources": ["trial_investigators", "trials", "providers"], "ms": 1060, "population": "ClinicalTrials.gov interventional studies with a US site, and NIH RePORTER fiscal years 2024 to 2026. NPIs are linked by unique name within a state, not published by the source: verify 'medium' links.", "note": "Only investigators linked to an NPI are ranked (about 45% of investigator listings). match_confidence is the weakest link among the person's trials.", "usage": { "credits": 1, "creditsUsed": 1670, "creditsLimit": 5000, "txid": "11187" } } ``` ### Columns | Field | Meaning | |---|---| | `name`, `credentials`, `specialty`, `city`, `state` | The clinician's NPI registry record. `state` is the registry address, which can differ from the trial state you filtered on. | | `trials` | Distinct trials that match the filters and name this clinician. | | `active_trials` | Those whose status is recruiting, not yet recruiting, active but not recruiting, or enrolling by invitation. | | `industry_trials` | Those with an industry sponsor. | | `latest_start` | Latest start date among them. Sponsors enter dates, and some are estimates. | | `match_confidence` | `high` or `medium`. See below. | The counts arrive as JSON strings. `sql` is the statement the server ran, as a read-only [receipt](https://openpipe.health/docs/receipts.md). A row's `match_confidence` is the weakest link among the clinician's matching trials: it reads `medium` as soon as one of them is a medium-confidence link. To count only high-confidence links, send `confidence=high`. ## Get an expert ```http GET /api/market/experts/:npi ``` Returns one clinician's trials, NIH grants and industry payments. Costs 1 credit, charged only if the provider exists. `:npi` must be 10 digits, otherwise the call returns `400` with `NPI must be 10 digits.` An NPI that is not in the registry returns `404`. It works for any NPI in the registry, not only those a search returned. ### Response | Field | Contents | |---|---| | `npi` | The NPI. | | `provider` | Name, credentials, specialty, city and state from the NPI registry. | | `summary` | `trials` (distinct trials), `nih_projects` (distinct NIH projects), `nih_funding_as_contact_pi` (award dollars, fiscal 2024 to 2026, on awards where the clinician is the contact investigator, leaving out subprojects) and `industry_payments` (Open Payments total for 2024). | | `trials` | Up to 100 trials, newest start first: NCT number, title, phase, status, sponsor, sponsor class, conditions, start date, `role`, `listed_as` (`overall_official` or `site`), `facility` and `match_confidence`. | | `grants` | Up to 100 NIH awards, newest fiscal year first: application id, fiscal year, project number, activity code, institute, title, organization, `is_contact_pi`, `pi_count`, `is_subproject`, award amount, project dates and `match_confidence`. | | `payments` | The 25 largest industry payers from Open Payments: year, company, total amount, number of payments and the most common nature of payment. | | `sources` | `providers`, `trial_investigators`, `trials`, `nih_grants`, `open_payments`. | `sql` is an object with the five statements the server ran (`provider`, `summary`, `trials`, `grants`, `payments`), as a read-only [receipt](https://openpipe.health/docs/receipts.md). ```sh curl "$OPH_API/api/market/experts/1234567890" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "npi": 1234567890, "provider": { "npi": "1234567890", "name": "JANE EXAMPLE", "credentials": "MD", "specialty": "Internal Medicine", "city": "HOUSTON", "state": "TX" }, "summary": { "trials": "9", "nih_projects": "0", "nih_funding_as_contact_pi": null, "industry_payments": "59170" }, "trials": [ { "nct_id": "NCT05704647", "title": "Phase II Study of Nivolumab in Combination With Relatlimab in Patients With Active Melanoma Brain Metastases", "phase": "PHASE2", "status": "RECRUITING", "sponsor": "M.D. Anderson Cancer Center", "sponsor_class": "OTHER", "conditions": "Melanoma (Skin)", "start_date": "2023-02-23T00:00:00.000Z", "role": "PRINCIPAL_INVESTIGATOR", "listed_as": "overall_official", "facility": "M D Anderson Cancer Center", "match_confidence": "high" } ], "grants": [], "payments": [ { "year": 2024, "company": "Merck Sharp & Dohme LLC", "total_amount": "43328.65", "payment_count": 23, "top_nature": "Travel and Lodging" } ], "sources": ["providers", "trial_investigators", "trials", "nih_grants", "open_payments"], "ms": 63, "population": "ClinicalTrials.gov interventional studies with a US site, and NIH RePORTER fiscal years 2024 to 2026. NPIs are linked by unique name within a state, not published by the source: verify 'medium' links.", "note": "Trials and grants are attached by name, not by a published NPI; empty lists mean nothing was linked, not that the clinician has none. nih_funding_as_contact_pi counts awards where the clinician is the contact investigator, fiscal 2024 to 2026.", "usage": { "credits": 1, "creditsUsed": 1678, "creditsLimit": 5000, "txid": "11204" } } ``` The example shows one of nine trials and one of the payers. Things to know: - Empty `trials` and `grants` mean nothing was linked to this NPI. They do not mean the clinician has no trials or grants. - A provider in the registry with nothing linked still returns `200` and is charged. - When you add up `grants` yourself, count only rows where `is_contact_pi` is `true` and `is_subproject` is `false`, and pick one fiscal year or sum across years on purpose. A project with several principal investigators repeats its full `award_amount` on each one's row, and a subproject's money is already inside its parent award. - The top-level `npi` is a JSON number. `provider.npi` is a string. ## Caveats ### Links are made by name ClinicalTrials.gov and NIH RePORTER publish names, not NPIs. The NPI on a trial investigator or a grant is a link made here, and it has a confidence level. A link is made only when all of these hold: - The name parses as one person. - The investigator can be placed in a state. For a grant, that is the state of the organization. - Exactly one person in the NPI registry has that first and last name in that state. - That person is a doctoral-level clinician. | `match_confidence` | Meaning | |---|---| | `high` | The registry address is in the investigator's city or ZIP. | | `medium` | Same state only. Treat it as a lead to verify. | A name match can still be a different person. Check a `medium` link before outreach. How much is linked: - 45% of trial investigator listings have an NPI, and 67% of site principal investigators. - 21% of NIH grant rows have an NPI, because most NIH investigators are scientists without one. - No NPI means not linked. Common names, non-clinician scientists, sponsor staff and officials of multi-state studies who cannot be placed in a state stay unlinked, and none of them appear in a search. ### Trials - ClinicalTrials.gov as downloaded on 5 December 2026. - Interventional studies with at least one US site only. Observational studies and studies with no US site are not included. - Sponsors enter the data. Conditions and interventions are free text, not coded, so `condition=melanoma` matches the text and nothing else. Dates can be estimates or wrong. - Site investigators are published only while a site is recruiting, so older studies list just the study-level officials. - `facility` is free text typed by the sponsor. The same hospital appears under several spellings and is not linked to a CCN. ### NIH grants - NIH RePORTER, fiscal years 2024 to 2026, organizations in US states and territories. - About 4% of fiscal 2024 and 2025 projects have no state in RePORTER and are not included. - Fiscal 2026 was downloaded on 5 December 2026 and may still gain late awards. ### Industry payments `payments` and `summary.industry_payments` come from Open Payments general payments for 2024, totalled per clinician and company. Research payments and ownership interests are not included. --- # Ask URL: https://openpipe.health/docs/api/ask/ Markdown: https://openpipe.health/docs/api/ask.md > Ask a question in plain English and receive a dashboard of up to four tiles, as one JSON document or a live event stream. ## Ask a question ```http POST /api/ask ``` Turns a question into two to four tiles, runs them in parallel and returns a small dashboard. Costs 25 credits. Common questions can cost 5 credits through [`POST /api/ask2/ask`](https://openpipe.health/docs/api/ask2.md), which answers as a stream of UI patches. [Which Ask to call](https://openpipe.health/docs/api/ask2.md#which-ask-to-call) compares the two. There are two ways to receive the answer. The price, the limits and what is stored are the same for both. | Mode | Ask for it with | You get | |---|---|---| | JSON | `Accept: application/json`, or `?stream=false` | One JSON document when the answer is finished, usually after 5 to 30 seconds | | Event stream (default) | Nothing, or `Accept: text/event-stream`, or `?stream=true` | Server-sent events: each tile as soon as it is ready | An `Accept` header that names both `application/json` and `text/event-stream` gets the stream. The `stream` parameter wins over the header. ### Body ```json { "question": "Who are the highest-volume TAVR operators in Florida?" } ``` `question` must be at least 5 characters. Anything past 500 characters is cut off. Nothing else in the body is read. ## JSON mode ```sh curl "$OPH_API/api/ask" \ -H "Authorization: Bearer $OPH_KEY" \ -H "Content-Type: application/json" -H "Accept: application/json" \ -d '{"question": "Who are the highest-volume TAVR operators in Florida?"}' ``` ```json { "id": "df706628-076f-4fa8-9797-c5f6028915ab", "question": "Who are the highest-volume TAVR operators in Florida?", "title": "Highest-volume TAVR operators in Florida", "summary": "Ranks Florida clinicians by Medicare fee-for-service TAVR services. Counts under 11 patients are withheld by CMS.", "followups": ["Which Florida hospitals do the most TAVR?"], "model": "claude-haiku-4-5", "tiles": [ { "index": 0, "type": "leaderboard", "title": "TAVR volume by operator, Florida", "x": "name", "y": "services", "format": "number", "sql": "SELECT s.npi, ... LIMIT 25", "columns": ["npi", "name", "city", "state", "services"], "rows": [{ "npi": "1234567893", "name": "Jane Example", "city": "Miami", "state": "FL", "services": 212 }], "sources": ["medicare_service", "medicare_provider"], "engine": "postgres", "ms": 41 } ], "failed": [], "sources": ["medicare_provider", "medicare_service"], "ms": 9120, "usage": { "credits": 25, "creditsUsed": 51, "creditsLimit": 100, "txid": "81260" } } ``` | Field | Meaning | |---|---| | `id` | The stored dashboard. [`GET /api/dashboards/:id`](https://openpipe.health/docs/api/saved.md#open-a-dashboard) opens it again for free, and it is what an [export](https://openpipe.health/docs/api/exports.md#export-a-tile-of-an-answer) refers to. `null` only if the answer was computed but could not be stored. | | `title`, `summary` | How the question was read, and any limit on the answer, such as Medicare-only volumes. Show the summary. | | `followups` | Up to three suggested next questions | | `tiles` | The tiles that succeeded, in planned order. `index` is the tile's position in the plan. See [tile types](#tile-types). | | `tiles[].sql` | The statement the model wrote for the tile. A [receipt](https://openpipe.health/docs/receipts.md): it shows how the numbers were computed. Nothing accepts it back. | | `failed` | Tiles whose statement was rejected or failed: `index`, `title`, `error`, `sql`. They are kept in the stored dashboard, so a free [refresh](https://openpipe.health/docs/api/saved.md#refresh-a-dashboard) retries them. | | `sources` | Every dataset the answer read | | `ms` | Total time, planning included | | `usage` | The [usage object](https://openpipe.health/docs/credits.md#the-usage-object) for this call | If the model cannot produce a plan, the response is `502`, nothing is charged and nothing is stored: ```json { "error": "The model could not plan an answer for that question. Nothing was charged.", "code": "ASK_FAILED", "charged": false } ``` ## Event stream Without a JSON `Accept` header the response is a `text/event-stream`. Events arrive in this order: | Event | Count | Data | |---|---|---| | `usage` | 1 | The [usage object](https://openpipe.health/docs/credits.md#the-usage-object) for this call. It arrives once the model has a plan, just before `plan`, so the first event can take several seconds. | | `plan` | 1 | `title`, `summary`, `followups` (up to 3 suggested next questions), `model`, `ms`, and `tiles` (each tile's `type`, `title`, `x`, `y`, `format`, without its SQL) | | `tile` | 0 to 4 | One finished tile. Arrives in completion order, so use `index` to place it. | | `tile_error` | 0 to 4 | A tile whose statement failed: `index`, `title`, `sql`, `error` | | `done` | 1 | `tiles` (planned), `failed`, `ms` (total) and `id`, the stored dashboard (`null` only if it could not be stored) | | `error` | 0 or 1 | `error`. Sent in place of everything else when the answer cannot start; the stream then ends without `done`. See [errors inside the stream](#errors-inside-the-stream). | ### A tile event ``` event: tile data: {"index":0,"tile":{"type":"bar","title":"TAVR volume by operator, Florida","sql":"SELECT ... LIMIT 15","x":"name","y":"services","format":"number","position":0},"columns":["name","services"],"rows":[{"name":"Jane Example","services":212}],"ms":41,"sources":["medicare_service","medicare_provider"],"engine":"postgres"} ``` Each tile carries its own [receipt](https://openpipe.health/docs/receipts.md): the SQL inside `tile.sql`, the `sources` it read and the `engine` that ran it. In the stream the tile's fields sit under `tile`; in JSON mode they are flattened into the tile object. ```sh curl -N "$OPH_API/api/ask" \ -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \ -d '{"question": "Who are the highest-volume TAVR operators in Florida?"}' ``` `-N` turns off curl's buffering so events print as they arrive. For a browser or Node client, see [Stream Ask in JavaScript](https://openpipe.health/docs/guides/stream-ask.md). ### Errors inside the stream Once the stream has started, the HTTP status is already `200`. A failure arrives as one `error` event and the stream ends: | Data | Meaning | |---|---| | `{ "error": "The model could not plan …", "code": "ASK_FAILED", "charged": false }` | No plan could be made. Nothing was charged or stored. | | `{ "error": "Out of credits: …", "status": 402 }` | The balance was spent by another call between the first check and the charge. Nothing was charged and no tile ran. | | `{ "error": "The answer could not be finished." }` | An unexpected failure after the charge | ## Tile types | `type` | Shape | How to draw it | |---|---|---| | `stat` | One row | Show the value in column `y` as a headline number. Other columns in the row are supporting figures. | | `leaderboard` | A ranking of named clinicians, hospitals or groups | `x` is the name column, `y` the metric it is ranked by. Rows include an `npi`, `ccn` or `group_pac_id` you can pass to a lookup endpoint. | | `map` | One row per state | `x` is `state` (a two-letter code), `y` the numeric column | | `bar` | Ranked categories | `x` is the label column, `y` the numeric column | | `line` | Ordered series | `x` and `y` as for `bar` | | `table` | A detailed list | Show `columns` as headers. `x` and `y` are `null`. | `format` is `number`, `usd`, `percent` or `null`, and says how to display `y`. A `table` tile carries at most 50 rows and any other tile at most 100. The model is asked for fewer (about 15 for a bar, 25 for a leaderboard or table), but those are instructions to the model, not limits the API enforces. ## When you are charged, and what is stored The same four steps run in both modes, in this order: 1. **Checks before any work.** The request is rate limited (10 asks a minute per workspace, shared with the MCP [`ask` tool](https://openpipe.health/docs/mcp.md#tools)) and the balance must cover 25 credits, or the answer is `429` or `402`. 2. **The model plans.** If it cannot produce a plan, the call ends: nothing is charged, nothing is stored. 3. **The workspace is charged, once.** This happens when a plan exists and before any tile runs. If the balance was spent in the meantime the call ends with `402`: no tile runs and nothing is stored. 4. **Tiles run and one dashboard is stored.** Exactly one, whether or not you are still connected. If your connection drops, the answer is still finished, charged and stored; find it with [`GET /api/dashboards`](https://openpipe.health/docs/api/saved.md#list-dashboards) instead of asking again. Things to know: - **A planned tile is not a guaranteed tile.** The model writes the SQL, and each statement is [checked](https://openpipe.health/docs/receipts.md#how-model-written-sql-is-checked) before it runs. One that fails is reported (`failed` in JSON mode, `tile_error` in the stream) and the others still arrive. The call is still charged. - **The planner is shown the tables your question needs, not all of them.** A fast classifier picks the table groups (procedures, prescribing, hospitals, care sites, payers and so on) before the model plans; if a statement then reads a table that was left out, that table is added and the statement is rewritten once. Naming the thing you mean ("hospices", "Medicare Advantage", "trial investigators") helps the right tables get picked. - **A tile that would double count is rewritten or withheld.** Before a statement runs it is checked for a sum over a one-to-many join (a facility's payment repeated once per owner) and for procedure volume picked by a loose text match. The model is asked to rewrite it. If the double count is still there, the tile is reported as failed with an `error` that starts with `Withheld:` and no figure is shown. - **A failed tile can be retried for free.** It is stored with the dashboard, and [refresh](https://openpipe.health/docs/api/saved.md#refresh-a-dashboard) runs every tile's stored statement again without calling the model. - **Tiles hold a page, not everything.** A `table` tile carries at most 50 rows and any other tile at most 100. For every row a tile's statement returns, [export the tile](https://openpipe.health/docs/api/exports.md#export-a-tile-of-an-answer). - **Answers are kept as recent dashboards.** A workspace keeps its newest 50 unsaved answers; a signed-in person can [save](https://openpipe.health/docs/api/saved.md#save-unsave-or-rename-a-dashboard) one to keep it. - **Opening a stored answer is free.** [`GET /api/dashboards/:id`](https://openpipe.health/docs/api/saved.md#open-a-dashboard) returns the stored rows. - **There is no way to send your own SQL.** `sql` fields are receipts. To change what a tile computes, ask a different question. ## Answers framed for the asker When the request is made with a [session token](https://openpipe.health/docs/authentication.md#two-kinds-of-token) and the signed-in person has an [onboarding profile](https://openpipe.health/docs/api/profile.md), the profile is given to the model along with the question. The model is told to use it for emphasis and defaults only: - **Territory.** If the question names no state, no region and does not say "national", and the profile has a territory, the answer is filtered to those states and the summary says so. A place named in the question always wins. - **Subject.** If the question says "my product", "my market", "my procedures" or "my drug", or names no subject, the profile's focus items are used. A subject named in the question always wins. - **Role.** A territory rep or business developer gets named people and accounts first (a leaderboard). A sales leader or founder gets market size and where it is (a stat, a map). Marketing gets segments and counts. An analyst gets breakdowns and a detailed table. - **No numbers.** The profile never supplies a figure. Every number still comes from SQL the model writes over the data tables, and that SQL passes the same checks. Things to know: - **A request made with an API key never gets a profile.** A key belongs to a workspace, not to a person, so the same question asked with a key and asked in the app can return different tiles. To get the territory with a key, name the states in the question. - **The profile does not have to be finished.** It is used as soon as it holds a role, what the company sells, a focus item or a territory. A person with none of those is treated like a key. - **These are instructions to a model, not filters in code.** Read `plan.summary` and each tile's `sql` to see what was applied. - **The request is the same.** There is no parameter that sends, overrides or turns off the profile, and the price is the same 25 credits. - If the profile cannot be read, the question is answered without it. ## Errors These arrive as an ordinary JSON error, in either mode, before any answer starts: | Status | Message | |---|---| | `400` | `Body must be {"question": "..."}.` | | `402` | `Out of credits: …` | | `429` | `Too many requests. Try again in 23s.` | In JSON mode two more can follow: `502` with `code: "ASK_FAILED"` when no plan could be made, and `402` when the balance was spent between the first check and the charge. In the stream the same two arrive as an [`error` event](#errors-inside-the-stream). --- # Ask (instant) URL: https://openpipe.health/docs/api/ask2/ Markdown: https://openpipe.health/docs/api/ask2.md > The endpoints behind the app's Ask page. A question is answered from a ready-made recipe for 5 credits when one fits, and by the planner for 25 when none does, as a stream of UI patches. ## Which Ask to call There are two ways to ask a question over REST. Both store the answer as a [dashboard](https://openpipe.health/docs/api/saved.md) in the same place. | | [`POST /api/ask`](https://openpipe.health/docs/api/ask.md) | `POST /api/ask2/ask` (this page) | |---|---|---| | How it answers | Always the planner: a model writes the SQL | A ready-made recipe when one fits the question. The planner when none does. | | Credits | 25 | 5 for a recipe, 25 for the planner | | Response | One JSON document, or an event stream of finished tiles | Always an event stream of JSON Patch operations that build a UI spec | | Follow-ups | Ask a new question | [`/edit`](#change-a-dashboard) patches the dashboard. [`/predict`](#predict-the-next-dashboards) and [`/open`](#open-a-predicted-dashboard) prepare the next one. | | Used by | The MCP [`ask` tool](https://openpipe.health/docs/mcp.md#tools) | The app's Ask page | - **Simpler for a server-to-server integration: `POST /api/ask`.** In [JSON mode](https://openpipe.health/docs/api/ask.md#json-mode) it is one request and one document with every tile's rows. `/api/ask2/ask` has no JSON mode. You read server-sent events and apply each patch to a spec yourself, or you wait for `done` and fetch the rows with [`GET /api/dashboards/:id`](https://openpipe.health/docs/api/saved.md#open-a-dashboard). - **Cheaper for common questions: `/api/ask2/ask`.** Top clinicians for a procedure, top prescribers of a drug, a hospital, group or clinician profile and a market by state are recipes. They cost 5 credits and need no text model. [`GET /api/ask2/about`](#recipes-prices-and-limits) lists all of them, and the free [preview](#preview-a-question) says which tier a question would get before you ask it. - **It never costs more than 25.** When no recipe fits, `/api/ask2/ask` runs the same pipeline as `POST /api/ask`: the same table selection, the same SQL checks, the same withheld tiles, the same charge after the plan. See [how the planner works](https://openpipe.health/docs/api/ask.md#when-you-are-charged-and-what-is-stored). Only the events differ. Every endpoint here takes an [API key or a session token](https://openpipe.health/docs/authentication.md). Nothing here accepts SQL. | Endpoint | Credits | |---|---| | [`GET /api/ask2/preview`](#preview-a-question) | Free | | [`POST /api/ask2/ask`](#ask-a-question) | 5 or 25 | | [`POST /api/ask2/edit`](#change-a-dashboard) | 5 or 25 | | [`POST /api/ask2/predict`](#predict-the-next-dashboards) | Free | | [`POST /api/ask2/open`](#open-a-predicted-dashboard) | 5 | | [`GET /api/ask2/d/:id`](#read-a-stored-answer) | Free | | [`GET /api/ask2/about`](#recipes-prices-and-limits) | Free | ## Preview a question ```http GET /api/ask2/preview ``` Says what would be built for these words: the tier, the recipe, what was recognised and the tile layout. Free. No query runs and no rows are returned. | Parameter | Meaning | |---|---| | `q` | The question so far. 3 to 200 characters after trimming. | | `as` | Optional role to lay the answer out for: `rep`, `leader`, `marketing`, `analyst`, `bizdev` or `founder`. Any other value is ignored. | ```sh curl -G "$OPH_API/api/ask2/preview" \ -H "Authorization: Bearer $OPH_KEY" \ --data-urlencode "q=top TAVR operators in Florida" ``` ```json { "tier": "instant", "recipe": { "id": "proc_top_clinicians", "label": "Top clinicians for a procedure", "flow": "list" }, "confidence": 0.94, "probabilities": [ { "id": "proc_top_clinicians", "label": "Top clinicians for a procedure", "p": 0.94 }, { "id": "proc_market_by_state", "label": "Procedure market by state", "p": 0.01 }, { "id": "none", "label": "None of these (use the planner)", "p": 0.05 } ], "decidedBy": "jev", "unsure": false, "threshold": 0.5, "chips": [ { "kind": "procedure", "label": "TAVR", "sub": "HCPCS 33361" }, { "kind": "state", "label": "Florida", "sub": "FL" } ], "alternatives": [ { "id": "proc_market_by_state", "label": "Procedure market by state" }, { "id": "proc_top_groups", "label": "Group practices for a procedure" }, { "id": "proc_share_by_specialty", "label": "Procedure share by specialty" } ], "territoryDefault": null, "ms": { "match": 309.85, "decide": 229, "decideCached": false }, "q": "top TAVR operators in Florida", "title": "Top clinicians for tAVR in Florida", "layout": [ { "id": "top", "type": "Leaderboard", "title": "Top clinicians for tAVR" }, { "id": "stats", "type": "Stat", "title": "TAVR, Medicare volume" }, { "id": "map", "type": "StateMap", "title": "TAVR by state", "highlight": ["FL"] }, { "id": "split", "type": "Bar", "title": "Which specialties perform it" } ] } ``` | Field | Meaning | |---|---| | `tier` | `instant` when a recipe was chosen (5 credits to ask), `planned` when the question would go to the planner (25) | | `recipe` | The chosen recipe, or `null` | | `confidence`, `probabilities` | What the decision model gave the top recipe, and its spread over the candidates and `none`. `confidence` is `null` and `probabilities` is empty when rules decided. | | `decidedBy` | `jev` (the decision model), `rules` (the recipes' cue words), `pinned` (you passed `pin`) or `none` (no recipe) | | `unsure` | `true` when the pick is a guess. Offer `alternatives`. | | `threshold` | The probability a recipe needs: 0.5. See [how a recipe is chosen](#how-a-recipe-is-chosen). | | `chips` | What was recognised in the words: `kind` is `procedure`, `drug`, `specialty`, `company`, `state`, `city`, `hospital`, `group`, `clinician` or `filter` | | `alternatives` | Up to three other recipes that could answer the same words. Pass one's `id` as `pin` to [`/ask`](#ask-a-question). | | `territoryDefault` | Set when no place was named and the signed-in person's territory was used | | `ms` | Time spent matching entities and deciding. `decideCached` is `true` when the decision was already held from an earlier call. | | `title` | The dashboard title, or `null` when no recipe was chosen | | `layout` | Up to four tiles in display order: `id`, `type`, `title` and, on a map, `highlight`. When no recipe was chosen it is the closest recipe's shape with empty titles, or three generic tiles. | The response is sent with `Cache-Control: no-store`. `/ask` makes its own decision. It is normally the same one, because decisions made by the model are held for 10 minutes. ### Limits 300 previews a minute per person (per workspace for an API key). After the first 150 in a minute the decision model is no longer called and rules alone decide, so answers can differ. These sit on top of the [general limits](https://openpipe.health/docs/api/errors.md#rate-limits). ### Errors | Status | Body | |---|---| | `400` | `{ "error": "Type at least 3 characters.", "code": "TOO_SHORT" }` | | `400` | `{ "error": "A preview reads at most 200 characters.", "code": "TOO_LONG" }` | | `429` | `{ "error": "Too many previews. Try again in 23s.", "code": "RATE_LIMITED" }` | ## Ask a question ```http POST /api/ask2/ask ``` Answers a question from a recipe or, when none fits, with the planner. Costs 5 credits when a recipe answers. Costs 25 credits when the planner does. The response is a `text/event-stream`. ### Body ```json { "question": "top TAVR operators in Florida", "rid": "docs-ask2-0001" } ``` | Field | Meaning | |---|---| | `question` | Required. At least 5 characters after trimming (the preview accepts 3). Anything past 500 characters is cut off. | | `as` | Optional role, as for [preview](#preview-a-question). It sets the board's `lens` and can change which recipe a short question gets. | | `pin` | Optional recipe `id`. If that recipe can be built from the question, it is used without asking the decision model. Otherwise `pin` is ignored. Anything past 60 characters is cut off. | | `planner` | Optional. `true` skips the recipes and sends the question to the planner, at 25 credits. | | `rid` | Optional request id for safe retries: 8 to 64 letters, digits or hyphens. Any other value is ignored. See [retrying with `rid`](#retrying-with-rid). | ```sh curl -N "$OPH_API/api/ask2/ask" \ -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \ -d '{"question": "top TAVR operators in Florida", "rid": "docs-ask2-0001"}' ``` ### Events of an instant answer | Event | Count | Data | |---|---|---| | `decision` | 1 | The same fields as a [preview](#preview-a-question), without `q`, `title` and `layout` | | `patch` | 1 per element | The spec, before any query has finished: `/root`, then the board, then each tile with its SQL | | `say` | 0 or more | `{ "text": "…" }`, a line of narration | | `usage` | 1 | The [usage object](https://openpipe.health/docs/credits.md#the-usage-object). Sent when the first tile has a result and the workspace has been charged. No row is sent before it. | | `patch` | 1 per tile | `add /state/`: the tile's result, in completion order | | `say` | 0 or 1 | One line computed from the rows | | `done` | 1 | `id` (the stored dashboard, `null` only if it could not be stored), `tier`, `meta` and `ms` (total) | | `error` | 0 or 1 | Sent when the answer cannot finish. The stream ends without `done`. See [errors inside the stream](#errors-inside-the-stream). | The example above produced this, trimmed: ``` event: decision data: {"tier":"instant","recipe":{"id":"proc_top_clinicians","label":"Top clinicians for a procedure","flow":"list"},"confidence":0.94,"decidedBy":"jev","unsure":false,"threshold":0.5,"chips":[{"kind":"procedure","label":"TAVR","sub":"HCPCS 33361"},{"kind":"state","label":"Florida","sub":"FL"}], ...} event: patch data: {"op":"add","path":"/root","value":"board"} event: patch data: {"op":"add","path":"/elements/board","value":{"type":"Board","props":{"title":"Top clinicians for tAVR in Florida","summary":"Medicare fee-for-service claims for HCPCS 33361, data year 2024. A clinician with fewer than 11 patients for the code is hidden by CMS, so small volumes do not appear.","lens":null,"layouts":{"rep":["top","groups","map","stats"], ...}},"children":["top","stats","map","split","groups"]}} event: patch data: {"op":"add","path":"/elements/stats","value":{"type":"Stat","props":{"title":"TAVR, Medicare volume","sql":"SELECT round(sum(services)) AS services, sum(providers) AS clinicians, round(sum(payment)) AS medicare_payment\nFROM rollup_hcpcs_state\nWHERE hcpcs_code = '33361' AND state IN ('FL')","x":null,"y":"services","format":"number","tag":"market","engine":"postgres"},"children":[]}} event: say data: {"text":"Matched TAVR (33361)"} event: say data: {"text":"Chose \"Top clinicians for a procedure\" at 94% in 369 ms"} event: usage data: {"credits":5,"creditsUsed":1989,"creditsLimit":5000,"txid":"12296"} event: patch data: {"op":"add","path":"/state/stats","value":{"columns":["services","clinicians","medicare_payment"],"rows":[{"services":6800,"clinicians":"214","medicare_payment":4206559}],"ms":202,"engine":"postgres","sources":["rollup_hcpcs_state"]}} event: patch data: {"op":"add","path":"/state/top","value":{"columns":["npi","name","specialty","city","state","services","patients"],"rows":[{"npi":"1234567893","name":"Jane Example","specialty":"Thoracic Surgery","city":"Melbourne","state":"FL","services":152,"patients":"152"}, ...],"ms":212,"engine":"postgres","sources":["medicare_provider","medicare_service"]}} event: say data: {"text":"Ranked the top 25 of 214 clinicians in FL"} event: done data: {"id":"f4b85ea7-00bd-4622-831d-aac31a7d22b3","tier":"instant","meta":{"v":2,"tier":"instant","kind":"ask","recipe":"proc_top_clinicians", ...},"ms":1373} ``` That answer had five tiles: twelve `patch` events, three `say` events and one each of `decision`, `usage` and `done`. ### Events of a planned answer When no recipe is chosen, or `planner` is `true`, the planner answers. | Event | Count | Data | |---|---|---| | `decision` | 1 | As above, with `tier: "planned"` and `recipe: null` | | `say` | 1 | `No ready-made dashboard fits, so the planner is writing one` | | `usage` | 1 | The [usage object](https://openpipe.health/docs/credits.md#the-usage-object), 25 credits. Sent once the model has a plan, so it can take several seconds. | | `patch` | 1 per element | `/root`, the board, then tiles `t0`, `t1` and so on. Each tile's `sql` is an empty string at this point. | | `say` | 1 | `Planned 3 tiles in 6.2 s` | | `patch` | 2 per tile | `replace /elements/t0/props` with the tile's SQL filled in, then `add /state/t0` with its result or its error | | `done` | 1 | `id`, `tier: "planned"`, `meta`, `ms` and `model` | | `error` | 0 or 1 | As for an instant answer | A planned tile that fails or is [withheld](https://openpipe.health/docs/api/ask.md#when-you-are-charged-and-what-is-stored) arrives as a state patch holding `error`. There is no separate `tile_error` event. ### Building the spec from patches Start with `{ "root": "", "elements": {}, "state": {} }` and apply each `patch` in order. A patch is one [RFC 6902](https://www.rfc-editor.org/rfc/rfc6902) operation with `op` (`add`, `replace` or `remove`), `path` and, except for `remove`, `value`. | Path | Holds | |---|---| | `/root` | The id of the board element | | `/elements/` | The board (`type: "Board"`) or one tile | | `/state/` | That tile's result | The board's `props` are `title`, `summary`, `lens` and `layouts`. Its `children` are the tile ids in default order. `layouts` gives the tile order for each role, most important first. A tile's `type` is `Stat`, `Leaderboard`, `StateMap`, `Bar`, `Line` or `Table`. They are drawn like the [tile types](https://openpipe.health/docs/api/ask.md#tile-types) of `POST /api/ask` (`StateMap` is `map` there). A dashboard holds at most 8 tiles. Tile `props`: | Prop | Meaning | |---|---| | `title` | The tile's title | | `sql` | The statement that computes the tile. A [receipt](https://openpipe.health/docs/receipts.md). Nothing accepts it back. | | `x`, `y` | The label column and the numeric column. Both `null` on a `Table`. | | `format` | `number`, `usd`, `percent` or `null`: how to display `y` | | `tag` | Optional. What the tile is for: `people`, `accounts`, `market`, `segment`, `breakdown` or `intel` | | `highlight` | Optional. State codes to mark on a map. | | `engine` | Optional. The engine the recipe chose for the statement: `postgres` or `duckdb` | A tile's state is one of two shapes: ```json { "columns": ["services", "clinicians"], "rows": [{ "services": 6800, "clinicians": "214" }], "ms": 202, "engine": "postgres", "sources": ["rollup_hcpcs_state"] } ``` ```json { "error": "The query failed to run.", "sources": ["medicare_service"] } ``` A `Table` tile carries at most 50 rows and any other tile at most 100. ### The done event | Field | Meaning | |---|---| | `id` | The stored dashboard. Pass it to [`/edit`](#change-a-dashboard), [`/predict`](#predict-the-next-dashboards), [`GET /api/ask2/d/:id`](#read-a-stored-answer), [`GET /api/dashboards/:id`](https://openpipe.health/docs/api/saved.md#open-a-dashboard) or an [export](https://openpipe.health/docs/api/exports.md#export-a-tile-of-an-answer). | | `tier` | `instant` or `planned` | | `ms` | Total time in milliseconds | | `model` | Planned answers only: the model that wrote the plan | | `meta.kind` | `ask`, `edit` or `predicted` | | `meta.recipe`, `meta.params` | The recipe id and the parameters it was built with. Both `null` on a planned answer. | | `meta.lens` | The role the board was laid out for, or `null` | | `meta.parent` | The dashboard this one followed from, or `null` | | `meta.decision` | The `decision` event again | | `meta.timings` | `match`, `decide`, `decideCached`, `queries` (per tile: `id`, `title`, `ms`, `engine`, `rows`), `firstTile` and `total`. Also `ledger` on an instant answer and `plan` on a planned one. | | `meta.narration` | Every `say` line, in order | | `meta.followups` | Suggested next steps: `{ "text": "…", "kind": "edit" }` to send to [`/edit`](#change-a-dashboard), `{ "text": "…", "kind": "ask" }` to send to `/ask` | ### How a recipe is chosen 1. Entities are matched in the question: a procedure, drug, specialty, company, hospital, group, clinician, states, a city. 2. The recipes that can be built from those entities are the candidates. With no candidate, the question goes to the planner. 3. A short question is decided by rule, from the role: it names a subject, has at most 7 words, leaves no word unmatched, matches no recipe's cue words and is not phrased as a question ("which", "how", "compare" and similar). With no role, or as `rep` or `bizdev`, it gets the ranked list. Other roles get a market view. `unsure` is `true` for these. 4. Otherwise the decision model gives each candidate, and `none`, a probability. The top recipe is used at 0.5 or more. It is also used at 0.3 or more when the cue words pick the same recipe and `none` is under 0.4. When words in the question matched nothing (three or more with a subject, any without one), the top recipe needs 0.8. 5. If the decision model does not answer within 900 ms, the recipes' cue words decide. After a model decision, `unsure` is `true` when no recipe was chosen, when the top probability is under 0.55, or when it is under 0.7 with a lead of less than 0.3 over the runner-up. ### Retrying with `rid` Send the same `rid` when you retry a request. If an answer with that `rid` finished in the last 5 minutes, the response is plain JSON and nothing runs: ```json { "id": "f4b85ea7-00bd-4622-831d-aac31a7d22b3", "replay": true, "charged": false } ``` Things to know: - **A replay is free and is not rate limited** by the 60 a minute below. - **Only a finished, stored answer is replayed.** - **A retry that arrives while the first request is still running gets `409` with `code: "IN_PROGRESS"`** and is not charged. The same applies to `/edit`. - **`rid` is matched per workspace, and nothing else about the request is compared.** `/ask` and `/edit` share the same ids, so use a new `rid` for each new request. - **The record is kept in the server's memory.** It does not survive a restart. ### When you are charged, and what is stored For an instant answer: 1. **Checks before any work.** The `rid` replay, then the rate limit (`429`), then the balance must cover 5 credits (`402`). 2. **The spec is sent and every tile's statement starts at once.** Nothing is charged yet. 3. **The workspace is charged 5 credits, once, when the first tile has a result.** The `usage` event follows, then the rows. 4. **One dashboard is stored** and `done` carries its `id`. Things to know: - **Nothing is charged if you disconnect before the charge.** Nothing is stored either. After the charge the answer is finished and stored whether or not you are still connected. - **Nothing is charged if every tile fails.** The stream sends each tile's error, then an `error` event with `code: "ALL_TILES_FAILED"`. Nothing is stored. - **One failed tile among others is still charged.** Its state holds `error`. - **If the balance was spent between the check and the charge**, the stream ends with an `error` event carrying `status: 402`. No row is sent and nothing is stored. For a planned answer the rules are those of [`POST /api/ask`](https://openpipe.health/docs/api/ask.md#when-you-are-charged-and-what-is-stored): 25 credits, charged once when the model has a plan and before any tile runs, and nothing if no plan can be made. One difference: if you have disconnected by the time the plan is ready, nothing is charged, no tile runs and nothing is stored. ### Asking with an API key A key has no [onboarding profile](https://openpipe.health/docs/api/profile.md), so there is no role and no territory. Pass `as` to get a role's layout. Name the states in the question to get a territory. ### Limits | Applies to | Limit | Counted per | |---|---|---| | `/api/ask2/ask` and `/api/ask2/edit` together | 60 per minute | Workspace | | Questions that reach the planner, together with `POST /api/ask` and the MCP `ask` tool | 10 per minute | Workspace | A question that reaches the planner counts against both. These sit on top of the [general limits](https://openpipe.health/docs/api/errors.md#rate-limits). ### Errors These arrive as an ordinary JSON error, before the stream starts: | Status | Message | |---|---| | `400` | `Body must be {"question": "..."} with at least 5 characters.` | | `409` | `{ "error": "This request is still being answered. …", "code": "IN_PROGRESS", "charged": false }` when the same `rid` is sent again before its answer has finished. Nothing runs and nothing is charged; retry in a few seconds to get the stored answer. | | `402` | `Out of credits: …` The check is for 5 credits when a recipe was chosen and 25 when the planner will answer. | | `429` | `Too many questions. Try again in 23s.` (the 60) or `Too many planned questions. Try again in 23s.` (the 10). `code` is `RATE_LIMITED`. | ### Errors inside the stream Once the stream has started, the HTTP status is already `200`. A failure arrives as one `error` event and the stream ends: | Data | Meaning | |---|---| | `{ "error": "None of the tiles could be computed, so nothing was charged.", "code": "ALL_TILES_FAILED" }` | Instant answers. Nothing was charged or stored. | | `{ "error": "The model could not plan …", "code": "ASK_FAILED", "charged": false }` | Planned answers. No plan could be made. Nothing was charged or stored. | | `{ "error": "Out of credits: …", "status": 402 }` | The balance was spent between the first check and the charge. Nothing was charged. | | `{ "error": "The answer could not be finished." }` | An unexpected failure | ## Change a dashboard ```http POST /api/ask2/edit ``` A follow-up on a stored dashboard: change a filter, drop a tile, switch the view. Costs 5 credits when it can be done from a recipe. Costs 25 credits when the planner has to answer. The response is a `text/event-stream` with the same events as [`/ask`](#ask-a-question). ### Body ```json { "dashboard": "f4b85ea7-00bd-4622-831d-aac31a7d22b3", "text": "only Texas", "rid": "docs-ask2-0002" } ``` | Field | Meaning | |---|---| | `dashboard` | Required. The `id` of a dashboard in this workspace. | | `text` | Required. At least 2 characters after trimming. Anything past 300 characters is cut off. | | `as` | Optional role, as for [preview](#preview-a-question) | | `rid` | Optional request id. See [retrying with `rid`](#retrying-with-rid). | ```sh curl -N "$OPH_API/api/ask2/edit" \ -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \ -d '{"dashboard": "f4b85ea7-00bd-4622-831d-aac31a7d22b3", "text": "only Texas"}' ``` ``` event: decision data: {"tier":"instant","recipe":{"id":"proc_top_clinicians","label":"Top clinicians for a procedure","flow":"list"},"confidence":null,"probabilities":[],"decidedBy":"rules","unsure":false, ...} event: patch data: {"op":"replace","path":"/elements/board/props/title","value":"Top clinicians for tAVR in Texas"} event: patch data: {"op":"replace","path":"/elements/stats/props/sql","value":"SELECT round(sum(services)) AS services, sum(providers) AS clinicians, round(sum(payment)) AS medicare_payment\nFROM rollup_hcpcs_state\nWHERE hcpcs_code = '33361' AND state IN ('TX')"} event: patch data: {"op":"replace","path":"/elements/map/props/highlight","value":["TX"]} event: say data: {"text":"Changed states: TX"} event: say data: {"text":"Kept 1 tile as they were, recomputing 4"} event: usage data: {"credits":5,"creditsUsed":2003,"creditsLimit":5000,"txid":"12355"} event: patch data: {"op":"add","path":"/state/stats","value":{"columns":["services","clinicians","medicare_payment"],"rows":[{"services":5297,"clinicians":"185","medicare_payment":3058738}],"ms":63,"engine":"postgres","sources":["rollup_hcpcs_state"]}} event: done data: {"id":"585dee73-f554-4cc4-8457-79395e4b6756","tier":"instant","meta":{"v":2,"tier":"instant","kind":"edit","recipe":"proc_top_clinicians","parent":"f4b85ea7-00bd-4622-831d-aac31a7d22b3", ...},"ms":446} ``` ### What an edit does The follow-up is read in one of four ways: | Read as | When | Credits | `meta.kind` | |---|---|---|---| | An edit | The dashboard came from a recipe and the words change a filter, drop a tile or ask for a sibling view | 5 | `edit` | | A new instant question | The text does not open with an edit word, names its own subject, and a recipe is a sure pick: a hospital, group or clinician profile, or 0.8 or more from the decision model | 5 | `ask` | | A new planned question | The text does not open with an edit word, names its own subject, and three or more of its words matched nothing | 25 | `ask` | | A planned follow-up | Anything else. The planner gets the first 300 characters of the dashboard's question together with the follow-up. | 25 | `edit` | The edit words are `only`, `just`, `now`, `add`, `remove`, `also`, `without`, `same`, `but`, `and`, `exclude`, `filter`, `hide`, `drop`, `show the`, `rank by`, `sort by`, `in`, `for`, `with`, `not`, and `top` with a number alone. Things to know: - **An edit's patches apply to the spec you already hold.** They are the difference from the stored dashboard: `replace`, `add` and `remove` under `/elements`, and `remove /state/` for a tile that is gone. Read the spec with [`GET /api/ask2/d/:id`](#read-a-stored-answer) if you do not hold it. - **Only tiles whose SQL changed run again.** A kept tile gets no state patch. Keep the state you have for it. - **A dashboard that did not come from a recipe always costs 25 to follow up.** That includes every answer from `POST /api/ask` and every planned answer. There is nothing to patch, so the planner writes a new one. - **A new dashboard is stored each time.** The one you passed is left unchanged, and the new one's `meta.parent` points to it. - **Charging follows [`/ask`](#when-you-are-charged-and-what-is-stored)**, by tier. ### Limits The same counters as [`/ask`](#limits-1): 60 a minute per workspace shared with `/ask`, and 10 a minute for follow-ups that reach the planner. ### Errors Before the stream starts: | Status | Message | |---|---| | `400` | `Body must be {"dashboard": "", "text": "..."}.` | | `404` | `No answer with that id in this workspace.` A dashboard in another workspace answers the same. | | `402` | `Out of credits: …` | | `429` | `Too many questions. …` or `Too many planned questions. …` | Inside the stream, the [same `error` events](#errors-inside-the-stream) as `/ask`. ## Predict the next dashboards ```http POST /api/ask2/predict ``` Computes up to three likely next dashboards for a stored instant answer and holds them on the server. Free. It returns a token for each. No rows and no SQL are returned. ### Body ```json { "dashboard": "f4b85ea7-00bd-4622-831d-aac31a7d22b3" } ``` | Field | Meaning | |---|---| | `dashboard` | Required. The `id` of a dashboard in this workspace. | | `as` | Optional role, as for [preview](#preview-a-question). It can change the order the candidates are ranked in. | ```sh curl "$OPH_API/api/ask2/predict" \ -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \ -d '{"dashboard": "f4b85ea7-00bd-4622-831d-aac31a7d22b3"}' ``` ```json { "predictions": [ { "token": "80a5d43d-…", "question": "Which group practices have the most clinicians performing tAVR in Florida?", "label": "Group practices for a procedure", "readyAt": "2026-12-05T13:19:18.801Z", "ms": 96, "expiresInSeconds": 300 } ] } ``` | Field | Meaning | |---|---| | `token` | Pass it to [`/open`](#open-a-predicted-dashboard). 68 characters. | | `question` | The question the prediction answers | | `label` | The recipe's label | | `readyAt`, `ms` | When it finished computing, and how long that took | | `expiresInSeconds` | Time left before the token stops working | Things to know: - **Only instant answers are predicted from.** For a planned answer, or one from `POST /api/ask`, the response is `{ "predictions": [] }`. - **Predictions are recipes only.** They are the neighbours of the dashboard's recipe that can be built from the same entities. One whose lead tile came back empty or failed is left out. - **A token lives for 5 minutes** from `readyAt`. Predictions are kept in the server's memory, at most 12 per workspace; the oldest are dropped first. - **Asking again within 5 minutes returns the same tokens** and computes nothing. Predictions you have already opened are left out of the list. - **A token belongs to the workspace and the signed-in person it was computed for.** With API keys, any key of the workspace can open it. - **The call waits** until every prediction is computed. They run one after another. ### Limits 20 a minute per workspace. ### Errors | Status | Message | |---|---| | `404` | `No answer with that id in this workspace.` | | `429` | `Too many prediction requests. Try again in 23s.` | ## Open a predicted dashboard ```http POST /api/ask2/open ``` Opens a prediction. Costs 5 credits. The workspace is charged, the dashboard is stored, and the rows computed earlier are returned as one JSON document. No query runs. ### Body ```json { "token": "80a5d43d-…" } ``` ```sh curl "$OPH_API/api/ask2/open" \ -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \ -d "{\"token\": \"$TOKEN\"}" ``` ```json { "id": "cbb5cc78-4f1c-463e-bcc0-a106715cac77", "question": "Which group practices have the most clinicians performing tAVR in Florida?", "spec": { "root": "board", "elements": { "board": { "type": "Board", "props": { "title": "Group practices performing tAVR in Florida" }, "children": ["groups", "top", "stats", "map", "split"] }, "groups": { "type": "Leaderboard", "props": { "title": "Group practices with the most clinicians performing it", "sql": "SELECT …" }, "children": [] } } }, "state": { "stats": { "columns": ["services", "clinicians", "medicare_payment"], "rows": [{ "services": 6800, "clinicians": "214", "medicare_payment": 4206559 }], "ms": 64, "engine": "postgres", "sources": ["rollup_hcpcs_state"] } }, "meta": { "v": 2, "tier": "instant", "kind": "predicted", "recipe": "proc_top_groups", "parent": "f4b85ea7-00bd-4622-831d-aac31a7d22b3", "narration": ["Predicted from your last question and computed ahead of time in 96 ms"], "followups": [{ "text": "Only orthopedic surgeons", "kind": "edit" }], "predictedReadyAt": "2026-12-05T13:19:18.801Z" }, "usage": { "credits": 5, "creditsUsed": 2019, "creditsLimit": 5000, "txid": "12423" }, "readyAt": "2026-12-05T13:19:18.801Z", "openMs": 178 } ``` | Field | Meaning | |---|---| | `id` | The stored dashboard | | `spec` | The finished spec: `root` and `elements`, as [built from patches](#building-the-spec-from-patches) | | `state` | Every tile's result, keyed by tile id | | `meta` | As in the [done event](#the-done-event), with `kind: "predicted"` and `predictedReadyAt` | | `usage` | The [usage object](https://openpipe.health/docs/credits.md#the-usage-object) for this call | | `readyAt` | When the rows were computed. They are not recomputed on open. | | `openMs` | Time this call took | Opening the same token again is free and returns only a pointer to the stored dashboard: ```json { "id": "cbb5cc78-4f1c-463e-bcc0-a106715cac77", "replay": true, "charged": false } ``` Two opens of one token at the same moment share one charge and one stored dashboard. ### Errors | Status | Message | |---|---| | `404` | `That prediction has expired. Ask the question instead.` Also the answer for an unknown token, a token longer than 100 characters, and a token computed for another workspace or person. | | `402` | `Out of credits: …` Nothing was charged. The token can be opened again until it expires. | ## Read a stored answer ```http GET /api/ask2/d/:id ``` Returns the UI spec and the build record of a stored dashboard. Free. It returns no rows: get those from [`GET /api/dashboards/:id`](https://openpipe.health/docs/api/saved.md#open-a-dashboard). ```sh curl "$OPH_API/api/ask2/d/f4b85ea7-00bd-4622-831d-aac31a7d22b3" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "id": "f4b85ea7-00bd-4622-831d-aac31a7d22b3", "question": "top TAVR operators in Florida", "ui": { "root": "board", "elements": { "board": { "type": "Board", "props": { "title": "Top clinicians for tAVR in Florida" }, "children": ["top", "stats", "map", "split", "groups"] } } }, "meta": { "v": 2, "tier": "instant", "kind": "ask", "recipe": "proc_top_clinicians", "parent": null } } ``` | Field | Meaning | |---|---| | `ui` | The spec: `root` and `elements`, with every tile's SQL | | `meta` | As in the [done event](#the-done-event). `null` for a dashboard that was not made through `/api/ask2`. | A dashboard made by `POST /api/ask` has no stored spec. One is laid out from its first 8 tiles, with tile ids `t0`, `t1` and so on. ### Errors | Status | Message | |---|---| | `404` | `No answer with that id in this workspace.` Also the answer for an id that is not a UUID and for a dashboard in another workspace. | ## Recipes, prices and limits ```http GET /api/ask2/about ``` Lists the recipes and the numbers on this page, read from the running server. Free. ```sh curl "$OPH_API/api/ask2/about" -H "Authorization: Bearer $OPH_KEY" ``` ```json { "recipes": [ { "id": "proc_top_clinicians", "label": "Top clinicians for a procedure", "flow": "list" }, { "id": "hospital_profile", "label": "Hospital profile", "flow": "account" }, { "id": "proc_market_by_state", "label": "Procedure market by state", "flow": "market" } ], "thresholds": { "instant": 0.5, "unsureBelow": 0.7 }, "credits": { "instant": 5, "planned": 25, "preview": 0, "predict": 0, "openPredicted": 5 }, "limits": { "previewPerMinute": 300, "previewModelPerMinute": 150, "instantPerMinute": 60, "plannedPerMinute": 10, "predictPerMinute": 20 } } ``` `recipes` is trimmed here. `flow` is `list` (a ranking of people or accounts), `account` (one hospital, group or clinician) or `market` (size and spread). Pass a recipe's `id` as `pin` to [`/ask`](#ask-a-question). --- # Saved dashboards URL: https://openpipe.health/docs/api/saved/ Markdown: https://openpipe.health/docs/api/saved.md > Every Ask answer is stored as a dashboard. Open it from its stored result, refresh it for free, and save it to keep it. Every completed answer from [Ask](https://openpipe.health/docs/api/ask.md) is stored as a dashboard in the workspace: first as a recent answer, and for good once a signed-in person saves it. A dashboard stores its last result. Opening it returns that stored result without running anything. Refreshing it runs the statements the answer was planned with again and replaces the stored result. None of the endpoints on this page spend credits. They act in one [workspace](https://openpipe.health/docs/workspaces.md), and an id that belongs to another workspace answers `404`, the same as an id that never existed. ## Who can do what | | API key | Member | Owner or admin | |---|---|---|---| | List, open and refresh dashboards | Yes | Yes | Yes | | [Export](https://openpipe.health/docs/api/exports.md#export-a-tile-of-an-answer) a tile (10 credits) | Yes | Yes | Yes | | Save a dashboard | No | Yes | Yes | | Rename or delete a recent (unsaved) dashboard | No | Yes | Yes | | Rename, unsave or delete a saved dashboard | No | Only one they saved | Yes | - "Member", "owner" and "admin" mean a signed-in person with a [session token](https://openpipe.health/docs/authentication.md#two-kinds-of-token). In your personal workspace you are the owner. - Every response carries a `can` object (`save`, `modify`, `delete` on a dashboard; `delete` in lists) that says what this caller may do with it. A refused call answers `403`. With an API key the message is `An API key can list, open and refresh saved answers. Sign in to save, rename or delete them.` For a member it is `Only the person who saved this, or a workspace owner or admin, can change or delete it.` ## Limits | Limit | Value | |---|---| | Saved dashboards per workspace | 200 | | Recent (unsaved) answers kept per workspace | The newest 50. Older ones are deleted. Saved dashboards are never deleted this way. | | Name length | 120 characters | | Refreshes | 20 per minute per workspace | | Refreshes running at once | 2 per workspace | | Stored result of a dashboard | 50 rows per `table` tile, 100 rows per tile of any other type, 8 tiles, 256 KB for all tiles together | Old recent answers are removed when the dashboard list is requested, at most once a minute per workspace. ## Refreshing is free but rationed A refresh runs the stored statements through the same [checks](https://openpipe.health/docs/receipts.md#how-model-written-sql-is-checked) they passed when the question was asked: the parse check, the read-only role, the time limit and a row cap. It costs nothing, so it has its own limits. - **20 refreshes per minute per workspace.** Past that the response is `429` with `Retry-After` and `{ "error": "Too many refreshes. Try again in 41s.", "code": "RATE_LIMITED" }`. - **2 refreshes at a time per workspace.** A third answers `429` with `Retry-After: 3` and: ```json { "error": "Other refreshes are still running in this workspace. Try again in a few seconds.", "code": "REFRESH_BUSY" } ``` - **The same dashboard refreshing twice at once is one run.** A second request for a dashboard that is already refreshing waits for that run and gets its result. It still counts toward the 20. These limits apply on top of the [general rate limits](https://openpipe.health/docs/api/errors.md#rate-limits). On a successful refresh the `RateLimit-*` headers describe the workspace's general limit of 300; on a `429` from the refresh limit they describe the 20. ## Newer data available Each stored result remembers when it was computed (`refreshedAt`) and which dataset versions it read (`dataVersion`). When a dataset that the dashboard reads has been loaded again since then, it is marked stale: ```json "stale": true, "staleDatasets": [{ "dataset": "hospitals", "version": "2027-01", "loadedAt": "2027-01-14T09:02:11.000Z" }] ``` - `staleDatasets` holds one entry per dataset loaded after `refreshedAt`. In list responses it is an array of dataset names only. - A dashboard that has never been refreshed is not stale: it has no result to be out of date. - Nothing refreshes on its own. `stale` is a prompt to call the refresh endpoint. - Load times are re-read at most every 30 seconds, so the flag can lag a load by that long. ## List dashboards ```http GET /api/dashboards ``` Returns the workspace's answers from [Ask](https://openpipe.health/docs/api/ask.md), saved or not, newest first. | Parameter | Meaning | |---|---| | `saved` | `true` for saved dashboards only, ordered by when they were saved. `false` for recent answers only. Leave it out for both. | | `q` | Text to find in the name, the generated title or the question. Case-insensitive, 100 characters at most. | | `limit` | Default 20, maximum 100 | | `offset` | Default 0, maximum 10,000 | ```sh curl "$OPH_API/api/dashboards?saved=true&limit=2" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "rows": [ { "id": "df706628-076f-4fa8-9797-c5f6028915ab", "question": "Largest hospitals in Vermont by beds", "createdAt": "2026-12-05T04:20:08.121Z", "title": "Largest hospitals in Vermont by beds", "saved": true, "savedAt": "2026-12-05T04:21:30.000Z", "savedBy": { "email": "you@example.com", "you": false, "label": "you@example.com" }, "refreshedAt": "2026-12-05T04:22:43.437Z", "tiles": 1, "stale": false, "staleDatasets": [], "can": { "delete": false } } ], "more": false, "limit": 2, "offset": 0 } ``` - `more` is `true` when there are rows past this page. - `tiles` is the number of tiles, not their contents. - `savedBy` is `null` for a recent answer. `label` is `you` when a session token belongs to the person who saved it, otherwise their email, or `a teammate` when the email is not known. ## Open a dashboard ```http GET /api/dashboards/:id ``` Returns the answer with its stored rows. Nothing runs. ```sh curl "$OPH_API/api/dashboards/df706628-076f-4fa8-9797-c5f6028915ab" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json { "id": "df706628-076f-4fa8-9797-c5f6028915ab", "question": "Largest hospitals in Vermont by beds", "createdAt": "2026-12-05T04:20:08.121Z", "model": "claude-haiku-4-5", "title": "Largest hospitals in Vermont by beds", "name": null, "summary": "…", "followups": ["Which Vermont hospitals are critical access facilities?"], "tiles": [ { "index": 0, "tile": { "type": "leaderboard", "title": "Largest Vermont hospitals", "sql": "SELECT ccn, name, city, state, beds … LIMIT 25", "x": "name", "y": "beds", "format": "number" }, "columns": ["ccn", "name", "city", "state", "beds", "discharges", "net_patient_revenue"], "rows": [{ "ccn": "470005", "name": "RUTLAND REGIONAL MEDICAL CENTER", "city": "RUTLAND", "state": "VT", "beds": 134, "discharges": 5982, "net_patient_revenue": "331544608" }], "ms": 259, "sources": ["hospitals"], "engine": "postgres", "asOf": "2026-12-05T04:22:43.047Z" } ], "ms": 0, "credits": 0, "saved": false, "savedAt": null, "savedBy": null, "createdBy": null, "refreshedAt": "2026-12-05T04:22:43.047Z", "fromSnapshot": true, "stale": false, "staleDatasets": [], "dataVersion": { "hospitals": { "version": "enrollments 2026-11-12, cost report FY2024 final, owners 2026-11-12", "loadedAt": "2026-12-05T02:16:33.124Z" } }, "can": { "save": false, "modify": false, "delete": false } } ``` | Field | Meaning | |---|---| | `title` | The name if the dashboard was renamed, otherwise the generated title, otherwise the question | | `name` | The name someone gave it, or `null` | | `tiles` | Up to 8. Each has the tile as planned (`tile`, with its SQL as a [receipt](https://openpipe.health/docs/receipts.md)), the stored `columns` and `rows`, and `asOf`: when those rows were computed. A tile's place in this array is the `tile` index an [export](https://openpipe.health/docs/api/exports.md#export-a-tile-of-an-answer) takes. | | `ms` | Always `0`: nothing ran | | `fromSnapshot` | Always `true` | | `createdBy` | Who asked, or `null` when the question was asked with an API key | | `refreshedAt` | When the stored result was last replaced | A tile without usable rows comes back as `{ "index", "tile", "sources", "error" }`: | `error` | Why | |---|---| | `No result is stored for this tile yet. Refresh to load it.` | Nothing has been stored for it | | `This result is too large to keep here. Export the tile as a CSV to get every row.` | The dashboard passed 256 KB and this tile's rows were dropped, largest tile first. [Export the tile](https://openpipe.health/docs/api/exports.md#export-a-tile-of-an-answer). | | The statement's own error message | The tile has never run successfully. This includes a tile that failed when the question was asked: it is stored with its SQL so that a refresh can retry it. | A tile whose last refresh failed but that has older rows keeps them, and adds `refreshError` and `refreshErrorAt`. **An old answer can run once on first open.** An answer asked today is stored with the rows it was computed with. One stored before results were kept has none: the first `GET` of such an answer runs its tiles and stores the rows, under the same [refresh limits](#refreshing-is-free-but-rationed). If the workspace is over those limits at that moment, the answer still opens with status `200`, and each tile carries the "Refresh to load it" error. Returns `404` with `No saved answer with that id.` if the id is unknown, is not a UUID, or belongs to another workspace. ## Refresh a dashboard ```http POST /api/dashboards/:id/refresh ``` Runs every tile's stored SQL again, stores the capped result, and returns the dashboard in the same shape as [Open a dashboard](#open-a-dashboard) with one more field: ```sh curl -X POST "$OPH_API/api/dashboards/df706628-076f-4fa8-9797-c5f6028915ab/refresh" \ -H "Authorization: Bearer $OPH_KEY" ``` ```json "refresh": { "ok": 1, "failed": 0 } ``` - No model is called. The SQL is the SQL the answer was planned with; no endpoint accepts SQL, for a dashboard or anything else. - A tile that failed when the question was asked is run again too, so a refresh is the free way to retry it. - A tile that fails keeps the rows it had and records the error. The others are replaced. - `refreshedAt` moves only if at least one tile ran. If every tile fails, the old time still describes the rows. - `409` with `This answer has no tiles to refresh.` if the answer has no tiles. - `404` if the dashboard was deleted while its tiles ran. ## Save, unsave or rename a dashboard ```http PATCH /api/dashboards/:id ``` `POST` to the same path does the same. Needs a session token. See [who can do what](#who-can-do-what). ```json { "saved": true, "name": "Vermont hospitals by size" } ``` | Field | Meaning | |---|---| | `saved` | `true` saves the answer and records you as the person who saved it. `false` returns it to the recent answers. | | `name` | A new name, 1 to 120 characters after trimming. Control characters are removed. | Send one or both. Any other field (`sql`, `spec`, `tiles`, anything) is refused with `400`: a dashboard's statements cannot be changed. Returns the dashboard in the same shape as [Open a dashboard](#open-a-dashboard). Saving an answer that has no stored result runs its tiles once, as the first open does. | Status | Message | |---|---| | `400` | `Body must be a JSON object.` | | `400` | `Send "name", "saved" or both.` | | `400` | `Only "name" and "saved" can be changed. Unknown field: "sql".` | | `400` | `"saved" must be true or false.` | | `400` | `Give it a name of at least one character.` | | `403` | See [who can do what](#who-can-do-what) | | `409` | `A workspace can keep 200 saved dashboards. Remove one first.` | If two people save the same answer at once, one of them becomes `savedBy` and both calls succeed. ## Delete a dashboard ```http DELETE /api/dashboards/:id ``` Needs a session token. Returns `{ "deleted": "" }`, or `404`. A member's delete also answers `404` if someone else saved the answer in the moment before it. ## Things to know - **A key that tries to change something it cannot see gets `404`, not `403`.** The id is looked up in the caller's workspace first. - **Stored SQL is never trusted more than fresh SQL.** Every refresh and every tile export passes the same checks again, so a statement that was valid when the question was asked can fail later, for example after a table is renamed. - **Saved queries are gone.** `/api/queries` and everything under it answer `404`. The API no longer accepts SQL, so there is nothing to save but answers. - **Refresh limits are counted in memory, per server instance**, like the other [rate limits](https://openpipe.health/docs/api/errors.md#if-you-run-the-server). --- # Exports URL: https://openpipe.health/docs/api/exports/ Markdown: https://openpipe.health/docs/api/exports.md > Write every row of a list search, or of one tile of an answer, to a CSV of up to 500,000 rows and get a download link. ## Create an export ```http POST /api/exports ``` Writes a full result to a CSV file and returns a link to it. Costs 10 credits. An export is made by reference. You name something the server can already build or already holds, and the server runs the statement. The body takes one of two shapes: | Shape | Exports | |---|---| | `{ "list": …, "params": { … } }` | Every row of a [list search](#export-a-list), not just a page | | `{ "dashboard": "", "tile": }` | Every row of [one tile of a stored answer](#export-a-tile-of-an-answer) | **No SQL is accepted.** The body is validated strictly: any field that is not listed on this page, including `sql`, is a `400`. ### Export a list ```sh curl "$OPH_API/api/exports" \ -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \ -d '{"list": "providers", "params": {"hcpcs": "27447", "state": "TX", "min_services": 50}}' ``` `list` is `providers`, `facilities` or `groups`. `params` takes the filters of the matching search endpoint, without `limit` and `offset`, and the server builds the statement with the same code as the search. The CSV has the columns the search returns. | `list` | `params` | Same as | |---|---|---| | `providers` | `q`, `state`, `city`, `specialty`, `entity` (`"I"` or `"O"`), `hcpcs`, `min_services` (number), `sort` (`payment`, `patients` or `services`) | [`GET /api/providers`](https://openpipe.health/docs/api/providers.md) | | `facilities` | `q`, `state`, `city`, `min_beds` (integer), `ownership` (`proprietary` or `non-profit`), `private_equity` (boolean), `sort` (`beds`, `revenue` or `discharges`) | [`GET /api/facilities`](https://openpipe.health/docs/api/facilities.md) | | `groups` | `q`, `state`, `min_members` (integer), `specialty` | [`GET /api/groups`](https://openpipe.health/docs/api/groups.md) | Unlike the search endpoints, which take everything as query-string text, `params` is typed JSON: numbers are numbers, `private_equity` is `true` or `false`, `state` is two letters and `hcpcs` is five characters. A wrong type or an unknown filter is a `400`, not an empty result. `params` may be left out or empty, which exports the whole list up to the row limit. ### Export a tile of an answer ```sh curl "$OPH_API/api/exports" \ -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \ -d '{"dashboard": "df706628-076f-4fa8-9797-c5f6028915ab", "tile": 0}' ``` | Field | Meaning | |---|---| | `dashboard` | The id of a stored answer in this workspace: `id` from [Ask](https://openpipe.health/docs/api/ask.md#json-mode) or from [`GET /api/dashboards`](https://openpipe.health/docs/api/saved.md#list-dashboards) | | `tile` | The tile's position in the dashboard's `tiles` array, from 0 to 7 | The server runs the statement stored for that tile when the question was asked, through the same [checks](https://openpipe.health/docs/receipts.md#how-model-written-sql-is-checked) as any model-written SQL, with the export's limits in place of the tile's. A tile shows at most 50 or 100 rows; the export has every row the statement returns. If the statement itself ends in a `LIMIT`, as a ranking usually does, the export stops there too. An id that does not exist, an id from another workspace and a tile index the dashboard does not have all answer `404` with the same message. ### Response Returns `201`. ```json { "id": "2f0c6c0e-6d5b-4b55-9d0b-1f3c9d2a7e11", "source": { "list": "providers", "params": { "hcpcs": "27447", "state": "TX", "min_services": 50 } }, "rows": 1384, "bytes": 92140, "truncated": false, "engine": "postgres", "ms": 180, "url": "https://…/2f0c6c0e-….csv?X-Amz-Signature=…", "expiresIn": 3600, "usage": { "credits": 10, "creditsUsed": 25, "creditsLimit": 100, "txid": "81250" } } ``` | Field | Meaning | |---|---| | `source` | What was exported: `{ list, params }`, or `{ dashboard, tile, title }` | | `url` | A signed download link. Anyone with the link can download the file until it expires. | | `expiresIn` | Seconds until `url` stops working. Always 3600. | | `truncated` | `true` if more than 500,000 rows matched and the rest were left out | | `bytes` | Size of the CSV | | `engine` | `postgres` or `duckdb`. See [which engine ran](https://openpipe.health/docs/receipts.md#which-engine-ran). | The file is UTF-8 CSV with a header row. Each export gets a new file; nothing is overwritten. ### Limits and charging | Limit | Value | |---|---| | Rows | 500,000 | | Time | 30 seconds | | Exports | 10 per minute per workspace | | Price | 10 credits | - The balance must cover 10 credits before anything runs, or the answer is `402`. - The charge is made after the statement has run. An export that is rejected, fails or times out is free. ### Errors | Status | Message | Cause | |---|---|---| | `400` | `Exports do not accept SQL. Send {"dashboard": …} … or {"list": …} …` | The body has a `sql` field | | `400` | `Send {"dashboard": "", "tile": } … or {"list": …, "params": {...}} …` | Neither shape, or both at once | | `400` | `Invalid export request. params.state: must be a two-letter USPS state code` | A field of the wrong type or value, or an unknown filter | | `400` | `"list" must be "providers", "facilities" or "groups".` | | | `400` | `The export exceeded the 30s time limit. Narrow the list with a filter.` | | | `400` | The statement's own error | A tile whose stored statement no longer runs | | `404` | `No stored answer with that id and tile in this workspace.` | The id is unknown, belongs to another workspace, or the dashboard has no tile at that index | | `409` | `This tile has no result to export yet. Refresh the answer … and export it once the tile has rows.` | The tile failed when the question was asked and has never returned rows. [Refresh the dashboard](https://openpipe.health/docs/api/saved.md#refresh-a-dashboard) (free) first | | `402`, `429` | | See [Credits](https://openpipe.health/docs/credits.md#running-out) and [Rate limits](https://openpipe.health/docs/api/errors.md#rate-limits) | ## List exports ```http GET /api/exports ``` Returns your 20 most recent exports, newest first, each with a fresh one-hour link. Not metered. ```json { "rows": [ { "id": "2f0c6c0e-…", "rows": 1384, "bytes": 92140, "createdAt": "2026-12-05T02:14:09.000Z", "url": "https://…" } ] } ``` If a link has expired, call this endpoint for a new one. You are not charged again. --- # Account and keys URL: https://openpipe.health/docs/api/account/ Markdown: https://openpipe.health/docs/api/account.md > Your workspace, credit balance, API keys and usage history. None of the endpoints on this page spend credits. All of them act in one [workspace](https://openpipe.health/docs/workspaces.md): the one that created the API key, or the one a session token selects with `X-Oph-Workspace`. ## Get your account ```http GET /api/me ``` ```json { "account": { "id": "8a1f…", "email": "you@example.com", "plan": "free" }, "workspace": { "kind": "personal", "orgId": null, "role": "owner" }, "credits": { "used": 42, "limit": 100 }, "keys": [ { "id": "c3d2…", "name": "notebook", "prefix": "oph_Ab12Cd34", "createdAt": "2026-12-01T17:02:11.000Z", "lastUsedAt": "2026-12-05T01:58:40.000Z" } ] } ``` | Field | Meaning | |---|---| | `account` | The workspace's billing record. `id` is the workspace's account id and `plan` its plan. For an organization workspace, `email` is the address of the member who first opened it, not necessarily yours. | | `workspace.kind` | `personal` or `organization` | | `workspace.orgId` | The organization id, or `null` for a personal workspace | | `workspace.role` | Your role in this request: `owner`, `admin` or `member`. A session in its personal workspace is `owner`. A request made with an API key always reports `member`. | | `credits` | `used` counts the workspace's current calendar month; `limit` is its monthly allowance | | `keys` | The workspace's active keys, newest first. Revoked keys are left out. Every member can see this list. | ## Create a key ```http POST /api/keys ``` Needs a [session token](https://openpipe.health/docs/authentication.md#two-kinds-of-token) from an owner or admin of the workspace. The key is created in the workspace the request acts in, so send `X-Oph-Workspace` to create one for an organization. | Body field | Type | Description | |---|---|---| | `name` | string | A label for the key. Cut to 60 characters. Defaults to `default`. | Returns `201`: ```json { "id": "c3d2…", "name": "notebook", "prefix": "oph_Ab12Cd34", "createdAt": "2026-12-05T02:20:00.000Z", "key": "oph_Ab12Cd34…" } ``` `key` is returned only here. Store it now. | Status | Message | Cause | |---|---|---| | `403` | `Sign in to do that; an API key cannot.` | Called with an API key | | `403` | `Only workspace owners and admins can do that.` | Called by a member of an organization workspace | | `409` | `A workspace can have 20 active keys. Revoke one first.` | The workspace already has 20 active keys | ## Revoke a key ```http DELETE /api/keys/:id ``` Needs a session token from an owner or admin of the workspace, like creating a key. Any owner or admin can revoke any of the workspace's keys, not only the ones they created. Returns `{ "revoked": "" }`, or `404` with `No such key.` if the key does not exist, is already revoked, or belongs to another workspace. The `403` responses are the same as for [creating a key](#create-a-key). ## List usage ```http GET /api/usage ``` The workspace's last 100 metered calls, newest first. In an organization workspace that is every member's and every key's calls together. ```json { "rows": [ { "id": 5120, "kind": "ask", "credits": 25, "meta": { "via": "api_key", "question": "Largest hospitals in Vermont by beds" }, "createdAt": "2026-12-05T02:14:09.000Z" } ] } ``` `kind` is `search`, `lookup`, `ask` or `export`. `meta` records what was asked: the route and filters for a search, the question for Ask, the dashboard and tile or the list and its filters for an export. Records from before the SQL endpoint was removed have `kind` set to `sql`. `meta.via` says how the call was made: `api_key`, `session`, or `mcp` for a tool call through the [MCP server](https://openpipe.health/docs/mcp.md). Session calls also carry `meta.user`, the id of the signed-in person. MCP calls carry `meta.tool`. ## Saved dashboards Listing, opening, refreshing, renaming and deleting dashboards are on their own page: [Saved dashboards](https://openpipe.health/docs/api/saved.md). They are free too. ## Live feeds `POST /api/live/usage` and `POST /api/live/pipeline` return `{ url, sealed }` for the app's live usage and data-pipeline views. They exist for the app and may change without notice. --- # Onboarding profile URL: https://openpipe.health/docs/api/profile/ Markdown: https://openpipe.health/docs/api/profile.md > What a signed-in person told the app about their role, product and territory. Session only, free, and used to frame Ask answers. The web app asks a new person a few questions: what their company sells, their role, who they sell to, what their product is for, and which states they cover. The answers are their profile. [Ask](https://openpipe.health/docs/api/ask.md#answers-framed-for-the-asker) uses it to frame answers. A profile belongs to a person, not to a workspace and not to an API key. It follows the person into every workspace they open. - **Session only.** Every endpoint on this page needs a [session token](https://openpipe.health/docs/authentication.md#two-kinds-of-token). An API key gets `403` with `A profile belongs to a signed-in person. An API key does not have one.` - **Free.** Nothing here spends credits. - **No user id in any request.** The profile read or written is always the one of the person the session belongs to. - **Request bodies are at most 8 KB.** A larger one gets `413` with code `TOO_LARGE`. These endpoints exist for the app's onboarding screens. They are documented so the behaviour is clear. ## Limits Counted per person, per minute, in every workspace together. Switching workspace does not reset them. They apply on top of the [general rate limits](https://openpipe.health/docs/api/errors.md#rate-limits), and on these four endpoints the `RateLimit-*` headers describe the limit below. | Endpoint | Limit | |---|---| | `PUT /api/profile` | 120 per minute | | `GET /api/profile/resolve` | 90 per minute | | `POST /api/profile/market` | 12 per minute | | `POST /api/profile/suggestions` | 6 per minute | `GET /api/profile` has no limit of its own. ## Get your profile ```http GET /api/profile ``` ```sh curl "$OPH_API/api/profile" -H "Authorization: Bearer $OPH_SESSION" ``` `$OPH_SESSION` stands for a session token. See [Authentication](https://openpipe.health/docs/authentication.md#browser-sign-in) for how the app gets one. ```json { "profile": { "sells": "devices", "role": "rep", "buyers": ["hospitals", "clinicians"], "focus": { "text": "knee replacement", "items": [{ "kind": "procedure", "code": "27447", "label": "…" }] }, "territory": ["FL", "GA"], "suggestions": null, "step": 4, "completedAt": null, "skippedAt": null, "updatedAt": "2026-12-05T04:10:02.000Z" }, "exists": true } ``` | Field | Values | |---|---| | `sells` | `devices`, `pharma`, `diagnostics`, `healthit`, `services`, `other`, or `null` | | `role` | `rep`, `leader`, `marketing`, `analyst`, `bizdev`, `founder`, or `null` | | `buyers` | Any of `hospitals`, `groups`, `clinicians`, `asc`, `labs` | | `focus.text` | What the person typed, up to 80 characters | | `focus.items` | Up to 5 things in the data that the text was matched to. See [focus items](#focus-items). | | `territory` | Two-letter codes of the 50 states and DC, sorted | | `suggestions` | The last result of [Build suggestions](#build-suggestions), or `null` | | `step` | The onboarding step the person is on, 0 to 5 | | `completedAt`, `skippedAt` | When the person finished or skipped onboarding | A person with no profile yet gets an empty one and `"exists": false`. ## Update your profile ```http PUT /api/profile ``` Send only the fields to change. Each one replaces the stored value. ```json { "role": "rep", "territory": ["FL", "GA"], "step": 4 } ``` | Field | Rule | |---|---| | `sells`, `role` | One of the values above, or `null` | | `buyers` | An array of the values above | | `focus` | `{ "text": "…", "items": [ … ] }`. `text` can be 200 characters; it is stripped of markup and control characters and cut to 80. At most 5 items. | | `territory` | An array of state codes. Anything other than the 50 states and DC is rejected. | | `step` | An integer from 0 to 5 | | `status` | `completed` sets `completedAt` and clears `skippedAt`. `skipped` sets `skippedAt`, unless the profile is already completed. | An unknown field is rejected, at the top level and inside `focus` and its items. Returns `{ "profile": { … } }` with the stored profile. | Status | Message | |---|---| | `400` | `Invalid profile: : ` | | `413` | `Request body is too large (8 KB limit).` | | `429` | `Too many profile updates. Try again in 12s.` | ### Focus items An item names one thing in the data, in one of three shapes: ```json { "kind": "procedure", "code": "27447" } { "kind": "drug", "name": "Apixaban", "by": "generic" } { "kind": "specialty", "name": "Cardiology" } ``` - `code` is a five-character HCPCS code. `by` is `generic` or `brand`. - Every item is checked against the data. A code or name that is not there is dropped without an error, and duplicates are removed. - `label` is written by the server from its own index. A `label` sent in the request is ignored. Use [Match text to the data](#match-text-to-the-data) to get items that will pass the check. ## Match text to the data ```http GET /api/profile/resolve ``` Turns what someone typed into procedures, drugs and specialties that exist in the data. It is fast enough to call as a person types. | Parameter | Meaning | |---|---| | `q` | The text. Fewer than 2 characters, not counting spaces, returns no matches. Only the first 80 characters are used, and more than 200 is rejected. | | `sells` | Optional. One of the `sells` values, used to rank the kinds of match. | ```json { "q": "knee", "matches": [ … ], "drugsPending": false, "guess": null } ``` - `matches` are candidates to offer as [focus items](#focus-items). - `drugsPending` is `true` while the drug names are still loading; drug matches can be missing until then. - `guess` is `procedure`, `drug`, `specialty`, `unclear` or `null`. It is set only when the text matched more than one kind of thing and a classifier answered in time. - The response has a `Server-Timing` header with the time spent matching. ## Size your market ```http POST /api/profile/market ``` Takes no body. Computes a few headline numbers for the profile's buyers, focus and territory. ```json { "headline": "…", "scope": "…", "metrics": [ { "id": "…", "label": "…", "format": "number", "sql": "SELECT …", "sources": ["medicare_service"], "value": 1234, "detail": null, "engine": "postgres", "ms": 40 } ], "ms": 412 } ``` - Every metric carries the SQL that produced it and the datasets it read, like any other [receipt](https://openpipe.health/docs/receipts.md). Each statement runs through the read-only checks with a time limit of 8 seconds. - A metric that fails has `"value": null` and an `error`. The others are still returned. - A result with no failed metric is kept for 10 minutes and returned with `"cached": true` to anyone whose buyers, focus and territory are the same. - When the numbers cannot be computed yet, the response is still `200`, with an `unavailable` message and `retry`: `true` if it is worth asking again shortly. - `409` with `Your saved focus no longer matches the data. Pick it again.` if a focus item is no longer in the data. ## Build suggestions ```http POST /api/profile/suggestions ``` Takes no body. Builds starter questions and dashboard ideas for the profile, stores them on it, and returns them. ```json { "suggestions": { "questions": [{ "text": "…", "family": "…" }], "dashboards": [{ "title": "…", "question": "…", "family": "…" }], "source": "templates", "builtAt": "2026-12-05T04:12:44.000Z" }, "timing": { "ms": 380, "decisionMs": 120, "decision": "used" } } ``` - Questions come from templates filled in with the profile. `source` is `templates+model` when a model added up to two more; those have `"family": "model"`. - `timing.decision` is `used` when a model ranked the templates for this person, and `fallback` when it was unavailable and the default order was used. - The suggestions are text to send to [Ask](https://openpipe.health/docs/api/ask.md). Building them runs no query against the data and costs nothing; asking one costs the usual 25 credits. --- # Meta and health URL: https://openpipe.health/docs/api/meta/ Markdown: https://openpipe.health/docs/api/meta.md > Public endpoints that describe the loaded data and the state of the service. These endpoints need no token and spend no credits. ## List datasets ```http GET /api/meta ``` Returns one entry per loaded dataset, largest first. This is where a name in a response's `sources` array resolves to a publisher, version and download URL. ```json { "sources": [ { "dataset": "medicare_service", "title": "Medicare Physician & Other Practitioners, by Provider and Service", "publisher": "CMS", "url": "https://data.cms.gov/…/PHY_R26_P05_V10_D24_Prov_Svc.csv", "version": "R26 P05 V10", "data_year": 2024, "row_count": "9781673", "raw_keys": ["…"], "parquet_key": "…", "parquet_bytes": 123456789, "in_postgres": true, "loaded_at": "2026-12-05T01:20:00.000Z" } ], "sql": "SELECT dataset, title, publisher, url, version, data_year, row_count, raw_keys, parquet_key, parquet_bytes, in_postgres, loaded_at FROM sources ORDER BY row_count DESC NULLS LAST" } ``` | Field | Meaning | |---|---| | `dataset` | The name used in `sources` arrays and in the [data catalog](https://openpipe.health/docs/data/catalog.md) | | `version` | The publisher's release identifier | | `data_year` | The year the data describes, which is earlier than the year it was published | | `row_count` | Rows loaded | | `in_postgres` | `false` for a dataset held only in the analytics store, such as `partd_drug`. Queries on it always run on DuckDB. | | `loaded_at` | When this copy was loaded | ## Health ```http GET /api/health ``` ```json { "ok": true, "branch": "main", "postgres": { "db": "neondb", "version": "PostgreSQL 17.2", "ms": 2 }, "services": { "isolatedSqlRole": true, "auth": true, "aiGateway": true, "objectStorage": true, "realtime": true, "lake": "s3://datasets", "function": true } } ``` `services` shows which parts are configured. `isolatedSqlRole` is `true` when the SQL the model writes runs on its own read-only database login. If `aiGateway` is `false`, [Ask](https://openpipe.health/docs/api/ask.md) will fail. If `objectStorage` is `false`, [Exports](https://openpipe.health/docs/api/exports.md) will fail. `lake` is `false` when the analytics engine is unavailable, in which case every statement runs on Postgres. ## Config ```http GET /api/config ``` Returns `realtimeUrl` and `model` for the browser app. `realtimeUrl` is `null` when live feeds are not configured. `model` is the model that answers [Ask](https://openpipe.health/docs/api/ask.md). --- # Errors URL: https://openpipe.health/docs/api/errors/ Markdown: https://openpipe.health/docs/api/errors.md > Status codes, the error body, rate limits and request size limits. Every error is JSON with an `error` message: ```json { "error": "NPI must be 10 digits." } ``` Some errors add a machine-readable `code`: ```json { "error": "Too many requests. Try again in 23s.", "code": "RATE_LIMITED" } ``` `code` is present on `429` (`RATE_LIMITED`, or `REFRESH_BUSY` when a workspace already has two [refreshes](https://openpipe.health/docs/api/saved.md#refreshing-is-free-but-rationed) running), on `413` (`TOO_LARGE`), on `502` from Ask (`ASK_FAILED`) and on errors from the [sign-in endpoints](https://openpipe.health/docs/authentication.md#browser-sign-in) under `/api/auth/`. Other errors have only `error`. The message is written to be shown to a person. Branch on the status code, and on `code` where there is one, not on the text. | Status | Meaning | What to do | |---|---|---| | `400` | The request is malformed, has a field the endpoint does not take, or an export could not run | Fix the request; the message says how. Not charged. | | `401` | Missing, unknown, revoked or expired token | See [Authentication](https://openpipe.health/docs/authentication.md#failures) | | `402` | Out of credits for the month | Wait for the monthly reset or raise your limit. See [Credits](https://openpipe.health/docs/credits.md#running-out). | | `403` | Not a member of the workspace named in `X-Oph-Workspace`; key management called with an API key or by a member; a dashboard saved, renamed or deleted by an API key, or changed by a member who does not own it; `/api/profile` called with an API key | See [Authentication](https://openpipe.health/docs/authentication.md#failures), [Roles](https://openpipe.health/docs/workspaces.md#roles) and [who can do what](https://openpipe.health/docs/api/saved.md#who-can-do-what) | | `404` | No provider, hospital, group, key, dashboard, dashboard tile or catalog dataset with that id or name. A dashboard in another workspace answers `404` too. So do the removed endpoints: `POST /api/sql` and everything under `/api/queries`. | Check the id. Lookups that miss are not charged. | | `409` | The workspace already has 20 active API keys or 200 saved dashboards; a dashboard with no tiles was refreshed | Remove one first, or see [Saved dashboards](https://openpipe.health/docs/api/saved.md) | | `413` | Request body larger than 64 KB, or 8 KB under `/api/profile` | Send a smaller body. See [Request size](#request-size). | | `429` | Rate limited | Wait the number of seconds in `Retry-After`. See [Rate limits](#rate-limits). | | `502` | [Ask](https://openpipe.health/docs/api/ask.md#json-mode) in JSON mode: the model could not plan an answer. `code` is `ASK_FAILED` and `charged` is `false`. | Rephrase the question, or name the procedure, drug or state you mean. Nothing was charged. | | `500` | `Internal error.` | Retry once. If it repeats, check [`/api/health`](https://openpipe.health/docs/api/meta.md#health). | The [MCP server](https://openpipe.health/docs/mcp.md#errors) reports errors differently: JSON-RPC errors for protocol problems, and tool results marked `isError` for failed tool calls. ## Order of checks A request under `/api/` passes these checks in order, and stops at the first that fails: 1. Rate limit per client address (`429`) 2. Request size (`413`) 3. Authentication and workspace (`401`, `403`) 4. Rate limits per workspace (`429`) 5. Credit pre-check, on metered endpoints only (`402`) 6. The endpoint's own validation and work (`400`, `404`, and `402` if this call would pass the limit) Two consequences: - A workspace that has already spent its allowance gets `402` from every metered endpoint before the request is validated or anything runs. See [Running out](https://openpipe.health/docs/credits.md#running-out). - Requests that fail authentication still count against the per-address limit. ## SQL is not accepted No endpoint and no MCP tool takes SQL. `POST /api/sql` and `/api/queries` answer `404`, [`POST /api/exports`](https://openpipe.health/docs/api/exports.md#errors) answers `400` to a body with a `sql` field, and the endpoint that renames or saves a dashboard answers `400` to any field other than `name` and `saved`. The `sql` fields in responses are [receipts](https://openpipe.health/docs/receipts.md). ## Errors inside an Ask stream Once [`/api/ask`](https://openpipe.health/docs/api/ask.md) starts streaming, the HTTP status is already `200`. Failures arrive as events: - `tile_error`: one tile failed. Others still arrive, and `done` reports the count in `failed`. A free [refresh](https://openpipe.health/docs/api/saved.md#refresh-a-dashboard) of the stored dashboard retries it. - `error`: the answer could not start. With `code: "ASK_FAILED"` and `charged: false`, the model could not plan and nothing was charged; with `status: 402`, the balance ran out before the charge. The stream ends. See [errors inside the stream](https://openpipe.health/docs/api/ask.md#errors-inside-the-stream). In [JSON mode](https://openpipe.health/docs/api/ask.md#json-mode) the same failures are ordinary responses: failed tiles are listed in `failed`, and a failed plan is a `502`. ## Rate limits Requests are rate limited. The limits stop bursts and runaway loops; the hard cap on spend is still your [credits](https://openpipe.health/docs/credits.md). | Applies to | Limit | Counted per | |---|---|---| | Every request under `/api/`, including public and sign-in endpoints | 900 per minute | Client address | | Every authenticated request under `/api/` | 300 per minute | Workspace | | `/api/ask`, together with the MCP `ask` tool | 10 per minute | Workspace | | `POST /api/exports` (listing with `GET` counts only toward the 300) | 10 per minute | Workspace | | [Refreshing](https://openpipe.health/docs/api/saved.md#refreshing-is-free-but-rationed) a dashboard | 20 per minute, and 2 running at once | Workspace | | [`/api/catalog`](https://openpipe.health/docs/data/catalog.md#limits) | 240 per minute | Workspace | | `/api/catalog/search` | 180 per minute | Workspace | | `/api/catalog/:table/sample` | 40 per minute | Workspace | | [`/api/profile`](https://openpipe.health/docs/api/profile.md#limits): 120 updates, 90 lookups, 12 market summaries, 6 suggestion builds per minute | See left | Signed-in person | | [`/mcp`](https://openpipe.health/docs/mcp.md#limits) | 120 per minute | API key and client address together | How they combine: - **Limits stack.** A call to `/api/ask` counts against the per-address limit, the workspace's 300 and the workspace's 10. It must be under all three. - **Workspace limits are shared.** Every key and every signed-in member of a workspace draws on the same counters. - **Rejected requests count.** A request that gets `429` still counts toward the limits checked before it and the one that rejected it, though it cannot extend the window. - **Windows are fixed.** A window starts at the first request and lasts 60 seconds. The count returns to zero when it ends; it is not a sliding average. ### Headers Responses carry the state of one limit: | Header | Meaning | |---|---| | `RateLimit-Limit` | Requests allowed per window | | `RateLimit-Remaining` | Requests left in the current window | | `RateLimit-Reset` | Seconds until the window ends | | `Retry-After` | Only on `429`: seconds to wait. Same value as `RateLimit-Reset`. | When several limits apply, the headers describe the last one checked. On a successful call that is the most specific: the 10 on `/api/ask`, the 300 on `/api/providers`, the 900 on a public endpoint such as `/api/health`. The refresh limit is the exception: a successful refresh reports the 300, and only its `429` reports the 20. On a `429` they describe the limit that rejected the request. On a `401` they describe the per-address limit, because the workspace is not yet known. ### The 429 response ```http HTTP/1.1 429 Too Many Requests RateLimit-Limit: 10 RateLimit-Remaining: 0 RateLimit-Reset: 23 Retry-After: 23 ``` ```json { "error": "Too many requests. Try again in 23s.", "code": "RATE_LIMITED" } ``` Nothing is charged for a `429`. Wait `Retry-After` seconds, then retry. ### Sign-in limits The [sign-in](https://openpipe.health/docs/authentication.md#browser-sign-in) and [workspace](https://openpipe.health/docs/workspaces.md#workspace-endpoints) endpoints under `/api/auth/` have their own limits, counted over 10 minutes. Where an email is involved, the limit applies per client address and per email address separately. | Action | Per address | Per email | |---|---|---| | Password sign-up | 20 | 8 | | Password sign-in | 20 | 8 | | Sending a code (`POST /api/auth/code`) | 10 | 4 | | Checking a code (sign-in, verify and reset together) | 30 | 10 | | Creating a workspace | 10 | | | Creating an invitation | 30 | | | Accepting or rejecting an invitation | 30 | | Past one of these, the response is `429` with `Retry-After` and a body such as `{ "error": "Too many attempts. Try again in 412s.", "code": "RATE_LIMITED" }`. The `RateLimit-*` headers on these endpoints describe the general per-address limit, not these. ### If you run the server - **Counters are in memory, per server instance.** On one long-running server the limits are exact. With several instances behind a load balancer, a client can get up to that many times each limit, and a restart clears the counters. The credit ledger is in Postgres and is exact everywhere. - **The client address comes from `X-Forwarded-For`, counted from the right.** Set `TRUSTED_PROXY_HOPS` to the number of proxies in front of the server. The default is `1`: the address is the last entry in the header, the one your own proxy appended. With `0` the header is ignored and the socket address is used. A wrong value either lets clients choose their own address or puts every client behind one address. ## Request size A request body under `/api/` can be at most 64 KB. A larger one gets: ```json { "error": "Request body is too large (64 KB limit).", "code": "TOO_LARGE" } ``` with status `413`. This is checked before authentication. The [MCP endpoint](https://openpipe.health/docs/mcp.md#limits) has its own limit of 256 KB, and the [profile endpoints](https://openpipe.health/docs/api/profile.md) a smaller one of 8 KB, checked after authentication. --- # Datasets URL: https://openpipe.health/docs/data/datasets/ Markdown: https://openpipe.health/docs/data/datasets.md > The public files behind the API, with their versions and row counts. Everything the API returns comes from public files. Most are published by the Centers for Medicare & Medicaid Services (CMS). The others come from ASTP/ONC (hospital EHR attestations), HRSA (health center sites), the National Library of Medicine (ClinicalTrials.gov), the National Institutes of Health (RePORTER) and the FDA (drug names). The pipeline downloads each file, loads it into Postgres, and archives a Parquet copy. In the table, a source with no publisher named is a CMS file. The [data catalog](https://openpipe.health/docs/data/catalog.md) serves the same list over the API, with every column described and profiled. The table below is a snapshot from 5 December 2026. [`GET /api/meta`](https://openpipe.health/docs/api/meta.md#list-datasets) always has the current list, with the download URL of each file. | Table | Source file | Version | Data year | Rows | |---|---|---|---|---| | `partd_drug` | Medicare Part D Prescribers, by Provider and Drug | RY26 P04 V10 | 2024 | 28,023,892 | | `medicaid_drug_state` | Medicaid State Drug Utilization Data (Medicaid.gov), with names from the FDA NDC Directory. Lake only. | SDUD 2024 and 2025, updated July 2026; NDC Directory 2026-12-04 | 2024 and 2025 | 9,976,129 | | `medicare_service` | Medicare Physician & Other Practitioners, by Provider and Service | R26 P05 V10 | 2024 | 9,781,673 | | `providers` | NPPES NPI Registry, monthly file, with NUCC taxonomy 26.1 | November 2026 V2 | 2026 | 9,531,103 | | `open_payments` | Open Payments general payments, aggregated to clinician and company | PGYR2024 | 2024 | 4,578,218 | | `group_members` | Revalidation Reassignment List, clinician-to-group links | 2026-11 | 2026 | 3,764,899 | | `ma_enrollment_county` | Medicare Advantage / Part D Monthly Enrollment by Contract/Plan/State/County | November 2026 | 2026 | 3,387,584 | | `clinician_facilities` | Doctors and Clinicians: Facility Affiliation Data | 2026-11-12 | 2026 | 2,280,190 | | `partd_provider` | Medicare Part D Prescribers, by Provider | RY26 P04 V20 | 2024 | 1,416,883 | | `trial_sites` | ClinicalTrials.gov (National Library of Medicine): US sites of interventional studies | API v2, downloaded 2026-12-05 | 2026 | 1,370,232 | | `medicare_provider` | Medicare Physician & Other Practitioners, by Provider | R26 P05 V10 | 2024 | 1,296,739 | | `facility_owners` | SNF, HHA, Hospice, FQHC and RHC All Owners, and Nursing Home Ownership | SNF 2026-11-12; HHA, hospice, FQHC, RHC 2026-09-29; nursing home ownership November 2026 | 2026 | 686,080 | | `rollup_medicaid_drug_state` | Derived: Medicaid drug volume by drug, state and year | SDUD 2024 and 2025, updated July 2026 | 2024 and 2025 | 346,210 | | `hospital_measures` | Care Compare hospital measures: mortality, safety, readmissions, infections, timely care, patient survey, spending | Care Compare 2026-11-12 | 2025 | 303,620 | | `nih_grants` | NIH RePORTER: funded projects and principal investigators, linked to NPI by name | API v2, fiscal years 2024 to 2026, downloaded 2026-12-05 | 2024 to 2026 | 292,397 | | `trial_investigators` | ClinicalTrials.gov: study officials and site investigators, linked to NPI by name | API v2, downloaded 2026-12-05 | 2026 | 239,175 | | `groups` | Revalidation Reassignment List, group practices | 2026-11 | 2026 | 219,703 | | `trials` | ClinicalTrials.gov: interventional studies with a US site | API v2, downloaded 2026-12-05 | 2026 | 165,307 | | `hospital_owners` | Hospital All Owners | 2026-11-12 | 2026 | 147,029 | | `hospital_drgs` | Medicare Inpatient Hospitals, by Provider and Service (MS-DRG) | RY26 P03 V10 | 2024 | 145,879 | | `drug_spending` | Medicare Part D, Medicare Part B and Medicaid Spending by Drug | RY26 (Part D P04 V10, Part B P06 V10, Medicaid P06 V20) | 2020 to 2024 | 142,925 | | `rollup_hcpcs_state` | Derived: procedure volume by code and state | R26 P05 V10 | 2024 | 128,881 | | `rollup_drug_state` | Derived: Medicare Part D volume by drug and state, from the prescriber file and the CMS state totals (Part D Prescribers by Geography and Drug) | RY26 P04 V10 | 2024 | 113,704 | | `facilities` | Provider of Services file (iQIES), Care Compare facility listings, PECOS enrollments, Post-Acute Care Utilization and HRSA Health Center Sites, joined | POS Q3 2026; Care Compare September to November 2026; PECOS 2026-09-29 and 2026-11-12; utilization RY26; HRSA 2026-12-04 | 2026 (volumes 2024) | 94,745 | | `hospital_ehr_products` | Certified Health IT Reported by Hospitals for Promoting Interoperability (ASTP/ONC, from CMS attestations and the CHPL) | January 2026, program years 2023 and 2024 | 2023 and 2024 | 55,579 | | `medicare_enrollment_county` | Medicare Monthly Enrollment, by county | August 2026 (released November 2026) | 2013 to 2026 | 45,877 | | `health_center_sites` | HRSA Health Center Service Delivery and Look-Alike Sites | 2026-12-04 | 2026 | 18,389 | | `aco_participants` | Medicare Shared Savings Program: ACO Participants | PY2026 (2026-01) | 2026 | 15,329 | | `nursing_homes` | Care Compare: Nursing homes, Provider Information | November 2026 | 2026 | 14,681 | | `home_health_agencies` | Care Compare: Home Health Care Agencies | October 2026 | 2026 | 12,201 | | `hospitals` | Hospital Enrollments, Hospital Provider Cost Report and Hospital All Owners, joined | Enrollments 2026-11-12, cost report FY2024 | 2024 | 9,326 | | `ma_plans` | Medicare Advantage / Part D Monthly Enrollment: contract and plan directory | November 2026 | 2026 | 7,582 | | `dialysis_facilities` | Care Compare: Dialysis Facility, Listing by Facility | October 2026 | 2026 | 7,449 | | `ma_enrollment_state` | Derived: Medicare private-plan enrollment by state and parent organization | November 2026 | 2026 | 6,927 | | `surgery_centers` | Provider of Services file (iQIES), ambulatory surgical centers | Q3 2026 | 2026 | 6,665 | | `hcpcs` | Derived: codes seen in the Medicare service file | R26 P05 V10 | 2024 | 6,471 | | `hospices` | Care Compare: Hospice Provider Data and CAHPS Hospice Survey | November 2026 | 2026 | 6,229 | | `hospital_quality` | Care Compare: Hospital General Information, HCAHPS summary and headline outcome measures | Care Compare 2026-11-12 | 2025 | 5,435 | | `rollup_specialty_state` | Derived: Medicare activity by specialty and state | R26 P05 V10 | 2024 | 4,976 | | `hospital_ehr` | Derived: primary EHR per hospital, from the ONC file above | January 2026, program years 2023 and 2024 | 2024 | 4,224 | | `hospital_systems` | Medicare cost reports (HCRIS form 2552-10, worksheet S-2): chain home office per hospital | HCRIS FY2024, file of 2026-10-02 | 2024 | 3,950 | | `medicare_enrollment_state` | Medicare Monthly Enrollment, by state | August 2026 (released November 2026) | 2013 to 2026 | 784 | | `acos` | Medicare Shared Savings Program: ACOs, with Performance Year Financial and Quality Results | Organizations PY2026 (2026-04), results PY2025 (2026-11-19) | 2026 (results 2025) | 544 | ## Two kinds of year - **Registry and ownership data is current.** `providers`, `groups`, `group_members`, `hospital_owners`, `facilities`, `facility_owners` and `clinician_facilities` come from late-2026 files. So do Medicare plan enrollment (November 2026), the ACO list (performance year 2026) and the trials download (5 December 2026). - **Utilization data lags.** Medicare volumes, hospital DRG volumes, Part D prescribing and Open Payments describe calendar year 2024, the latest year CMS has published. Medicaid drug utilization runs to 2025. - **Some sources sit in between.** Hospital quality is the November 2026 Care Compare release, with measurement periods mostly in 2024 and 2025. Hospital EHR data is program year 2024, published January 2026. Health systems come from fiscal year 2024 cost reports. ACO results are performance year 2025. A clinician who started practising in 2025 is in `providers` but has no Medicare rows yet. ## Derived tables Seven tables are computed from the others, not downloaded: - `rollup_hcpcs_state` and `rollup_specialty_state` pre-aggregate the two largest Medicare tables so "by state" questions answer in milliseconds. - `hcpcs` is the list of codes that appear in `medicare_service`, with national totals. - `rollup_drug_state` totals Part D by drug and state, and adds CMS's own state totals over every prescriber. - `rollup_medicaid_drug_state` totals `medicaid_drug_state` by drug, state and year. - `ma_enrollment_state` totals plan enrollment by state and parent company. - `hospital_ehr` picks the primary EHR per hospital from `hospital_ehr_products`. Three more hold links made here, which the sources do not publish. `hospital_systems` resolves each hospital's reported home office to a `system_id`. `trial_investigators` and `nih_grants` carry an `npi` matched by name, and `aco_participants` a `group_pac_id` matched by name. [Caveats](https://openpipe.health/docs/data/caveats.md#trials-and-grants-are-linked-by-name) says how. ## How the pipeline runs The pipeline has five steps, run in this order for each dataset: | Step | Does | |---|---| | `raw` | Stores the file exactly as CMS published it | | `transform` | Cleans and types it into a Parquet file | | `lake` | Uploads the Parquet file, which DuckDB reads | | `load` | Loads the same Parquet into Postgres. Skipped for `partd_drug` and `medicaid_drug_state`, which are held in the lake only. | | `profile` | Computes the column statistics the [data catalog](https://openpipe.health/docs/data/catalog.md#profile-statistics) shows, and writes them to `catalog_columns` | Things to know about `profile`: - It reads the Parquet files, so it describes the same rows both engines serve. - It runs last, and only if no earlier step failed. A failed load leaves the previous statistics in place. - It replaces all of a dataset's rows in `catalog_columns` at once, so a renamed or dropped column does not linger. - It stops with an error if a table's described columns and its Parquet file disagree. - Run on its own, it does not move a dataset's `loaded_at`, so it does not mark [saved dashboards](https://openpipe.health/docs/api/saved.md#newer-data-available) as stale. A load does. --- # Data catalog URL: https://openpipe.health/docs/data/catalog/ Markdown: https://openpipe.health/docs/data/catalog.md > Free endpoints that list every dataset, describe every column, show how full each one is, return sample rows and search across all of it. 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). --- # Tables URL: https://openpipe.health/docs/data/tables/ Markdown: https://openpipe.health/docs/data/tables.md > The tables behind every answer, what one row is, and what every column means. These 45 tables hold everything the API answers from. You do not query them yourself: the [search and lookup endpoints](https://openpipe.health/docs/api/providers.md) and [Ask](https://openpipe.health/docs/api/ask.md) read them for you, and each response shows the SQL it ran as a [receipt](https://openpipe.health/docs/receipts.md). Use this page to understand the columns in a result and to word a question. The same descriptions feed the data catalog in the workspace, the schema the model is given when it plans an answer, and the MCP `describe_data` tool. The notes under each table are written for whoever writes the SQL, which is the model. Read [Caveats](https://openpipe.health/docs/data/caveats.md) before quoting a number. ## Clinicians ### `medicare_provider` Medicare Part B activity per clinician or organization: patients, services and dollars for the year. One row is one clinician or organization that billed Medicare Part B, per year. Key: `(npi, year)`. How it is read: - Display name is trim(coalesce(first_name || ' ', '') || last_org_name). - Some provider_type values: 'Orthopedic Surgery', 'Cardiology', 'Internal Medicine', 'Nurse Practitioner', 'Dermatology', 'Ophthalmology', 'Urology', 'Gastroenterology', 'Diagnostic Radiology', 'Family Practice'. | Column | Type | Meaning | |---|---|---| | `npi` | bigint | National Provider Identifier of the rendering clinician or organization. | | `year` | smallint | Calendar year the figures cover. | | `last_org_name` | text | Last name of an individual, or the organization name when entity_type is 'O'. Mixed case. | | `first_name` | text | First name of an individual. NULL for organizations. | | `credentials` | text | Credentials of an individual, for example M.D. NULL for organizations. | | `entity_type` | char(1) | Whether the NPI belongs to a person or an organization. `I` individual, `O` organization. | | `city` | text | City of the provider's practice address. | | `state` | char(2) | Two-letter USPS state code of the provider. | | `zip5` | char(5) | Five-digit ZIP code of the provider. | | `provider_type` | text | Medicare specialty: the specialty code on the provider's claims, or the one with the most services when there are several. | | `tot_hcpcs_codes` | integer, codes | Number of distinct HCPCS procedure codes the provider billed. | | `tot_benes` | integer, patients | Distinct Medicare patients the provider saw. | | `tot_srvcs` | double precision, services | Services provided. Can be fractional, because some services are counted in units. | | `tot_charges` | double precision, USD | Total charges the provider submitted. Charges are list prices and are usually far above what Medicare allows or pays. | | `tot_allowed` | double precision, USD | Total Medicare allowed amount: what Medicare paid plus the patient's deductible and coinsurance and any third-party share. | | `tot_payment` | double precision, USD | Total amount Medicare paid, after the deductible and coinsurance were subtracted. | | `drug_tot_payment` | double precision, USD | Part of tot_payment paid for Part B drug services. | | `med_tot_payment` | double precision, USD | Part of tot_payment paid for medical (non-drug) services. | | `avg_age` | double precision, years | Average age of the provider's Medicare patients. | | `dual_benes` | integer, patients | Patients entitled to both Medicare and Medicaid. | | `avg_risk_score` | double precision, score | Average HCC risk score of the provider's patients. 1.0 is the Medicare average; higher means sicker patients. | Indexed on `(state, provider_type, tot_payment)`. Joins: `medicare_service` on `medicare_provider.npi = medicare_service.npi`; `providers` on `medicare_provider.npi = providers.npi`; `partd_provider` on `medicare_provider.npi = partd_provider.npi`; `partd_drug` on `medicare_provider.npi = partd_drug.npi`; `hospitals` on `medicare_provider.npi = hospitals.npi`; `group_members` on `medicare_provider.npi = group_members.npi`; `open_payments` on `medicare_provider.npi = open_payments.npi`; `clinician_facilities` on `medicare_provider.npi = clinician_facilities.npi`; `facilities` on `medicare_provider.npi = facilities.npi`; `trial_investigators` on `medicare_provider.npi = trial_investigators.npi`; `nih_grants` on `medicare_provider.npi = nih_grants.npi`. Know before you use it: - Medicare fee-for-service only. Commercial insurance, Medicare Advantage, Medicaid and self-pay are not counted, so volumes are a floor, not a total. - CMS withholds any figure based on fewer than 11 patients. A withheld value is NULL, which means hidden, not zero. - Calendar year 2024. Registry, group and ownership tables are newer snapshots, so a clinician who moved since shows a different city there. - Specialty is the Medicare specialty name (Cardiology), which differs from the NUCC classification in providers.specialty. ### `medicare_service` Procedure volume per clinician: how often each provider billed each HCPCS code to Medicare Part B, split by place of service. One row is one clinician, one HCPCS procedure code and one place of service, per year. Key: `(npi, year, hcpcs_code, place_of_service)`. How it is read: - About 9.8M rows; ALWAYS filter by hcpcs_code. - Medicare payment for a row = avg_payment * tot_srvcs. - Join to medicare_provider on (npi, year) for names and cities, and to hcpcs on hcpcs_code = hcpcs.code for the description. | Column | Type | Meaning | |---|---|---| | `npi` | bigint | National Provider Identifier of the rendering clinician or organization. | | `year` | smallint | Calendar year the figures cover. | | `hcpcs_code` | text | HCPCS procedure code billed, for example 27447 (total knee replacement). Described in hcpcs. | | `place_of_service` | char(1) | Where the service was delivered. `F` facility, such as a hospital or surgery center, `O` office or other non-facility setting. | | `state` | char(2) | Two-letter USPS state code of the provider. | | `specialty` | text | Medicare specialty of the provider, same values as medicare_provider.provider_type. | | `tot_benes` | integer, patients | Distinct Medicare patients who received this service from this provider. | | `tot_srvcs` | double precision, services | Number of times the service was provided. Can be fractional. | | `tot_bene_day_srvcs` | integer, services | Distinct patient-per-day services: the same service given to one patient more than once in a day counts once. | | `avg_charge` | double precision, USD per service | Average charge the provider submitted for the service. | | `avg_allowed` | double precision, USD per service | Average Medicare allowed amount: Medicare's payment plus the patient's deductible and coinsurance. | | `avg_payment` | double precision, USD per service | Average amount Medicare paid per service, after the deductible and coinsurance. | Indexed on `(hcpcs_code, state, tot_srvcs)`. Joins: `medicare_provider` on `medicare_service.npi = medicare_provider.npi`; `providers` on `medicare_service.npi = providers.npi`; `partd_provider` on `medicare_service.npi = partd_provider.npi`; `partd_drug` on `medicare_service.npi = partd_drug.npi`; `hospitals` on `medicare_service.npi = hospitals.npi`; `group_members` on `medicare_service.npi = group_members.npi`; `open_payments` on `medicare_service.npi = open_payments.npi`; `clinician_facilities` on `medicare_service.npi = clinician_facilities.npi`; `facilities` on `medicare_service.npi = facilities.npi`; `trial_investigators` on `medicare_service.npi = trial_investigators.npi`; `nih_grants` on `medicare_service.npi = nih_grants.npi`; `hcpcs` on `medicare_service.hcpcs_code = hcpcs.code`; `rollup_hcpcs_state` on `medicare_service.hcpcs_code = rollup_hcpcs_state.hcpcs_code`; `drug_spending` on `medicare_service.hcpcs_code = drug_spending.hcpcs_code`. Know before you use it: - Medicare fee-for-service only. Commercial insurance, Medicare Advantage, Medicaid and self-pay are not counted, so volumes are a floor, not a total. - A clinician who performed a procedure on fewer than 11 Medicare patients has no row for it, so sums over many small providers undercount. - Calendar year 2024. Registry, group and ownership tables are newer snapshots, so a clinician who moved since shows a different city there. - Specialty is the Medicare specialty name (Cardiology), which differs from the NUCC classification in providers.specialty. ### `hcpcs` The procedure code dictionary: every HCPCS code that appears in medicare_service, with its description and national volume. One row is one HCPCS procedure code. Key: `code`. How it is read: - If unsure of a code, look it up by description with ILIKE. | Column | Type | Meaning | |---|---|---| | `code` | text | HCPCS code: a five-character CPT or HCPCS Level II code. | | `description` | text | CMS description of the code. | | `is_drug` | boolean | True when CMS flags the code as a Part B drug (it is on the Medicare Average Sales Price drug list). | | `providers` | integer, providers | Distinct clinicians and organizations that billed the code. | | `tot_srvcs` | double precision, services | Services billed under the code nationally, summed over medicare_service. | Joins: `medicare_service` on `hcpcs.code = medicare_service.hcpcs_code`; `rollup_hcpcs_state` on `hcpcs.code = rollup_hcpcs_state.hcpcs_code`; `drug_spending` on `hcpcs.code = drug_spending.hcpcs_code`. Know before you use it: - Only codes billed to Medicare Part B in 2024 by at least one provider above the 11-patient threshold. It is not the full HCPCS code set. - Medicare fee-for-service only. Commercial insurance, Medicare Advantage, Medicaid and self-pay are not counted, so volumes are a floor, not a total. ### `providers` The national NPI registry (NPPES): every active clinician and healthcare organization that holds a National Provider Identifier. One row is one active NPI, either a person or an organization. Key: `npi`. How it is read: - About 9.5M rows. Names, cities and addresses are UPPERCASE. Only use for lookups by npi or joined on npi, or filter by state and specialty (indexed). | Column | Type | Meaning | |---|---|---| | `npi` | bigint | National Provider Identifier of the clinician or organization. | | `entity_type` | char(1) | Whether the NPI belongs to a person or an organization. `I` individual, `O` organization. | | `name` | text | Display name: first and last name for a person, legal business name for an organization. UPPERCASE. A handful of registry rows have no legal name; they fall back to the other organization name, then to 'NPI '. | | `first_name` | text | First name of an individual. NULL for organizations. | | `last_name` | text | Legal last name of an individual. NULL for organizations. | | `org_name` | text | Legal business name of an organization. NULL for individuals. | | `credentials` | text | Credential text as the provider typed it, for example MD, M.D. or LCSW. Not standardized. | | `sex` | char(1) | Sex code of an individual as recorded in the registry. NULL for organizations. `F` female, `M` male. A small share of records carry other codes (X, U), kept as published. | | `taxonomy_code` | text | NUCC taxonomy code the provider marked as primary (the first listed code when none is marked). | | `specialty` | text | NUCC classification of the primary taxonomy code, for example Internal Medicine, Nurse Practitioner or Dentist. | | `subspecialty` | text | NUCC specialization of the primary taxonomy code, for example Cardiovascular Disease. NULL when the code has none. | | `address1` | text | First line of the business practice location address. | | `address2` | text | Second line of the business practice location address. | | `city` | text | City of the business practice location. UPPERCASE. | | `state` | char(2) | Two-letter USPS state code of the business practice location. | | `zip5` | char(5) | Five-digit ZIP code of the business practice location. | | `phone` | text | Telephone number of the business practice location, digits only. | | `enumeration_date` | date | Date the NPI was assigned. | | `last_updated` | date | Date the registry record was last updated. | Indexed on `(state, specialty)`, `name` for substring search, `zip5`. Joins: `medicare_provider` on `providers.npi = medicare_provider.npi`; `medicare_service` on `providers.npi = medicare_service.npi`; `partd_provider` on `providers.npi = partd_provider.npi`; `partd_drug` on `providers.npi = partd_drug.npi`; `hospitals` on `providers.npi = hospitals.npi`; `group_members` on `providers.npi = group_members.npi`; `open_payments` on `providers.npi = open_payments.npi`; `clinician_facilities` on `providers.npi = clinician_facilities.npi`; `facilities` on `providers.npi = facilities.npi`; `trial_investigators` on `providers.npi = trial_investigators.npi`; `nih_grants` on `providers.npi = nih_grants.npi`. Know before you use it: - A registry snapshot, newer than the 2024 Medicare tables. Details are self-reported by each provider and can be out of date. - specialty is the NUCC taxonomy classification, which differs from the Medicare specialty names in medicare_provider.provider_type. - Holding an NPI does not mean billing Medicare. Join to medicare_provider to find clinicians with activity. ### `clinician_facilities` Which facilities each clinician works at: hospital affiliations plus nursing homes, home health agencies, hospices, dialysis, rehabilitation and long-term care facilities. One row is one clinician and one facility they are affiliated with. Key: `(npi, ccn)`. How it is read: - Hospital medical staff: WHERE ccn = '...' AND facility_type = 'Hospital'. Join npi to providers for name and specialty, or to medicare_provider for Medicare volume. - Count clinicians per hospital with count(*): (npi, ccn) is unique. | Column | Type | Meaning | |---|---|---| | `npi` | bigint | National Provider Identifier of the clinician. | | `ccn` | char(6) | CMS Certification Number of the facility. Joins to hospitals.ccn for hospital-type rows. | | `facility_type` | text | Kind of facility: Hospital, Home health agency, Hospice, Nursing home, Dialysis facility, Inpatient rehabilitation facility or Long-term care hospital. | | `parent_ccn` | char(6) | CCN of the parent hospital when the facility is a unit inside one. NULL otherwise. | Indexed on `ccn`. Joins: `medicare_provider` on `clinician_facilities.npi = medicare_provider.npi`; `medicare_service` on `clinician_facilities.npi = medicare_service.npi`; `providers` on `clinician_facilities.npi = providers.npi`; `partd_provider` on `clinician_facilities.npi = partd_provider.npi`; `partd_drug` on `clinician_facilities.npi = partd_drug.npi`; `hospitals` on `clinician_facilities.npi = hospitals.npi`; `group_members` on `clinician_facilities.npi = group_members.npi`; `open_payments` on `clinician_facilities.npi = open_payments.npi`; `facilities` on `clinician_facilities.npi = facilities.npi`; `trial_investigators` on `clinician_facilities.npi = trial_investigators.npi`; `nih_grants` on `clinician_facilities.npi = nih_grants.npi`; `hospitals` on `clinician_facilities.ccn = hospitals.ccn`; `hospital_owners` on `clinician_facilities.ccn = hospital_owners.ccn`; `hospital_quality` on `clinician_facilities.ccn = hospital_quality.ccn`; `hospital_measures` on `clinician_facilities.ccn = hospital_measures.ccn`; `hospital_ehr` on `clinician_facilities.ccn = hospital_ehr.ccn`; `hospital_ehr_products` on `clinician_facilities.ccn = hospital_ehr_products.ccn`; `hospital_systems` on `clinician_facilities.ccn = hospital_systems.ccn`; `hospital_drgs` on `clinician_facilities.ccn = hospital_drgs.ccn`; `facilities` on `clinician_facilities.ccn = facilities.hospital_ccn`. Know before you use it: - From Medicare claims: CMS lists a facility when the clinician billed for services to patients there in recent months. It shows where a clinician practices, not employment, admitting privileges or a full medical-staff roster. - Only clinicians in Medicare's Doctors and Clinicians directory. Those who see no Medicare patients, and most residents, are absent. - November 2026 release. CMS lists at most five hospitals per clinician, so the busiest multi-hospital clinicians are truncated. - ccn joins to hospitals only for facility_type 'Hospital', 'Long-term care hospital' and 'Inpatient rehabilitation facility'. For nursing homes, home health agencies, hospices and dialysis facilities it equals facilities.facility_id (about 9 in 10 nursing home rows and nearly all of the others match). ## Prescribing ### `partd_provider` Medicare Part D prescribing totals per prescriber: claims, cost, patients, and the brand, generic and opioid split. One row is one prescriber, per year. Key: `(npi, year)`. How it is read: - No name columns. For prescriber names: LEFT JOIN providers p ON p.npi = d.npi and select p.name. | Column | Type | Meaning | |---|---|---| | `npi` | bigint | National Provider Identifier of the prescriber. | | `year` | smallint | Calendar year the figures cover. | | `state` | char(2) | Two-letter USPS state code of the prescriber. | | `specialty` | text | Specialty of the prescriber as CMS reports it: the Medicare specialty from their Part B claims, or their registry taxonomy when they have none. | | `tot_claims` | integer, claims | Part D prescription claims, original fills and refills together. | | `tot_30day_fills` | double precision, fills | Claims standardized to 30-day fills: a 90-day prescription counts as three. | | `tot_drug_cost` | double precision, USD | Total drug cost of all claims: ingredient cost, dispensing fee and sales tax, whoever paid it. Includes what the plan, the patient and government subsidies paid. Manufacturer rebates are not subtracted. | | `tot_day_supply` | bigint, days | Total days of medication supplied across all claims. | | `tot_benes` | integer, patients | Distinct Medicare patients with at least one claim from this prescriber. | | `brand_claims` | integer, claims | Claims for brand-name drugs. | | `brand_cost` | double precision, USD | Drug cost of brand-name claims. | | `generic_claims` | integer, claims | Claims for generic drugs. | | `generic_cost` | double precision, USD | Drug cost of generic claims. | | `opioid_claims` | integer, claims | Claims for opioid drugs. | | `opioid_rate` | double precision, percent | Opioid claims as a percentage of all the prescriber's claims, 0 to 100. | Joins: `medicare_provider` on `partd_provider.npi = medicare_provider.npi`; `medicare_service` on `partd_provider.npi = medicare_service.npi`; `providers` on `partd_provider.npi = providers.npi`; `partd_drug` on `partd_provider.npi = partd_drug.npi`; `hospitals` on `partd_provider.npi = hospitals.npi`; `group_members` on `partd_provider.npi = group_members.npi`; `open_payments` on `partd_provider.npi = open_payments.npi`; `clinician_facilities` on `partd_provider.npi = clinician_facilities.npi`; `facilities` on `partd_provider.npi = facilities.npi`; `trial_investigators` on `partd_provider.npi = trial_investigators.npi`; `nih_grants` on `partd_provider.npi = nih_grants.npi`. Know before you use it: - Medicare Part D only: prescriptions paid through a Part D plan. Drugs given in a clinic (Part B) and other payers are not counted. - CMS withholds any figure based on fewer than 11 patients. A withheld value is NULL, which means hidden, not zero. - Calendar year 2024. Registry, group and ownership tables are newer snapshots, so a clinician who moved since shows a different city there. ### `partd_drug` Medicare Part D prescribing per prescriber and drug: who writes how much of what. One row is one prescriber and one drug (brand name plus generic name), per year. Key: `(npi, year, brand_name, generic_name)`. Lake only: stored as Parquet and scanned by the analytics engine. It is not in Postgres and has no indexes. How it is read: - 28M rows, columnar (fast to aggregate). Always filter by generic_name or brand_name. - Drug names are title case and exact: brand_name 'Eliquis', generic_name 'Apixaban'. Prefer generic_name to cover all brands. - No name columns. For prescriber names: LEFT JOIN providers p ON p.npi = d.npi and select p.name. | Column | Type | Meaning | |---|---|---| | `npi` | bigint | National Provider Identifier of the prescriber. | | `year` | smallint | Calendar year the figures cover. | | `brand_name` | text | Brand name of the drug, title case, for example Eliquis. For a generic it repeats the generic name. | | `generic_name` | text | Generic (ingredient) name of the drug, title case, for example Apixaban. | | `state` | char(2) | Two-letter USPS state code of the prescriber. | | `specialty` | text | Specialty of the prescriber as CMS reports it: the Medicare specialty from their Part B claims, or their registry taxonomy when they have none. | | `tot_claims` | integer, claims | Part D prescription claims for this drug, original fills and refills together. | | `tot_30day_fills` | double precision, fills | Claims standardized to 30-day fills: a 90-day prescription counts as three. | | `tot_day_supply` | integer, days | Total days of this drug supplied. | | `tot_drug_cost` | double precision, USD | Total drug cost of these claims: ingredient cost, dispensing fee and sales tax, whoever paid it. Rebates are not subtracted. | | `tot_benes` | integer, patients | Distinct Medicare patients who filled this drug from this prescriber. NULL when fewer than 11. | Joins: `medicare_provider` on `partd_drug.npi = medicare_provider.npi`; `medicare_service` on `partd_drug.npi = medicare_service.npi`; `providers` on `partd_drug.npi = providers.npi`; `partd_provider` on `partd_drug.npi = partd_provider.npi`; `hospitals` on `partd_drug.npi = hospitals.npi`; `group_members` on `partd_drug.npi = group_members.npi`; `open_payments` on `partd_drug.npi = open_payments.npi`; `clinician_facilities` on `partd_drug.npi = clinician_facilities.npi`; `facilities` on `partd_drug.npi = facilities.npi`; `trial_investigators` on `partd_drug.npi = trial_investigators.npi`; `nih_grants` on `partd_drug.npi = nih_grants.npi`. Know before you use it: - Medicare Part D only: prescriptions paid through a Part D plan. Drugs given in a clinic (Part B) and other payers are not counted. - A prescriber and drug pair with fewer than 11 claims has no row. tot_benes is NULL when fewer than 11 patients, which is more than half the rows. - Calendar year 2024. Registry, group and ownership tables are newer snapshots, so a clinician who moved since shows a different city there. - Lake only: stored as Parquet and scanned by the analytics engine. It has no indexes and cannot be joined to on Postgres. ## Hospitals ### `hospitals` Every Medicare-enrolled hospital: identity and type from its enrollment record, size and financials from its latest cost report, and an ownership summary. One row is one hospital, identified by its CMS Certification Number (CCN). Key: `ccn`. How it is read: - Names are UPPERCASE. Filter out NULL beds or revenue before ranking by them. | Column | Type | Meaning | |---|---|---| | `ccn` | char(6) | CMS Certification Number: the six-character Medicare provider number of the hospital. | | `npi` | bigint | National Provider Identifier on the hospital's Medicare enrollment. NULL when the hospital is known only from a cost report. | | `name` | text | Hospital name: the doing-business-as name when there is one, otherwise the legal organization name. UPPERCASE. | | `dba` | text | Legal organization name on the Medicare enrollment. Despite the column name, this is the legal name; the doing-business-as name, when there is one, is in name. | | `address` | text | Street address of the hospital. | | `city` | text | City of the hospital. UPPERCASE. | | `state` | char(2) | Two-letter USPS state code of the hospital. | | `zip5` | char(5) | Five-digit ZIP code of the hospital. | | `org_structure` | text | Legal structure on the enrollment record, for example CORPORATION, LLC or GOVERNMENT. | | `ownership` | text | For-profit status on the enrollment record. `proprietary` for-profit, `non-profit` non-profit. NULL when the enrollment record does not say. | | `control_type` | text | Type of control code from the cost report (who runs the hospital). `1` voluntary non-profit, church, `2` voluntary non-profit, other, `3` proprietary, individual, `4` proprietary, corporation, `5` proprietary, partnership, `6` proprietary, other, `7` governmental, federal, `8` governmental, city-county, `9` governmental, county, `10` governmental, state, `11` governmental, hospital district, `12` governmental, city, `13` governmental, other. | | `facility_type` | text | CMS facility type code from the cost report. `STH` short-term acute care, `CAH` critical access, `PH` psychiatric, `RH` rehabilitation, `LTCH` long-term care, `CH` children's, `RNMHC` religious non-medical health care institution. Two more codes, ORD and TC, appear on fewer than ten hospitals. | | `is_acute_care` | boolean | True when the enrollment lists an acute care subgroup. | | `is_critical_access` | boolean | True when the cost report facility type is CAH (critical access hospital). NULL without a cost report. | | `is_childrens` | boolean | True when the enrollment lists a children's subgroup. | | `is_psychiatric` | boolean | True when the enrollment lists a psychiatric subgroup. | | `is_rehabilitation` | boolean | True when the enrollment lists a rehabilitation subgroup. | | `is_long_term` | boolean | True when the enrollment lists a long-term care subgroup. | | `rural_urban` | text | Rural or urban designation from the cost report. `R` rural, `U` urban, `NA` not reported. | | `beds` | integer, beds | Number of beds reported on the cost report. | | `discharges` | integer, discharges | Total discharges for the fiscal year, all payers (Medicare, Medicaid and everyone else). | | `fte` | double precision, FTE | Full-time-equivalent employees on payroll. | | `net_patient_revenue` | double precision, USD | Net patient revenue for the fiscal year: patient charges less contractual allowances and discounts. | | `total_costs` | double precision, USD | Total costs for the fiscal year. | | `net_income` | double precision, USD | Net income for the fiscal year. Negative means a loss. | | `fiscal_year_end` | date | Last day of the fiscal year the cost report covers. | | `owner_count` | integer, records | Number of owner and managing-party records disclosed for the hospital (rows in hospital_owners). | | `has_private_equity_owner` | boolean | True when any disclosed owner is flagged as a private equity company. | | `top_owner` | text | Name of the party with the largest disclosed ownership percentage. NULL when nobody reports a share above zero. Can be a person. Officers and directors report 0% and are never the top owner. | Indexed on `(state, beds)`, `name` for substring search. Joins: `hospital_owners` on `hospitals.ccn = hospital_owners.ccn`; `hospital_quality` on `hospitals.ccn = hospital_quality.ccn`; `hospital_measures` on `hospitals.ccn = hospital_measures.ccn`; `hospital_ehr` on `hospitals.ccn = hospital_ehr.ccn`; `hospital_ehr_products` on `hospitals.ccn = hospital_ehr_products.ccn`; `hospital_systems` on `hospitals.ccn = hospital_systems.ccn`; `hospital_drgs` on `hospitals.ccn = hospital_drgs.ccn`; `clinician_facilities` on `hospitals.ccn = clinician_facilities.ccn`; `facilities` on `hospitals.ccn = facilities.hospital_ccn`; `medicare_provider` on `hospitals.npi = medicare_provider.npi`; `medicare_service` on `hospitals.npi = medicare_service.npi`; `providers` on `hospitals.npi = providers.npi`; `partd_provider` on `hospitals.npi = partd_provider.npi`; `partd_drug` on `hospitals.npi = partd_drug.npi`; `group_members` on `hospitals.npi = group_members.npi`; `open_payments` on `hospitals.npi = open_payments.npi`; `clinician_facilities` on `hospitals.npi = clinician_facilities.npi`; `facilities` on `hospitals.npi = facilities.npi`; `trial_investigators` on `hospitals.npi = trial_investigators.npi`; `nih_grants` on `hospitals.npi = nih_grants.npi`. Know before you use it: - Beds, discharges, staffing and financials are self-reported on the hospital's Medicare cost report for the fiscal year ending fiscal_year_end. About a third of hospitals have no cost report on file, and those columns are NULL for them. - Private-equity and owner fields come from the ownership disclosures hospitals file with CMS. They reflect what was disclosed, and CMS has said the reporting is incomplete. - Enrollment and ownership are a late-2026 snapshot; cost reports are fiscal year 2024. ### `hospital_owners` Every owner and managing party a hospital disclosed to CMS: companies and people, their role and their ownership share. One row is one owner or managing party in one role at one hospital. Key: `id`. How it is read: - Join to hospitals on ccn. | Column | Type | Meaning | |---|---|---| | `id` | bigint | Row number assigned when the table is loaded. Not stable between loads. | | `ccn` | char(6) | CMS Certification Number of the hospital. Joins to hospitals.ccn. | | `owner_name` | text | Name of the owner or managing party: an organization name, or a person's first and last name. UPPERCASE. | | `owner_type` | char(1) | Whether the party is a person or an organization. `I` individual, `O` organization. | | `role` | text | The party's role, for example CORPORATE DIRECTOR or 5% OR GREATER DIRECT OWNERSHIP INTEREST. | | `title` | text | Job title as the hospital entered it, for example BOARD MEMBER or CEO. Free text. | | `association_date` | date | Date the party took up this role with the hospital. Typed in by the filer; a few dates are implausibly old. | | `pct_ownership` | double precision, percent | Ownership share the party holds, 0 to 100. Officers and directors report 0 or leave it blank (NULL). | | `is_private_equity` | boolean | True when an organization owner is flagged as a private equity company. NULL for individuals. | | `is_reit` | boolean | True when an organization owner is flagged as a real estate investment trust. NULL for individuals. | | `is_holding_company` | boolean | True when an organization owner is flagged as a holding company. NULL for individuals. | | `is_for_profit` | boolean | True when an organization owner is flagged as a for-profit entity. NULL for individuals. | Indexed on `ccn`. Joins: `hospitals` on `hospital_owners.ccn = hospitals.ccn`; `hospital_quality` on `hospital_owners.ccn = hospital_quality.ccn`; `hospital_measures` on `hospital_owners.ccn = hospital_measures.ccn`; `hospital_ehr` on `hospital_owners.ccn = hospital_ehr.ccn`; `hospital_ehr_products` on `hospital_owners.ccn = hospital_ehr_products.ccn`; `hospital_systems` on `hospital_owners.ccn = hospital_systems.ccn`; `hospital_drgs` on `hospital_owners.ccn = hospital_drgs.ccn`; `clinician_facilities` on `hospital_owners.ccn = clinician_facilities.ccn`; `facilities` on `hospital_owners.ccn = facilities.hospital_ccn`. Know before you use it: - Self-disclosed to CMS, and CMS has said the reporting is incomplete. The private-equity, REIT and holding-company flags are the filer's own answers. - Most rows are directors, officers and managing employees with a 0% share, not equity owners. Filter on pct_ownership or role to find owners. - id is a row number assigned at load time. It changes when the data is reloaded, so do not store it. ### `hospital_quality` CMS Care Compare quality scorecard per hospital: overall star rating, patient-survey stars, readmission, mortality, infection, emergency-department and spending headlines. One row is one hospital in Care Compare, identified by its CCN. Key: `ccn`. How it is read: - Join to hospitals on ccn for name, state, beds and revenue. - Lower is better for readmission_rate, mortality_rate, psi_90, the *_sir columns, ed_median_minutes and left_without_being_seen_pct. Higher is better for star ratings, recommend_pct and sepsis_care_pct. - The full list of measures per hospital is in hospital_measures. | Column | Type | Meaning | |---|---|---| | `ccn` | char(6) | CMS Certification Number of the hospital. Joins to hospitals.ccn. | | `hospital_type` | text | Care Compare hospital type, for example Acute Care Hospitals or Critical Access Hospitals. | | `ownership_type` | text | Care Compare ownership category, for example Voluntary non-profit - Private, Proprietary or Government - Local. | | `has_emergency_services` | boolean | True when the hospital has an emergency department. | | `is_birthing_friendly` | boolean | True when the hospital meets the CMS Birthing-Friendly designation. NULL otherwise. | | `overall_rating` | smallint, stars | CMS overall hospital quality star rating, 1 (worst) to 5 (best). | | `mortality_measures_better` | smallint, measures | Mortality measures on which the hospital is better than the national rate. | | `mortality_measures_worse` | smallint, measures | Mortality measures on which the hospital is worse than the national rate. | | `safety_measures_better` | smallint, measures | Safety-of-care measures better than the national rate. | | `safety_measures_worse` | smallint, measures | Safety-of-care measures worse than the national rate. | | `readmission_measures_better` | smallint, measures | Readmission measures better than the national rate. | | `readmission_measures_worse` | smallint, measures | Readmission measures worse than the national rate. | | `hcahps_star` | smallint, stars | HCAHPS patient-survey summary star rating, 1 to 5. | | `hcahps_surveys` | integer, surveys | Completed patient surveys behind the HCAHPS figures. | | `hcahps_response_rate` | double precision, percent | Share of surveyed patients who responded. | | `recommend_pct` | double precision, percent | Patients who would definitely recommend the hospital. | | `rating_9_10_pct` | double precision, percent | Patients who rated the hospital 9 or 10 out of 10. | | `readmission_rate` | double precision, percent | Hospital-wide 30-day unplanned readmission rate, risk-standardized. Lower is better. | | `mortality_rate` | double precision, percent | Hospital-wide 30-day mortality rate, risk-standardized. Lower is better. | | `psi_90` | double precision, ratio | PSI 90 patient-safety and adverse-events composite. About 1 is average; lower is better. | | `clabsi_sir` | double precision, ratio | Central-line bloodstream infection standardized infection ratio. Below 1 is better than predicted. | | `cauti_sir` | double precision, ratio | Catheter-associated urinary tract infection standardized infection ratio. | | `mrsa_sir` | double precision, ratio | MRSA bloodstream infection standardized infection ratio. | | `cdiff_sir` | double precision, ratio | C. difficile infection standardized infection ratio. | | `ed_volume` | text | Emergency department volume band. `low` under 20,000 visits a year, `medium` 20,000 to 39,999, `high` 40,000 to 59,999, `very high` 60,000 or more. | | `ed_median_minutes` | double precision, minutes | Median minutes patients spend in the emergency department before being sent home (OP-18b). Lower is better. | | `left_without_being_seen_pct` | double precision, percent | Emergency patients who left without being seen (OP-22). | | `sepsis_care_pct` | double precision, percent | Patients who received appropriate care for severe sepsis and septic shock (SEP-1). | | `spending_ratio` | double precision, ratio | Medicare spending per beneficiary relative to the national median (MSPB). 1.0 is the median; lower is cheaper. | Joins: `hospitals` on `hospital_quality.ccn = hospitals.ccn`; `hospital_owners` on `hospital_quality.ccn = hospital_owners.ccn`; `hospital_measures` on `hospital_quality.ccn = hospital_measures.ccn`; `hospital_ehr` on `hospital_quality.ccn = hospital_ehr.ccn`; `hospital_ehr_products` on `hospital_quality.ccn = hospital_ehr_products.ccn`; `hospital_systems` on `hospital_quality.ccn = hospital_systems.ccn`; `hospital_drgs` on `hospital_quality.ccn = hospital_drgs.ccn`; `clinician_facilities` on `hospital_quality.ccn = clinician_facilities.ccn`; `facilities` on `hospital_quality.ccn = facilities.hospital_ccn`. Know before you use it: - Care Compare release of November 2026. Each figure has its own measurement period (most are 2024 or 2025; readmission and mortality cover July 2024 to June 2025); hospital_measures gives the period per measure. - NULL means CMS published no value: too few cases, not reported, or not applicable to that hospital type. It never means zero. About 40% of hospitals have no overall star rating, mostly critical access, psychiatric and federal hospitals. - Includes about 170 Veterans Affairs and Department of Defense hospitals (CCN ending in F) that are not in hospitals. - is_birthing_friendly is true or NULL: CMS lists only the hospitals that meet the designation. - Readmission and mortality are the hospital-wide hybrid measures, risk-standardized by CMS. Infection ratios compare observed to predicted cases: below 1 is better than predicted. ### `hospital_measures` Every scored CMS Care Compare measure per hospital in one long table: mortality, patient safety, readmissions, infections, timely and effective care, patient survey and spending. One row is one hospital and one measure that CMS published a score for. Key: `(ccn, measure_id)`. How it is read: - Always filter to one measure_id. Common ones: 'Hybrid_HWR' hospital-wide readmission rate; 'Hybrid_HWM' hospital-wide mortality; 'MORT_30_AMI', 'MORT_30_HF', 'MORT_30_PN', 'MORT_30_STK', 'MORT_30_COPD', 'MORT_30_CABG' 30-day death rates; 'READM_30_HF', 'READM_30_PN', 'READM_30_HIP_KNEE', 'READM_30_AMI', 'READM_30_COPD', 'READM_30_CABG' readmission rates; 'COMP_HIP_KNEE' hip/knee complications; 'PSI_90' safety composite; 'HAI_1_SIR' CLABSI, 'HAI_2_SIR' CAUTI, 'HAI_3_SIR' colon surgical-site, 'HAI_5_SIR' MRSA, 'HAI_6_SIR' C. diff; 'OP_18b' ED minutes; 'OP_22' left without being seen; 'SEP_1' sepsis care; 'MSPB-1' spending ratio; 'H_STAR_RATING' survey summary stars; 'H_RECMND_DY' would recommend; 'H_HSP_RATING_9_10' rated 9-10. - The headline figures are already one row per hospital in hospital_quality. | Column | Type | Meaning | |---|---|---| | `ccn` | char(6) | CMS Certification Number of the hospital. Joins to hospitals.ccn. | | `measure_id` | text | CMS measure identifier, for example READM_30_HF or HAI_1_SIR. | | `measure_name` | text | CMS name of the measure. | | `domain` | text | Quality area the measure belongs to. `mortality` death rates, `safety` complications and patient-safety indicators, `readmission` readmissions and unplanned return visits, `infection` healthcare-associated infection ratios, `timely_care` timely and effective care, `patient_experience` HCAHPS patient survey, `spending` Medicare spending per beneficiary. | | `score` | double precision | The hospital's score, in the unit the measure defines (rate, percent, minutes, ratio or stars). | | `compared_to_national` | text | CMS's comparison with the national rate or benchmark, where published. `better` statistically better, `no different` no different, `worse` statistically worse. | | `denominator` | integer, cases | Cases, patients or completed surveys the score is based on. NULL where CMS publishes none. | | `period_start` | date | First day of the measurement period. | | `period_end` | date | Last day of the measurement period. | Indexed on `(measure_id, score)`. Joins: `hospitals` on `hospital_measures.ccn = hospitals.ccn`; `hospital_owners` on `hospital_measures.ccn = hospital_owners.ccn`; `hospital_quality` on `hospital_measures.ccn = hospital_quality.ccn`; `hospital_ehr` on `hospital_measures.ccn = hospital_ehr.ccn`; `hospital_ehr_products` on `hospital_measures.ccn = hospital_ehr_products.ccn`; `hospital_systems` on `hospital_measures.ccn = hospital_systems.ccn`; `hospital_drgs` on `hospital_measures.ccn = hospital_drgs.ccn`; `clinician_facilities` on `hospital_measures.ccn = clinician_facilities.ccn`; `facilities` on `hospital_measures.ccn = facilities.hospital_ccn`. Know before you use it: - Care Compare release of November 2026. Measurement periods differ by measure; use period_start and period_end. - A hospital with no row for a measure was not scored on it (too few cases, not reported or not applicable). Missing is not zero, so average only over the rows present. - Scores are not on one scale: rates, percentages, minutes, ratios and star ratings share the score column. Never compare or average scores across different measure_id values. - From the infection file only the standardized infection ratio (HAI_n_SIR) is kept, and from the patient survey only star ratings and top-box percentages. - compared_to_national is published only for some measures; CMS left it blank for the mortality measures in this release. ### `hospital_ehr` The electronic health record (EHR) system each hospital runs: vendor, product and whether the vendor changed since the year before. One row is one hospital, from its latest Medicare Promoting Interoperability attestation that names certified products. Key: `ccn`. How it is read: - Filter on vendor, a short label: 'Epic', 'Oracle Health (Cerner)', 'MEDITECH', 'TruBridge (CPSI)', 'Altera (Allscripts)', 'MEDHOST', 'athenahealth'. Cerner is 'Oracle Health (Cerner)'. - Join to hospitals on ccn. Every attested product is in hospital_ehr_products. | Column | Type | Meaning | |---|---|---| | `ccn` | char(6) | CMS Certification Number of the hospital. Joins to hospitals.ccn. | | `year` | smallint | Promoting Interoperability program year of the attestation. | | `vendor` | text | Short name of the primary EHR vendor, for example Epic or Oracle Health (Cerner). | | `developer` | text | Developer name exactly as the Certified Health IT Product List has it. | | `product` | text | Core inpatient EHR product attested, for example EpicCare Inpatient Base. NULL when basis is most_products. | | `basis` | text | How the primary vendor was chosen. `core_product` developer of the one core inpatient EHR product, `multiple_core_products` two core EHR developers attested, the larger bundle chosen; ambiguous, `most_products` no core product found, developer with the most products chosen; weak. | | `developer_count` | smallint, developers | Distinct developers on the hospital's attestation. | | `product_count` | smallint, products | Distinct certified products on the hospital's attestation. | | `other_vendors` | text | Other vendors on the same attestation, separated by '; ', largest bundle first. | | `previous_vendor` | text | Primary vendor the year before. NULL when that year has no decodable attestation. | | `vendor_changed` | boolean | True when the primary vendor differs from the year before. NULL when not comparable. | | `cehrt_id` | text | CMS EHR Certification ID the hospital attested with. | | `source` | text | Where the row comes from, including the program year. | Indexed on `vendor`. Joins: `hospitals` on `hospital_ehr.ccn = hospitals.ccn`; `hospital_owners` on `hospital_ehr.ccn = hospital_owners.ccn`; `hospital_quality` on `hospital_ehr.ccn = hospital_quality.ccn`; `hospital_measures` on `hospital_ehr.ccn = hospital_measures.ccn`; `hospital_ehr_products` on `hospital_ehr.ccn = hospital_ehr_products.ccn`; `hospital_systems` on `hospital_ehr.ccn = hospital_systems.ccn`; `hospital_drgs` on `hospital_ehr.ccn = hospital_drgs.ccn`; `clinician_facilities` on `hospital_ehr.ccn = clinician_facilities.ccn`; `facilities` on `hospital_ehr.ccn = facilities.hospital_ccn`. Know before you use it: - Program year 2024 for most hospitals (2023 where 2024 is missing): what the hospital attested to CMS, decoded by ONC against the Certified Health IT Product List. Published January 2026, so a go-live since 2024 is not reflected. - Covers hospitals in the Medicare Promoting Interoperability program that filed a certification ID: about 4,200, which is 85% of acute care hospitals. Psychiatric, rehabilitation, long-term, children's and federal hospitals are mostly absent. No row means unknown, not 'no EHR'. - A hospital attests to a bundle of products from several developers. vendor is the developer of the core inpatient EHR product (basis = 'core_product', 97% of rows). About 50 hospitals attest core products from two developers, usually mid-migration (basis = 'multiple_core_products'; the second is in other_vendors), and about 50 have no recognisable core product (basis = 'most_products'): treat both as uncertain. - vendor_changed compares program years 2023 and 2024 and is NULL unless basis is 'core_product' in both. A hospital that attests under a new parent system's ID can show as changed. ### `hospital_ehr_products` Every certified health IT product each hospital attested to for Medicare Promoting Interoperability: the EHR plus portals, labs, e-prescribing, messaging, surveillance and quality-reporting tools. One row is one hospital, one program year, one developer and one product. Key: `(ccn, year, developer, product)`. How it is read: - Filter year = 2024 for the current picture. vendor uses the same short labels as hospital_ehr.vendor; is_core_ehr marks the inpatient EHR itself. | Column | Type | Meaning | |---|---|---| | `ccn` | char(6) | CMS Certification Number of the hospital. Joins to hospitals.ccn. | | `year` | smallint | Promoting Interoperability program year. | | `vendor` | text | Short vendor name, for example Epic or Oracle Health (Cerner); the developer name when there is no short form. | | `developer` | text | Developer name as the Certified Health IT Product List has it. | | `product` | text | Certified product name. | | `is_core_ehr` | boolean | True when the product is an inpatient EHR system rather than an add-on module or tool. | | `listings` | integer, listings | Certified versions of the product on the hospital's attestation. | | `cehrt_id` | text | CMS EHR Certification ID the hospital attested with. | Indexed on `(vendor, year)`. Joins: `hospitals` on `hospital_ehr_products.ccn = hospitals.ccn`; `hospital_owners` on `hospital_ehr_products.ccn = hospital_owners.ccn`; `hospital_quality` on `hospital_ehr_products.ccn = hospital_quality.ccn`; `hospital_measures` on `hospital_ehr_products.ccn = hospital_measures.ccn`; `hospital_ehr` on `hospital_ehr_products.ccn = hospital_ehr.ccn`; `hospital_systems` on `hospital_ehr_products.ccn = hospital_systems.ccn`; `hospital_drgs` on `hospital_ehr_products.ccn = hospital_drgs.ccn`; `clinician_facilities` on `hospital_ehr_products.ccn = clinician_facilities.ccn`; `facilities` on `hospital_ehr_products.ccn = facilities.hospital_ccn`. Know before you use it: - Program years 2023 and 2024, published by ONC in January 2026 from CMS attestations and the Certified Health IT Product List. - Lists certified products only. Software that is not ONC-certified (most revenue-cycle, ERP, imaging and analytics tools) never appears, so this is not a full technology stack. - A product is listed because the hospital's certification ID includes it, which is strong but not perfect evidence of daily use. - Two years per hospital: filter on year, or counts double. ### `hospital_systems` The health system (chain or integrated delivery network) each hospital belongs to, from the home office it names on its Medicare cost report. One row is one hospital that reports being part of a chain organization. Key: `ccn`. How it is read: - Search with system_name ILIKE '%hca%'. Names are UPPERCASE. Group by system_id, not by name. - Join to hospitals on ccn. A hospital with no row here is independent or unknown: use LEFT JOIN. | Column | Type | Meaning | |---|---|---| | `ccn` | char(6) | CMS Certification Number of the hospital. Joins to hospitals.ccn. | | `system_id` | text | Identifier of the health system: its CMS home office number, or 'N:' plus a cleaned name. | | `system_name` | text | Name of the health system, the most common spelling its hospitals report. UPPERCASE. | | `system_hospitals` | integer, hospitals | Hospitals resolved to the same system in this table. | | `reported_name` | text | Home office name exactly as this hospital reported it. UPPERCASE. | | `reported_number` | text | Home office number as this hospital reported it, before resolution. | | `home_office_city` | text | City of the system's home office. UPPERCASE. | | `home_office_state` | char(2) | Two-letter USPS state code of the system's home office. | | `fiscal_year_end` | date | Last day of the cost-report fiscal year the affiliation was read from. | Indexed on `system_id`. Joins: `hospitals` on `hospital_systems.ccn = hospitals.ccn`; `hospital_owners` on `hospital_systems.ccn = hospital_owners.ccn`; `hospital_quality` on `hospital_systems.ccn = hospital_quality.ccn`; `hospital_measures` on `hospital_systems.ccn = hospital_measures.ccn`; `hospital_ehr` on `hospital_systems.ccn = hospital_ehr.ccn`; `hospital_ehr_products` on `hospital_systems.ccn = hospital_ehr_products.ccn`; `hospital_drgs` on `hospital_systems.ccn = hospital_drgs.ccn`; `clinician_facilities` on `hospital_systems.ccn = clinician_facilities.ccn`; `facilities` on `hospital_systems.ccn = facilities.hospital_ccn`. Know before you use it: - Self-reported on Medicare cost reports for fiscal year 2024 (worksheet S-2, lines 140 to 143). Hospitals that report no chain, or filed no 2024 cost report, have no row: no row means independent or unknown. - Names are typed by each hospital, so system_id and system_name are resolved by us from the home office number and name spellings. Most systems resolve cleanly; a few are split (a regional division reporting its own home office, such as Dignity Health within CommonSpirit) and system_hospitals undercounts those. - The home office is the legal or operating parent as reported for Medicare, which can differ from the consumer brand. Physician groups, clinics and other non-hospital sites of a system are not here. - system_id is a CMS home office number where one was reported, otherwise 'N:' followed by the cleaned name. Treat it as stable only within one load. ### `hospital_drgs` Medicare inpatient volume and payment per hospital and diagnosis-related group (MS-DRG): which service lines a hospital actually runs. One row is one hospital and one MS-DRG, per year. Key: `(ccn, drg_code)`. How it is read: - drg_code is three characters with leading zeros ('470', '003'). Examples: '470' major hip and knee joint replacement without MCC, '871' sepsis with MCC, '291' heart failure with MCC, '246' and '247' coronary stent, '460' spinal fusion, '266' and '267' transcatheter valve. Search drg_description ILIKE for others; descriptions are UPPERCASE. - Join to hospitals on ccn. | Column | Type | Meaning | |---|---|---| | `ccn` | char(6) | CMS Certification Number of the hospital. Joins to hospitals.ccn. | | `year` | smallint | Calendar year the figures cover. | | `drg_code` | char(3) | MS-DRG code, three characters with leading zeros. | | `drg_description` | text | MS-DRG description. UPPERCASE. | | `discharges` | integer, discharges | Medicare fee-for-service discharges in the DRG. Always 11 or more. | | `avg_covered_charges` | double precision, USD | Average charges the hospital billed per discharge. | | `avg_total_payment` | double precision, USD | Average total payment per discharge, including patient and third-party shares. | | `avg_medicare_payment` | double precision, USD | Average amount Medicare itself paid per discharge. | Indexed on `(drg_code, discharges)`. Joins: `hospitals` on `hospital_drgs.ccn = hospitals.ccn`; `hospital_owners` on `hospital_drgs.ccn = hospital_owners.ccn`; `hospital_quality` on `hospital_drgs.ccn = hospital_quality.ccn`; `hospital_measures` on `hospital_drgs.ccn = hospital_measures.ccn`; `hospital_ehr` on `hospital_drgs.ccn = hospital_ehr.ccn`; `hospital_ehr_products` on `hospital_drgs.ccn = hospital_ehr_products.ccn`; `hospital_systems` on `hospital_drgs.ccn = hospital_systems.ccn`; `clinician_facilities` on `hospital_drgs.ccn = clinician_facilities.ccn`; `facilities` on `hospital_drgs.ccn = facilities.hospital_ccn`. Know before you use it: - Medicare fee-for-service only. Commercial insurance, Medicare Advantage, Medicaid and self-pay are not counted, so volumes are a floor, not a total. - CMS leaves out any hospital and DRG with fewer than 11 discharges, so small programs are missing and a hospital's rows do not add up to its total Medicare discharges. - Calendar year 2024. Covers about 2,900 hospitals paid under the inpatient prospective payment system; critical access hospitals and Maryland hospitals are not included. - Payments are averages per discharge. Multiply by discharges for totals. Charges are list prices, far above what is paid. ## Groups ### `groups` Group practices, built from the list of clinicians who reassign their Medicare billing to a group. One row is one group practice, identified by its PECOS Associate Control ID. Key: `group_pac_id`. | Column | Type | Meaning | |---|---|---| | `group_pac_id` | bigint | PECOS Associate Control ID of the group: its enrollment identifier in Medicare. | | `name` | text | Legal business name of the group. UPPERCASE. A solo practice can carry its owner's name. | | `state` | char(2) | Two-letter USPS state code of the group. | | `member_count` | integer, clinicians | Distinct clinicians who reassign their Medicare benefits to the group. | | `top_specialty` | text | Most common specialty among the group's clinicians. | Indexed on `(state, member_count)`, `name` for substring search. Joins: `group_members` on `groups.group_pac_id = group_members.group_pac_id`; `aco_participants` on `groups.group_pac_id = aco_participants.group_pac_id`. Know before you use it: - member_count counts clinicians who reassign Medicare benefits to the group, not everyone who works there. - A late-2026 snapshot. One health system often enrolls as several groups. - Names are UPPERCASE legal business names. ### `group_members` Which clinician belongs to which group practice. One row is one clinician in one group practice. Key: `(group_pac_id, npi)`. How it is read: - Indexed on npi, so finding the groups a clinician is in is fast. Join to groups on group_pac_id and to providers on npi. | Column | Type | Meaning | |---|---|---| | `group_pac_id` | bigint | PECOS Associate Control ID of the group. Joins to groups.group_pac_id. | | `npi` | bigint | National Provider Identifier of the clinician. | | `specialty` | text | The clinician's specialty as listed on the reassignment record. | Indexed on `npi`. Joins: `groups` on `group_members.group_pac_id = groups.group_pac_id`; `aco_participants` on `group_members.group_pac_id = aco_participants.group_pac_id`; `medicare_provider` on `group_members.npi = medicare_provider.npi`; `medicare_service` on `group_members.npi = medicare_service.npi`; `providers` on `group_members.npi = providers.npi`; `partd_provider` on `group_members.npi = partd_provider.npi`; `partd_drug` on `group_members.npi = partd_drug.npi`; `hospitals` on `group_members.npi = hospitals.npi`; `open_payments` on `group_members.npi = open_payments.npi`; `clinician_facilities` on `group_members.npi = clinician_facilities.npi`; `facilities` on `group_members.npi = facilities.npi`; `trial_investigators` on `group_members.npi = trial_investigators.npi`; `nih_grants` on `group_members.npi = nih_grants.npi`. Know before you use it: - A clinician can belong to several groups. - A late-2026 snapshot of Medicare benefit reassignments, not an employment record. ## Industry payments ### `open_payments` Payments from drug and device companies to clinicians (Open Payments), totalled per clinician and company. One row is one clinician and one paying company, per year. Key: `(npi, year, company)`. How it is read: - Company names are exact and mixed in case as reported, for example 'PFIZER INC.' and 'Lilly USA, LLC'. Match with ILIKE. | Column | Type | Meaning | |---|---|---| | `npi` | bigint | National Provider Identifier of the clinician who received the payments. | | `year` | smallint | Program year the payments were made in. | | `company` | text | Name of the manufacturer or group purchasing organization that made the payments, as reported. | | `total_amount` | double precision, USD | Total value of the company's payments to the clinician in the year. | | `payment_count` | integer, payments | Number of payments included in the total. | | `top_nature` | text | Most common nature of payment across the records, for example Food and Beverage or Consulting Fee. | Indexed on `(company, total_amount)`. Joins: `medicare_provider` on `open_payments.npi = medicare_provider.npi`; `medicare_service` on `open_payments.npi = medicare_service.npi`; `providers` on `open_payments.npi = providers.npi`; `partd_provider` on `open_payments.npi = partd_provider.npi`; `partd_drug` on `open_payments.npi = partd_drug.npi`; `hospitals` on `open_payments.npi = hospitals.npi`; `group_members` on `open_payments.npi = group_members.npi`; `clinician_facilities` on `open_payments.npi = clinician_facilities.npi`; `facilities` on `open_payments.npi = facilities.npi`; `trial_investigators` on `open_payments.npi = trial_investigators.npi`; `nih_grants` on `open_payments.npi = nih_grants.npi`. Know before you use it: - General payments only: meals, travel, consulting, speaking and the like. Research payments and ownership interests are not included. - Aggregated: one row holds the year's total for a clinician and company, not individual payments. - Only payments to recipients with an NPI. Payments to teaching hospitals are not included. - Program year 2024, as reported by the companies. ## Rollups ### `rollup_specialty_state` Medicare Part B activity totalled by specialty and state. Built from medicare_provider. One row is one Medicare specialty in one state, per year. Key: `(specialty, state, year)`. How it is read: - PREFER for specialty and state totals: small and answers in milliseconds. | Column | Type | Meaning | |---|---|---| | `specialty` | text | Medicare specialty, same values as medicare_provider.provider_type. | | `state` | char(2) | Two-letter USPS state code of the providers. | | `year` | smallint | Calendar year the figures cover. | | `providers` | integer, providers | Clinicians and organizations of this specialty in the state that billed Medicare. | | `benes` | bigint, patients | Sum of each provider's patient count. Patients seen by more than one provider are counted more than once. | | `services` | double precision, services | Total services provided. | | `payment` | double precision, USD | Total amount Medicare paid. | Know before you use it: - Medicare fee-for-service only. Commercial insurance, Medicare Advantage, Medicaid and self-pay are not counted, so volumes are a floor, not a total. - benes adds up each clinician's patient count, so a patient seen by two clinicians is counted twice. Withheld (NULL) counts add nothing. - Calendar year 2024. Registry, group and ownership tables are newer snapshots, so a clinician who moved since shows a different city there. ### `rollup_hcpcs_state` Procedure volume totalled by HCPCS code and state. Built from medicare_service. One row is one HCPCS procedure code in one state, per year. Key: `(hcpcs_code, state, year)`. How it is read: - PREFER for "by state" procedure questions: small and answers in milliseconds. | Column | Type | Meaning | |---|---|---| | `hcpcs_code` | text | HCPCS procedure code. Described in hcpcs. | | `state` | char(2) | Two-letter USPS state code of the providers. | | `year` | smallint | Calendar year the figures cover. | | `providers` | integer, providers | Distinct clinicians and organizations in the state that billed the code. | | `benes` | bigint, patients | Sum of each provider's patient count for the code. Patients seen by more than one provider are counted more than once. | | `services` | double precision, services | Total times the service was provided. | | `payment` | double precision, USD | Estimated Medicare payment: the sum of avg_payment * tot_srvcs over the underlying rows. | Joins: `medicare_service` on `rollup_hcpcs_state.hcpcs_code = medicare_service.hcpcs_code`; `hcpcs` on `rollup_hcpcs_state.hcpcs_code = hcpcs.code`; `drug_spending` on `rollup_hcpcs_state.hcpcs_code = drug_spending.hcpcs_code`. Know before you use it: - Medicare fee-for-service only. Commercial insurance, Medicare Advantage, Medicaid and self-pay are not counted, so volumes are a floor, not a total. - Built only from clinicians above the 11-patient threshold for the code, so totals undercount. benes counts a patient once per clinician. - Calendar year 2024. Registry, group and ownership tables are newer snapshots, so a clinician who moved since shows a different city there. ## Facilities ### `facilities` Every non-hospital care facility in one table: nursing homes, home health agencies, hospices, dialysis facilities, surgery centers, rehab and long-term care hospitals, rural health clinics, FQHCs, HRSA health center sites and the smaller certified types. One row is one facility that is certified by Medicare or Medicaid today, or one active HRSA health center site. Key: `facility_id`. How it is read: - ALWAYS filter by facility_type. Names, cities and chain names are UPPERCASE; match with ILIKE. - Most measures are NULL for many rows (unrated, not published). Never COALESCE a rating, bed count or payment to 0: averages and sums skip NULL on their own. Sort with DESC NULLS LAST. - For totals over facilities with a private equity or REIT owner, filter has_private_equity_owner or has_reit_owner here. Do not join facility_owners and then SUM a facilities column: the join repeats a facility once per owner row. - Detail tables join on facility_id: nursing_homes, home_health_agencies, hospices, dialysis_facilities, surgery_centers, health_center_sites. Owners: facility_owners.facility_id. - Examples of chain_name: 'THE ENSIGN GROUP', 'GENESIS HEALTHCARE' (nursing homes); 'DAVITA', 'FRESENIUS MEDICAL CARE' (dialysis). For health center sites it is the parent health center. - When listing facilities select facility_id; it is the id column. Rank nursing homes by beds, hospices and home health by medicare_payment or medicare_patients, dialysis by stations, surgery centers by operating_rooms. | Column | Type | Meaning | |---|---|---| | `facility_id` | text | Facility identifier: the CMS Certification Number, or the HRSA site number for health center sites. | | `facility_type` | text | Kind of facility. `nursing_home` skilled nursing facility or nursing facility, `home_health_agency` home health agency, `hospice` hospice, `dialysis_facility` dialysis (ESRD) facility, `ambulatory_surgery_center` ambulatory surgery center, `inpatient_rehab_facility` inpatient rehabilitation hospital or hospital unit, `long_term_care_hospital` long-term care hospital, `rural_health_clinic` rural health clinic, `fqhc` federally qualified health center certified by CMS, `health_center_site` HRSA health center or look-alike service site, `intermediate_care_facility_iid` intermediate care facility for intellectual disabilities, `outpatient_therapy_provider` outpatient physical therapy or speech pathology provider, `portable_xray_supplier` portable X-ray supplier, `psychiatric_residential_treatment_facility` psychiatric residential treatment facility, `outpatient_rehab_facility` comprehensive outpatient rehabilitation facility, `community_mental_health_center` community mental health center, `organ_procurement_organization` organ procurement organization. | | `hospital_ccn` | char(6) | For rehab facilities and long-term care hospitals: the hospitals.ccn of the hospital itself or, for a unit, its parent. | | `fqhc_facility_id` | text | For a health center site: facility_id of the CMS-certified fqhc row for the same clinic, when HRSA publishes its Medicare number. Several sites can share one FQHC's number. | | `npi` | bigint | National Provider Identifier from the Medicare enrollment, quality listing or HRSA record. NULL when none is published. One organization can enroll several facilities under one NPI, so it is not unique here. | | `name` | text | Facility name as listed. UPPERCASE. | | `legal_name` | text | Legal business name on the Medicare enrollment. UPPERCASE. | | `address` | text | Street address. UPPERCASE. | | `city` | text | City. UPPERCASE. | | `state` | char(2) | Two-letter USPS state code of the facility. | | `zip5` | char(5) | Five-digit ZIP code. | | `county_fips` | char(5) | Five-digit county FIPS code. | | `phone` | text | Telephone number, ten digits. | | `ownership_type` | text | Who runs the facility, normalized across sources. `for_profit` for-profit, `non_profit` non-profit, `government` federal, state, local or tribal government, `other` published as other. A combined government and non-profit operator counts as government. Falls back to the for-profit flag on the Medicare enrollment when the listing has no ownership. | | `ownership_detail` | text | Ownership or control type in the publisher's own words. | | `chain_name` | text | Chain or parent organization where published (nursing homes, dialysis, health center sites). UPPERCASE. | | `beds` | integer, beds | Certified or total beds, for facility types that have beds. | | `stations` | integer, stations | Dialysis stations. | | `operating_rooms` | integer, rooms | Operating rooms in a surgery center. | | `star_rating` | double precision, stars | CMS star rating, 1 to 5; its meaning depends on facility_type. | | `avg_daily_census` | double precision, patients per day | Average patients per day: nursing home residents or hospice patients. | | `medicare_patients` | integer, patients | Distinct Medicare fee-for-service patients in 2024. | | `medicare_service_days` | integer, days | Medicare-covered days of care in 2024 (post-acute types only). | | `medicare_payment` | double precision, USD | Medicare fee-for-service payment in 2024. | | `certified_date` | date | Date first certified for Medicare or Medicaid; for health center sites, date added to the HRSA grant. | | `ownership_change_date` | date | Date of the most recent change of ownership on record. NULL when none. | | `rural_urban` | char(1) | Rural or urban location. `R` rural, `U` urban. | | `latitude` | double precision, degrees | Latitude (nursing homes and health center sites only). | | `longitude` | double precision, degrees | Longitude (nursing homes and health center sites only). | | `owner_count` | integer, records | Owner and managing-party records disclosed (rows in facility_owners). | | `has_private_equity_owner` | boolean | True when any disclosed owner is flagged as a private equity company. | | `has_reit_owner` | boolean | True when any disclosed owner is flagged as a real estate investment trust. | | `top_owner` | text | Party with the largest disclosed ownership share. Can be a person. | | `source` | text | Where the listing came from. `cms_care_compare` a CMS Care Compare listing, `cms_pos` Provider of Services file only, `hrsa` HRSA health center sites. | Indexed on `(facility_type, state, city)`, `name` for substring search, `chain_name` for substring search, `npi`, `zip5`. Joins: `facility_owners` on `facilities.facility_id = facility_owners.facility_id`; `nursing_homes` on `facilities.facility_id = nursing_homes.facility_id`; `home_health_agencies` on `facilities.facility_id = home_health_agencies.facility_id`; `hospices` on `facilities.facility_id = hospices.facility_id`; `dialysis_facilities` on `facilities.facility_id = dialysis_facilities.facility_id`; `surgery_centers` on `facilities.facility_id = surgery_centers.facility_id`; `health_center_sites` on `facilities.facility_id = health_center_sites.facility_id`; `hospitals` on `facilities.hospital_ccn = hospitals.ccn`; `hospital_owners` on `facilities.hospital_ccn = hospital_owners.ccn`; `hospital_quality` on `facilities.hospital_ccn = hospital_quality.ccn`; `hospital_measures` on `facilities.hospital_ccn = hospital_measures.ccn`; `hospital_ehr` on `facilities.hospital_ccn = hospital_ehr.ccn`; `hospital_ehr_products` on `facilities.hospital_ccn = hospital_ehr_products.ccn`; `hospital_systems` on `facilities.hospital_ccn = hospital_systems.ccn`; `hospital_drgs` on `facilities.hospital_ccn = hospital_drgs.ccn`; `clinician_facilities` on `facilities.hospital_ccn = clinician_facilities.ccn`; `medicare_provider` on `facilities.npi = medicare_provider.npi`; `medicare_service` on `facilities.npi = medicare_service.npi`; `providers` on `facilities.npi = providers.npi`; `partd_provider` on `facilities.npi = partd_provider.npi`; `partd_drug` on `facilities.npi = partd_drug.npi`; `hospitals` on `facilities.npi = hospitals.npi`; `group_members` on `facilities.npi = group_members.npi`; `open_payments` on `facilities.npi = open_payments.npi`; `clinician_facilities` on `facilities.npi = clinician_facilities.npi`; `trial_investigators` on `facilities.npi = trial_investigators.npi`; `nih_grants` on `facilities.npi = nih_grants.npi`; `ma_enrollment_county` on `facilities.county_fips = ma_enrollment_county.county_fips`; `medicare_enrollment_county` on `facilities.county_fips = medicare_enrollment_county.county_fips`. Know before you use it: - Acute-care hospitals are not here; they are in hospitals. Inpatient rehab facilities and long-term care hospitals appear in both: hospital_ccn points at their hospitals row. - facility_id is the CMS Certification Number (six characters; ten for surgery centers and portable X-ray suppliers), except for facility_type 'health_center_site', where it is HRSA's BPHC assigned site number (for example BPS-H80-015078). HRSA sites and CMS-certified FQHCs are two registries of largely the same clinics: a health_center_site row carries the facility_id of its fqhc row in fqhc_facility_id when HRSA publishes it (about 40%), so count one type or the other, not both. - A facility Care Compare still lists but the Provider of Services file marks terminated is left out. - star_rating means something different per type: nursing home overall rating, home health quality-of-patient-care rating (half stars), dialysis five-star rating, hospice family caregiver survey rating. Other types have none. Compare within one type only. - medicare_patients, medicare_service_days and medicare_payment are Medicare fee-for-service only, 2024: Part A stays for nursing homes (short rehab stays, not long-term residents), episodes for home health and hospice, Part B facility claims billed under the NPI for surgery centers. NULL means no published figure, not zero. An inpatient rehab unit carries the figures of its whole unit, reported under the parent hospital. - beds is certified beds (nursing homes, intermediate care facilities) or total beds (long-term care hospitals, psychiatric residential treatment). A few counts in the source are typing errors and are NULL. - Owner fields come from ownership disclosures filed with CMS (facility_owners) and exist only for nursing homes, home health agencies, hospices, FQHCs and rural health clinics. NULL elsewhere. - Certification data is the third quarter of 2026; listings and ratings are September to November 2026; HRSA sites are December 2026. ### `facility_owners` Owners and managing parties of nursing homes, home health agencies, hospices, FQHCs and rural health clinics: companies and people, their role, share and investor flags. One row is one owner or managing party in one role at one facility. Key: `id`. How it is read: - Join to facilities on facility_id. owner_associate_id identifies the same owner across facilities: group by it to size a portfolio. - A facility has many owner rows, and one owner can hold several roles at it. Count facilities with count(DISTINCT facility_id). To add up a facilities column per owner, first reduce to distinct (owner_associate_id, owner_name, facility_id), then join and sum. Several funds of one firm own the same facilities, so do not add their totals together. - Roles include '5% OR GREATER DIRECT OWNERSHIP INTEREST', '5% OR GREATER INDIRECT OWNERSHIP INTEREST', 'OPERATIONAL/MANAGERIAL CONTROL', 'CORPORATE OFFICER'. | Column | Type | Meaning | |---|---|---| | `id` | bigint | Row number assigned when the table is loaded. Not stable between loads. | | `facility_id` | text | Facility the party owns or manages. Joins to facilities.facility_id. | | `facility_type` | text | Type of that facility, same values as facilities.facility_type. | | `owner_name` | text | Organization name, or a person's first and last name. UPPERCASE. | | `owner_type` | char(1) | Whether the party is a person or an organization. `I` individual, `O` organization. | | `owner_associate_id` | text | CMS enrollment-system identifier of the owner, the same wherever that owner appears. | | `role` | text | The party's role, for example 5% OR GREATER DIRECT OWNERSHIP INTEREST or CORPORATE OFFICER. | | `title` | text | Job title as the facility entered it. Free text. | | `association_date` | date | Date the party took up this role. | | `pct_ownership` | double precision, percent | Ownership share, 0 to 100. Blank (NULL) or 0 for officers and directors. | | `is_private_equity` | boolean | True when an organization owner is flagged as a private equity company. NULL for individuals. | | `is_reit` | boolean | True when flagged as a real estate investment trust. NULL for individuals. | | `is_holding_company` | boolean | True when flagged as a holding company. NULL for individuals. | | `is_management_company` | boolean | True when flagged as a management services company. NULL for individuals. | | `is_chain_home_office` | boolean | True when flagged as a chain home office. NULL for individuals. | | `is_for_profit` | boolean | True when flagged as a for-profit entity. NULL for individuals. | | `source` | text | File the row came from. `pecos` CMS All Owners file, `care_compare` Care Compare nursing home ownership. | Indexed on `facility_id`, `owner_associate_id`, `owner_name` for substring search. Joins: `facilities` on `facility_owners.facility_id = facilities.facility_id`; `nursing_homes` on `facility_owners.facility_id = nursing_homes.facility_id`; `home_health_agencies` on `facility_owners.facility_id = home_health_agencies.facility_id`; `hospices` on `facility_owners.facility_id = hospices.facility_id`; `dialysis_facilities` on `facility_owners.facility_id = dialysis_facilities.facility_id`; `surgery_centers` on `facility_owners.facility_id = surgery_centers.facility_id`; `health_center_sites` on `facility_owners.facility_id = health_center_sites.facility_id`. Know before you use it: - Self-disclosed to CMS. The private-equity, REIT, holding-company and management-company flags are the filer's own answers, and CMS has said the reporting is incomplete. - Most rows are directors, officers and managing employees with a 0% or blank share. Filter on pct_ownership or role to find equity owners. - About 4% of rows have no owner name in the source and read 'UNKNOWN'. - 166 Medicaid-only nursing homes have no Medicare enrollment; their rows come from the Care Compare ownership file (source 'care_compare'), which has no investor flags and no owner_associate_id. - Owners of an enrollment whose CCN is not a certified facility of that type are left out. Dialysis facilities, surgery centers and the other types have no owner data. - id is a row number assigned at load time. It changes when the data is reloaded, so do not store it. ### `nursing_homes` Nursing home detail: the five-star rating components, occupancy, nurse staffing and turnover, inspection results and penalties. One row is one nursing home listed on Care Compare. Key: `facility_id`. How it is read: - Join to facilities on facility_id for name, address, chain_name, state and Medicare volume. - Ratings are NULL when CMS has not rated a home. Average them as they are; never COALESCE to 0. | Column | Type | Meaning | |---|---|---| | `facility_id` | text | CMS Certification Number. Joins to facilities.facility_id. | | `program_participation` | text | Programs the home is certified for: 'Medicare and Medicaid', 'Medicare' or 'Medicaid'. | | `in_hospital` | boolean | True when the nursing home is inside a hospital. | | `is_ccrc` | boolean | True when part of a continuing care retirement community. | | `special_focus_status` | text | Special Focus Facility program status for persistently poor quality. `SFF` in the program, `SFF Candidate` candidate. | | `abuse_icon` | boolean | True when CMS flags the home for an abuse citation. | | `changed_ownership_12mo` | boolean | True when ownership changed in the last 12 months. | | `chain_id` | text | CMS identifier of the chain. NULL for independent homes. | | `chain_facilities` | integer, facilities | Number of nursing homes in the chain. | | `chain_avg_overall_rating` | double precision, stars | Average overall star rating across the chain. | | `certified_beds` | integer, beds | Federally certified beds. | | `avg_residents_per_day` | double precision, residents | Average residents per day. | | `occupancy_pct` | double precision, percent | Residents per day as a share of certified beds. | | `overall_rating` | smallint, stars | Overall five-star rating, 1 to 5. | | `health_inspection_rating` | smallint, stars | Health inspection star rating, 1 to 5. | | `staffing_rating` | smallint, stars | Staffing star rating, 1 to 5. | | `quality_rating` | smallint, stars | Quality measure star rating, 1 to 5. | | `long_stay_quality_rating` | smallint, stars | Quality star rating for long-stay residents. | | `short_stay_quality_rating` | smallint, stars | Quality star rating for short-stay (rehab) patients. | | `rn_hours_per_resident_day` | double precision, hours | Registered nurse hours per resident per day. | | `lpn_hours_per_resident_day` | double precision, hours | Licensed practical nurse hours per resident per day. | | `aide_hours_per_resident_day` | double precision, hours | Nurse aide hours per resident per day. | | `total_nurse_hours_per_resident_day` | double precision, hours | Total nurse staffing hours per resident per day. | | `weekend_nurse_hours_per_resident_day` | double precision, hours | Total nurse staffing hours per resident per day on weekends. | | `pt_hours_per_resident_day` | double precision, hours | Physical therapist hours per resident per day. | | `nurse_turnover_pct` | double precision, percent | Share of nursing staff who left within a year. | | `rn_turnover_pct` | double precision, percent | Share of registered nurses who left within a year. | | `administrator_departures` | integer, people | Administrators who left within a year. | | `last_inspection_date` | date | Date of the most recent standard health inspection. | | `health_deficiencies` | integer, citations | Health deficiencies cited in the most recent inspection cycle. | | `infection_control_citations` | integer, citations | Citations from infection control inspections. | | `fines` | integer, fines | Fines in the last three years. | | `fines_amount` | double precision, USD | Total amount of those fines. | | `payment_denials` | integer, denials | Medicare payment denials in the last three years. | | `penalties` | integer, penalties | Fines plus payment denials. | Joins: `facilities` on `nursing_homes.facility_id = facilities.facility_id`; `facility_owners` on `nursing_homes.facility_id = facility_owners.facility_id`; `home_health_agencies` on `nursing_homes.facility_id = home_health_agencies.facility_id`; `hospices` on `nursing_homes.facility_id = hospices.facility_id`; `dialysis_facilities` on `nursing_homes.facility_id = dialysis_facilities.facility_id`; `surgery_centers` on `nursing_homes.facility_id = surgery_centers.facility_id`; `health_center_sites` on `nursing_homes.facility_id = health_center_sites.facility_id`. Know before you use it: - Care Compare, November 2026. Staffing comes from payroll data for one quarter; turnover covers a year; fines and penalties cover the last three years. - A rating is NULL when CMS footnotes it (too new, or data not available). 16 certified nursing homes in facilities are not on Care Compare and have no row here. - occupancy_pct is residents per day over certified beds. It is NULL for 48 homes whose residents exceed beds by more than 10%, because the bed count is stale. ### `home_health_agencies` Home health agency detail: services offered, the quality star rating and outcome measures. One row is one home health agency listed on Care Compare. Key: `facility_id`. How it is read: - Join to facilities on facility_id for name, address, ownership and Medicare volume. | Column | Type | Meaning | |---|---|---| | `facility_id` | text | CMS Certification Number. Joins to facilities.facility_id. | | `offers_nursing` | boolean | True when the agency offers nursing care. | | `offers_physical_therapy` | boolean | True when it offers physical therapy. | | `offers_occupational_therapy` | boolean | True when it offers occupational therapy. | | `offers_speech_pathology` | boolean | True when it offers speech pathology. | | `offers_medical_social` | boolean | True when it offers medical social services. | | `offers_home_health_aide` | boolean | True when it offers home health aide services. | | `quality_star_rating` | double precision, stars | Quality of patient care star rating, 1 to 5 in half stars. | | `timely_care_pct` | double precision, percent | How often care began in a timely manner. | | `improved_walking_pct` | double precision, percent | How often patients got better at walking or moving around. | | `improved_bathing_pct` | double precision, percent | How often patients got better at bathing. | | `discharge_to_community_rate` | double precision, percent | Risk-standardized rate of discharge to the community. | | `discharge_to_community_category` | text | That rate against the national rate: Better Than, Same As or Worse Than National Rate. | | `preventable_readmission_rate` | double precision, percent | Risk-standardized potentially preventable 30-day readmission rate. | | `preventable_readmission_category` | text | That rate against the national rate. | | `preventable_hospitalization_rate` | double precision, percent | Risk-standardized potentially preventable hospitalization rate during home health. | | `preventable_hospitalization_category` | text | That rate against the national rate. | | `medicare_spend_ratio` | double precision, ratio | Medicare spending per episode relative to the national average (1.0). | | `spend_episodes` | integer, episodes | Episodes behind the spending ratio. | Joins: `facilities` on `home_health_agencies.facility_id = facilities.facility_id`; `facility_owners` on `home_health_agencies.facility_id = facility_owners.facility_id`; `nursing_homes` on `home_health_agencies.facility_id = nursing_homes.facility_id`; `hospices` on `home_health_agencies.facility_id = hospices.facility_id`; `dialysis_facilities` on `home_health_agencies.facility_id = dialysis_facilities.facility_id`; `surgery_centers` on `home_health_agencies.facility_id = surgery_centers.facility_id`; `health_center_sites` on `home_health_agencies.facility_id = health_center_sites.facility_id`. Know before you use it: - Care Compare, October 2026. A third of agencies are too small or too new for a star rating or outcome rates; those are NULL. - 388 certified agencies in facilities are not on Care Compare and have no row here. - medicare_spend_ratio compares the agency with the national average: 1.0 is average, above 1 costs Medicare more per episode. ### `hospices` Hospice detail: daily census, where care is delivered, diagnosis mix, the Hospice Care Index and the family caregiver survey. One row is one hospice listed on Care Compare. Key: `facility_id`. How it is read: - Join to facilities on facility_id for name, address, ownership and Medicare volume. | Column | Type | Meaning | |---|---|---| | `facility_id` | text | CMS Certification Number. Joins to facilities.facility_id. | | `avg_daily_census` | double precision, patients per day | Average patients on service per day. | | `care_home_pct` | double precision, percent | Share of care days delivered at home. | | `care_assisted_living_pct` | double precision, percent | Share of care days in assisted living facilities. | | `care_nursing_facility_pct` | double precision, percent | Share of care days in long-term nursing facilities. | | `care_skilled_nursing_pct` | double precision, percent | Share of care days in skilled nursing facilities. | | `care_inpatient_hospice_pct` | double precision, percent | Share of care days in inpatient hospice facilities. | | `care_inpatient_hospital_pct` | double precision, percent | Share of care days in inpatient hospitals. | | `patients_cancer_pct` | double precision, percent | Share of patients with a primary diagnosis of cancer. | | `patients_dementia_pct` | double precision, percent | Share of patients with dementia. | | `patients_heart_disease_pct` | double precision, percent | Share of patients with circulatory or heart disease. | | `patients_respiratory_pct` | double precision, percent | Share of patients with respiratory disease. | | `patients_stroke_pct` | double precision, percent | Share of patients with stroke. | | `hospice_care_index` | double precision, score | Hospice Care Index, 0 to 10: how many of ten claims-based quality indicators the hospice met. | | `spending_per_beneficiary` | double precision, USD | Medicare spending per beneficiary. | | `visits_last_days_pct` | double precision, percent | Patients visited by a nurse or social worker on two of their last three days of life. | | `comprehensive_assessment_pct` | double precision, percent | Patients who got all seven admission care processes. | | `family_survey_star_rating` | smallint, stars | Family caregiver survey star rating, 1 to 5. | | `rated_9_or_10_pct` | double precision, percent | Caregivers who rated the hospice 9 or 10 out of 10. | | `would_recommend_pct` | double precision, percent | Caregivers who would definitely recommend the hospice. | Joins: `facilities` on `hospices.facility_id = facilities.facility_id`; `facility_owners` on `hospices.facility_id = facility_owners.facility_id`; `nursing_homes` on `hospices.facility_id = nursing_homes.facility_id`; `home_health_agencies` on `hospices.facility_id = home_health_agencies.facility_id`; `dialysis_facilities` on `hospices.facility_id = dialysis_facilities.facility_id`; `surgery_centers` on `hospices.facility_id = surgery_centers.facility_id`; `health_center_sites` on `hospices.facility_id = health_center_sites.facility_id`. Know before you use it: - Care Compare, November 2026. Measures are NULL when CMS marks them not available (small or new hospices). Only a third of hospices have enough survey responses for a star rating. - 98 certified hospices in facilities are not on Care Compare and have no row here. - The care_*_pct columns split a hospice's days of care by setting and sum to about 100. The patients_*_pct columns split its patients by primary diagnosis. ### `dialysis_facilities` Dialysis facility detail: chain, stations, modalities offered, patient counts and outcome measures. One row is one dialysis facility listed on Care Compare. Key: `facility_id`. How it is read: - Join to facilities on facility_id. chain_organization values: 'DaVita', 'Fresenius Medical Care', 'US Renal Care, Inc.', 'Dialysis Clinic, Inc.', 'American Renal Associates', 'Independent'. | Column | Type | Meaning | |---|---|---| | `facility_id` | text | CMS Certification Number. Joins to facilities.facility_id. | | `esrd_network` | smallint | ESRD Network number (1 to 18) that oversees the facility. | | `chain_owned` | boolean | True when the facility belongs to a chain. | | `chain_organization` | text | Chain name in mixed case, 'Independent' or 'Other'. | | `stations` | integer, stations | Dialysis stations. | | `late_shift` | boolean | True when the facility offers a shift starting at 5 pm or later. | | `offers_in_center_hemodialysis` | boolean | True when it offers in-center hemodialysis. | | `offers_peritoneal_dialysis` | boolean | True when it offers peritoneal dialysis. | | `offers_home_hemodialysis_training` | boolean | True when it offers home hemodialysis training. | | `five_star` | smallint, stars | CMS five-star quality rating, 1 to 5. | | `patients` | integer, patients | Medicare dialysis patients in the hospitalization measure, 2025. | | `survival_patients` | integer, patients | Patients in the four-year survival measure. | | `mortality_rate` | double precision, per 100 patient-years | Deaths per 100 patient-years. | | `survival_category` | text | Survival against expectation: Better than Expected, As Expected or Worse than Expected. | | `hospitalization_rate` | double precision, per 100 patient-years | Hospital admissions per 100 patient-years. | | `hospitalization_category` | text | Hospitalization against expectation. | | `readmission_rate` | double precision, percent | Share of hospital discharges followed by a readmission within 30 days. | | `transfusion_rate` | double precision, per 100 patient-years | Transfusions per 100 patient-years. | | `fistula_rate` | double precision, percent | Share of hemodialysis patients using an arteriovenous fistula. | | `transplant_waitlist_pct` | double precision, percent | Share of patients on a kidney transplant waitlist. | | `adult_hemodialysis_patients` | integer, patients | Adult hemodialysis patients in the adequacy measure. | | `adult_peritoneal_patients` | integer, patients | Adult peritoneal dialysis patients in the adequacy measure. | Joins: `facilities` on `dialysis_facilities.facility_id = facilities.facility_id`; `facility_owners` on `dialysis_facilities.facility_id = facility_owners.facility_id`; `nursing_homes` on `dialysis_facilities.facility_id = nursing_homes.facility_id`; `home_health_agencies` on `dialysis_facilities.facility_id = home_health_agencies.facility_id`; `hospices` on `dialysis_facilities.facility_id = hospices.facility_id`; `surgery_centers` on `dialysis_facilities.facility_id = surgery_centers.facility_id`; `health_center_sites` on `dialysis_facilities.facility_id = health_center_sites.facility_id`. Know before you use it: - Care Compare, October 2026; outcome measures cover calendar 2025 (mortality 2022 to 2025). - 88 certified dialysis facilities in facilities are not on Care Compare and have no row here. - patients is the number of Medicare dialysis patients in the 2025 hospitalization measure, the closest published figure to a census. It undercounts facilities with many non-Medicare patients. - Rates are per 100 patient-years (mortality, hospitalization, transfusion) or percentages, as CMS publishes them. NULL when CMS withholds a small number. ### `surgery_centers` Ambulatory surgery center detail: operating rooms, procedure rooms and the surgical specialties performed. One row is one Medicare-certified ambulatory surgery center. Key: `facility_id`. How it is read: - Join to facilities on facility_id for name, address, ownership and Medicare volume. | Column | Type | Meaning | |---|---|---| | `facility_id` | text | CMS Certification Number (ten characters). Joins to facilities.facility_id. | | `operating_rooms` | integer, rooms | Operating rooms. | | `procedure_rooms` | integer, rooms | Procedure rooms. | | `began_service_date` | date | Date the center began providing surgical services. | | `does_orthopedic` | boolean | True when it performs orthopedic surgery. | | `does_ophthalmology` | boolean | True when it performs eye surgery. | | `does_endoscopy` | boolean | True when it performs endoscopy. | | `does_pain` | boolean | True when it performs pain management procedures. | | `does_ent` | boolean | True when it performs ear, nose and throat surgery. | | `does_plastic` | boolean | True when it performs plastic surgery. | | `does_foot` | boolean | True when it performs foot surgery. | | `does_ob_gyn` | boolean | True when it performs obstetric or gynecologic surgery. | | `does_dental` | boolean | True when it performs dental surgery. | | `does_other` | boolean | True when it performs other kinds of surgery. | Joins: `facilities` on `surgery_centers.facility_id = facilities.facility_id`; `facility_owners` on `surgery_centers.facility_id = facility_owners.facility_id`; `nursing_homes` on `surgery_centers.facility_id = nursing_homes.facility_id`; `home_health_agencies` on `surgery_centers.facility_id = home_health_agencies.facility_id`; `hospices` on `surgery_centers.facility_id = hospices.facility_id`; `dialysis_facilities` on `surgery_centers.facility_id = dialysis_facilities.facility_id`; `health_center_sites` on `surgery_centers.facility_id = health_center_sites.facility_id`. Know before you use it: - From the Provider of Services file, third quarter of 2026: what each center reported at its last certification survey, which can be several years old. - Specialty flags are NULL for about 440 centers that reported none. 45 surgery centers in facilities are known only from the quality file and have no row here. - No case volumes: for Medicare volume use facilities.medicare_patients and medicare_payment, or join facilities.npi to medicare_service for procedure codes. ### `health_center_sites` HRSA health center site detail: the parent health center, look-alike status, site type, hours and website. One row is one active HRSA Health Center Program or look-alike service delivery site. Key: `facility_id`. How it is read: - Join to facilities on facility_id (facility_type = 'health_center_site') for name, address and coordinates. Group by health_center_number to count sites per organization. | Column | Type | Meaning | |---|---|---| | `facility_id` | text | HRSA BPHC assigned site number. Joins to facilities.facility_id. | | `health_center_number` | text | HRSA grant or look-alike number of the parent health center. | | `health_center_name` | text | Name of the parent health center organization. | | `is_look_alike` | boolean | True for a look-alike: meets program rules without a federal grant. | | `location_type` | text | Permanent, Seasonal or Mobile. | | `setting` | text | Site setting, for example Freestanding or Co-located with School. | | `operated_by` | text | Who runs the site: the health center, a subrecipient or a contractor. | | `schedule` | text | Full-Time or Part-Time, when reported. | | `hours_per_week` | double precision, hours | Operating hours per week. | | `website` | text | Website of the health center, lowercase. | | `organization_type` | text | Legal form of the parent organization as HRSA records it. | | `organization_city` | text | City of the parent organization's headquarters. | | `organization_state` | char(2) | Two-letter USPS state code of the parent organization. | | `congressional_district` | text | Congressional district of the site, for example NY-15. | Indexed on `health_center_number`. Joins: `facilities` on `health_center_sites.facility_id = facilities.facility_id`; `facility_owners` on `health_center_sites.facility_id = facility_owners.facility_id`; `nursing_homes` on `health_center_sites.facility_id = nursing_homes.facility_id`; `home_health_agencies` on `health_center_sites.facility_id = home_health_agencies.facility_id`; `hospices` on `health_center_sites.facility_id = hospices.facility_id`; `dialysis_facilities` on `health_center_sites.facility_id = dialysis_facilities.facility_id`; `surgery_centers` on `health_center_sites.facility_id = surgery_centers.facility_id`. Know before you use it: - HRSA data warehouse, 4 December 2026. Sites are self-reported by the health center. - Includes seasonal school-based sites and mobile vans, which have no fixed address. - schedule is published for about a quarter of sites. ## Drug markets ### `rollup_drug_state` Medicare Part D volume per drug and state. POPULATION: Medicare Part D only (PDP and MA-PD plans together); no commercial, no Medicaid. One row is one drug (brand name plus generic name) in one state, per year. Key: `(brand_name, generic_name, state, year)`. How it is read: - PREFER for any Part D drug total or by-state question: milliseconds, where partd_drug takes seconds. Use total_claims and total_drug_cost for market size; sum over states for a national figure. - total_* is NULL for a few pseudo-states: ALWAYS write ORDER BY ... DESC NULLS LAST, and add total_claims IS NOT NULL for a ranking. - Same drug names as partd_drug: brand_name 'Eliquis', generic_name 'Apixaban'. Filter generic_name to cover every brand. - For Medicare Part D next to Medicaid, join rollup_medicaid_drug_state on brand_name, generic_name and state; pick ONE Medicaid year. | Column | Type | Meaning | |---|---|---| | `brand_name` | text | Brand name, title case, same spelling as partd_drug. | | `generic_name` | text | Generic (ingredient) name, title case. | | `state` | char(2) | Two-letter USPS state code of the prescribers. | | `year` | smallint | Calendar year the figures cover. | | `prescribers` | integer, prescribers | Prescribers with 11+ claims of the drug (from partd_drug). | | `claims` | bigint, claims | Claims from those prescribers only; undercounts. | | `fills_30day` | double precision, fills | 30-day-equivalent fills from those prescribers only. | | `drug_cost` | double precision, USD | Drug cost from those prescribers only; undercounts. | | `total_prescribers` | integer, prescribers | All prescribers of the drug in the state (CMS state total). | | `total_claims` | bigint, claims | All Part D claims for the drug in the state (CMS state total). | | `total_drug_cost` | double precision, USD | All Part D drug cost in the state, before rebates (CMS state total). | | `total_benes` | integer, patients | Medicare patients who filled the drug in the state. NULL when under 11. | Indexed on `(generic_name, state)`, `state`. Know before you use it: - Medicare Part D only: prescriptions paid through a Part D plan. Drugs given in a clinic (Part B) and other payers are not counted. - Two sets of figures. prescribers, claims, fills_30day and drug_cost are summed from partd_drug, which leaves out any prescriber with 10 or fewer claims of the drug, so they undercount. total_* are CMS's own state totals over every prescriber (Medicare Part D Prescribers by Geography and Drug): use them for market size. - total_* is NULL for the pseudo-states CMS has no state total for (XX, ZZ, AA, AE, AP) and where CMS suppressed the cell. claims is NULL where no prescriber in the state reached 11 claims. - Calendar year 2024. Registry, group and ownership tables are newer snapshots, so a clinician who moved since shows a different city there. ### `medicaid_drug_state` Medicaid outpatient drug utilization per state, quarter and NDC. POPULATION: Medicaid only (fee-for-service and managed care), all ages; no Medicare, no commercial. One row is one 11-digit NDC in one state, quarter and delivery system (fee-for-service or managed care). Key: `(state, year, quarter, utilization_type, ndc)`. Lake only: stored as Parquet and scanned by the analytics engine. It is not in Postgres and has no indexes. How it is read: - 10M rows. Only for questions by quarter, NDC or labeler. For totals by drug and state use rollup_medicaid_drug_state. - Always filter year (2024 or 2025) and brand_name or generic_name. Sums ignore suppressed cells. | Column | Type | Meaning | |---|---|---| | `state` | char(2) | Two-letter USPS state code of the Medicaid program. | | `year` | smallint | Calendar year the prescriptions were paid. | | `quarter` | smallint | Calendar quarter, 1 to 4. | | `utilization_type` | text | Delivery system that paid. `FFS` fee-for-service Medicaid, `MCO` Medicaid managed care plan. | | `ndc` | char(11) | 11-digit National Drug Code: labeler (5), product (4), package (2). | | `product_name` | text | Product name as the source gives it, cut to 10 characters. | | `brand_name` | text | Full product name; partd_drug spelling when name_source is 'partd'. | | `generic_name` | text | Generic name; partd_drug spelling when name_source is 'partd'. NULL when unknown. | | `name_source` | text | Where the names came from. `partd` matched to a Part D drug name, `fda` FDA NDC Directory name, `sdud` truncated source name. | | `labeler` | text | Company that labels the product (manufacturer, repackager or distributor), from the FDA NDC Directory. | | `suppressed` | boolean | True when CMS withheld the figures (fewer than 11 prescriptions). | | `prescriptions` | bigint, prescriptions | Prescriptions reimbursed. NULL when suppressed. | | `units` | double precision, units | Units reimbursed (tablets, mL, grams, by product). NULL when suppressed. | | `total_reimbursed` | double precision, USD | Total paid to pharmacies, Medicaid plus other payers, before rebates. | | `medicaid_reimbursed` | double precision, USD | Part of total_reimbursed paid by Medicaid. | | `non_medicaid_reimbursed` | double precision, USD | Part of total_reimbursed paid by other payers. | Know before you use it: - Medicaid State Drug Utilization Data, calendar years 2024 and 2025. Covers outpatient drugs states report for the Medicaid Drug Rebate Program; drugs not in that program are missing. No prescriber or pharmacy is identified. - A cell with fewer than 11 prescriptions is suppressed: the row exists with suppressed = true and NULL figures, which means hidden, not zero. About half the rows are suppressed, though they hold little volume. - Amounts are what Medicaid and other payers reimbursed pharmacies, before manufacturer rebates, which are large in Medicaid. Do not read them as net spending. - The source cuts product names to 10 characters. brand_name and generic_name come from the FDA NDC Directory and are spelled like partd_drug when the drug exists there (name_source = 'partd': 87% of prescriptions, 94% of dollars in 2025). Otherwise they are FDA names in title case ('fda'), or the truncated source name with no generic ('sdud'). - Lake only: stored as Parquet and scanned by the analytics engine. It has no indexes and cannot be joined to on Postgres. ### `rollup_medicaid_drug_state` Medicaid drug volume per drug, state and year. POPULATION: Medicaid only (fee-for-service plus managed care); no Medicare, no commercial. One row is one drug (brand name plus generic name) in one state, per year. How it is read: - PREFER for Medicaid drug questions. ALWAYS filter year (2025 is newest; 2024 matches the Medicare tables), or two years are added together. - Drug names match partd_drug and rollup_drug_state when in_partd is true: brand_name 'Eliquis', generic_name 'Apixaban'. | Column | Type | Meaning | |---|---|---| | `year` | smallint | Calendar year: 2024 or 2025. | | `brand_name` | text | Product name; partd_drug spelling when in_partd. | | `generic_name` | text | Generic name; partd_drug spelling when in_partd. NULL when unknown. | | `state` | char(2) | Two-letter USPS state code of the Medicaid program. | | `in_partd` | boolean | True when the drug name matches a drug in partd_drug. | | `prescriptions` | bigint, prescriptions | Medicaid prescriptions, fee-for-service plus managed care. | | `units` | double precision, units | Units reimbursed. | | `total_reimbursed` | double precision, USD | Total paid to pharmacies, before rebates. | | `medicaid_reimbursed` | double precision, USD | Part of total_reimbursed paid by Medicaid. | | `ffs_prescriptions` | bigint, prescriptions | Prescriptions paid by fee-for-service Medicaid. | | `mco_prescriptions` | bigint, prescriptions | Prescriptions paid by Medicaid managed care plans. | | `ffs_reimbursed` | double precision, USD | Amount paid under fee-for-service. | | `mco_reimbursed` | double precision, USD | Amount paid under managed care. | | `ndcs` | integer, NDCs | Distinct NDCs (package sizes and labelers) behind the row. | | `suppressed_cells` | integer, cells | Withheld NDC-quarter cells (under 11 prescriptions each) not in the sums. | Indexed on `(brand_name, state, year)`, `(generic_name, state, year)`, `(state, year)`. Know before you use it: - Built from medicaid_drug_state (Medicaid State Drug Utilization Data), calendar years 2024 and 2025. - Sums leave out suppressed cells (fewer than 11 prescriptions each); suppressed_cells counts them. When every cell is suppressed the figures are NULL, not zero. - Amounts are before manufacturer rebates, which are large in Medicaid. - A different year from the Medicare tables (2024): compare Medicaid 2024 to Part D 2024, or say the years differ. ### `drug_spending` National spending per drug and year, 2020 to 2024, for Medicare Part D, Medicare Part B and Medicaid, with manufacturer and unit price trend. One row is one drug, one manufacturer (or 'Overall') and one program, per year. Key: `id`. How it is read: - For a drug's total ALWAYS filter manufacturer = 'Overall'. For who makes it, filter manufacturer <> 'Overall'. - program is 'part_d', 'part_b' or 'medicaid'. Drug names are spelled like partd_drug ('Eliquis', 'Apixaban'). | Column | Type | Meaning | |---|---|---| | `id` | integer | Row number; no meaning outside this table. | | `program` | text | Which program paid. `part_d` Medicare Part D, `part_b` Medicare Part B fee-for-service, `medicaid` Medicaid. | | `brand_name` | text | Brand name, title case. | | `generic_name` | text | Generic name, title case. | | `manufacturer` | text | Manufacturer as CMS abbreviates it, or 'Overall' for all manufacturers together. | | `manufacturers` | integer, manufacturers | Number of manufacturers of the drug. NULL for Part B. | | `hcpcs_code` | text | HCPCS code of the drug. Part B rows only. | | `year` | smallint | Calendar year the figures cover. | | `total_spending` | double precision, USD | Total spending on the drug, before rebates. | | `dosage_units` | double precision, units | Dosage units dispensed or administered. | | `claims` | double precision, claims | Prescription fills (Part D, Medicaid) or claims (Part B). | | `benes` | double precision, patients | Patients who used the drug. NULL for Medicaid. | | `avg_spend_per_unit` | double precision, USD per unit | Average spending per dosage unit, weighted by volume. | | `avg_spend_per_claim` | double precision, USD per claim | Average spending per claim. | | `avg_spend_per_bene` | double precision, USD per patient | Average spending per patient. NULL for Medicaid. | | `outlier` | boolean | True when CMS flags the year's figures as an outlier. | | `unit_price_change_1y` | double precision, fraction | Change in average spending per unit, 2023 to 2024, as a fraction (0.05 = +5%). Same on every year's row. | | `unit_price_cagr` | double precision, fraction | Annual growth rate of average spending per unit, 2020 to 2024, as a fraction. Same on every year's row. | Indexed on `(brand_name, program, year)`, `(generic_name, program, year)`, `(program, year, manufacturer)`. Joins: `medicare_service` on `drug_spending.hcpcs_code = medicare_service.hcpcs_code`; `hcpcs` on `drug_spending.hcpcs_code = hcpcs.code`; `rollup_hcpcs_state` on `drug_spending.hcpcs_code = rollup_hcpcs_state.hcpcs_code`. Know before you use it: - CMS Drug Spending dashboards. National only: no state or prescriber. Three populations, in the program column: Medicare Part D, Medicare Part B fee-for-service, Medicaid. No commercial. - Part D and Medicaid list each drug once per manufacturer and once more as manufacturer = 'Overall'. Adding all rows of a drug doubles it. - Spending is gross, before manufacturer rebates. Part B rows are per HCPCS code and have no manufacturer. - A drug with no spending in a year has no row for that year. Medicaid has no patient counts. ## Payers ### `ma_plans` Every Medicare private plan with its insurer and parent company: Medicare Advantage, cost and PACE plans, and stand-alone Part D plans. POPULATION: Medicare beneficiaries in private plans; no commercial or Medicaid plans. One row is one plan (contract ID plus plan ID) in the November 2026 CMS enrollment file. How it is read: - plan_category: 'MA' Medicare Advantage, 'PDP' stand-alone drug plan, 'OTHER' cost, PACE and demonstration plans. Filter plan_category = 'MA' for Medicare Advantage. - Match parent_organization with ILIKE '%unitedhealth%'. For enrollment by state use ma_enrollment_state; by county join ma_enrollment_county on contract_id and plan_id. | Column | Type | Meaning | |---|---|---| | `contract_id` | text | CMS contract number, for example H1234. | | `plan_id` | text | Plan number within the contract, three digits. | | `plan_category` | text | Kind of plan. `MA` Medicare Advantage, `PDP` stand-alone Part D drug plan, `OTHER` cost, PACE or demonstration plan. | | `organization_type` | text | Contract type as CMS names it. | | `plan_type` | text | Plan type: HMO/HMOPOS, Local PPO, Regional PPO, PFFS, MSA, PDP and others. | | `offers_part_d` | boolean | True when the plan includes drug coverage. | | `is_snp` | boolean | True for a Special Needs Plan. | | `is_employer_plan` | boolean | True for an employer or union group plan. | | `organization_name` | text | Legal name of the organization holding the contract. | | `marketing_name` | text | Name the organization markets under. | | `plan_name` | text | Name of the plan. | | `parent_organization` | text | Parent company of the contract. | | `contract_effective_date` | date | Date the contract with CMS began. | | `enrollment` | integer, enrollees | Enrollees, summed over published counties. NULL when no county is published. | | `counties` | integer, counties | Counties with a published enrollment figure. | | `suppressed_counties` | integer, counties | Counties withheld (10 or fewer enrollees). | Indexed on `(contract_id, plan_id)`, `parent_organization`. Joins: `ma_enrollment_county` on `ma_plans.contract_id = ma_enrollment_county.contract_id`. Know before you use it: - CMS Monthly Enrollment by Contract/Plan/State/County, November 2026. Medicare plans only: employer commercial insurance, exchange plans and Medicaid managed care are not here. - enrollment is the sum of the plan's county rows. CMS withholds counties with 10 or fewer enrollees, so it is slightly low; suppressed_counties counts what was withheld. - Five cost contracts are listed without a plan (plan_id NULL) and have no enrollment rows. - parent_organization is the name CMS records ('UnitedHealth Group, Inc.', 'Humana Inc.', 'CVS Health Corporation' for Aetna, 'Elevance Health, Inc.' for Anthem). ### `ma_enrollment_county` Enrollment in each Medicare private plan per county of residence. POPULATION: Medicare beneficiaries in private plans (Medicare Advantage, cost, PACE, stand-alone Part D). One row is one plan in one county, November 2026. Key: `(contract_id, plan_id, ssa_code)`. How it is read: - 3.4M rows. Filter state or county_fips. Join ma_plans p ON p.contract_id = e.contract_id AND p.plan_id = e.plan_id for insurer and plan type. - county_fips joins medicare_enrollment_county for total Medicare population. For state totals by insurer use ma_enrollment_state. | Column | Type | Meaning | |---|---|---| | `contract_id` | text | CMS contract number; joins ma_plans. | | `plan_id` | text | Plan number within the contract; joins ma_plans. | | `ssa_code` | char(5) | Social Security state-county code of the county. | | `county_fips` | char(5) | Five-digit county FIPS code. NULL when CMS did not map the county. | | `state` | char(2) | Two-letter USPS state code of the county. | | `county` | text | County name. | | `enrollment` | integer, enrollees | Enrollees living in the county. NULL when 10 or fewer. | Indexed on `county_fips`, `state`. Joins: `ma_plans` on `ma_enrollment_county.contract_id = ma_plans.contract_id`; `facilities` on `ma_enrollment_county.county_fips = facilities.county_fips`; `medicare_enrollment_county` on `ma_enrollment_county.county_fips = medicare_enrollment_county.county_fips`. Know before you use it: - CMS withholds any plan-county cell with 10 or fewer enrollees: enrollment is NULL, which means 1 to 10, not zero. 94% of rows are withheld (mostly a handful of members living outside the plan's service area); the published rows hold almost all enrollees. - County is where the enrollee lives. About 3,500 rows have no state and 10,000 no county_fips, because CMS did not map their SSA county code. - Includes stand-alone Part D plans. Join ma_plans and filter plan_category = 'MA' for Medicare Advantage only, or drug-plan members are counted as MA. ### `ma_enrollment_state` Medicare private-plan enrollment per state and parent company. POPULATION: Medicare beneficiaries in private plans, split into Medicare Advantage, stand-alone Part D and other. One row is one parent company and one plan category in one state, November 2026. Key: `(state, parent_organization, plan_category)`. How it is read: - PREFER for payer market share by state. Filter plan_category = 'MA' for Medicare Advantage; without it stand-alone drug plans are mixed in. - This table is NOT the Medicare population. For the share of a state's Medicare beneficiaries in Medicare Advantage (MA penetration) use medicare_enrollment_state.ma_share (year = 2026), never a ratio within this table. - Share = enrollment / sum(enrollment) over the state. Match insurers with ILIKE: '%unitedhealth%', '%humana%', '%cvs%' (Aetna), '%elevance%' (Anthem), '%kaiser%'. | Column | Type | Meaning | |---|---|---| | `state` | char(2) | Two-letter USPS state code of the enrollees. | | `parent_organization` | text | Parent company of the plans. | | `plan_category` | text | Kind of plan. `MA` Medicare Advantage, `PDP` stand-alone Part D drug plan, `OTHER` cost, PACE or demonstration plan. | | `contracts` | integer, contracts | Contracts with enrollees in the state. | | `plans` | integer, plans | Plans with enrollees in the state. | | `enrollment` | integer, enrollees | Enrollees living in the state, published cells only. | | `snp_enrollment` | integer, enrollees | Part of enrollment in Special Needs Plans. | | `suppressed_cells` | integer, cells | Withheld plan-county cells (1 to 10 enrollees each) not in the sum. | Indexed on `parent_organization`. Know before you use it: - Built from ma_enrollment_county and ma_plans. Withheld county cells (10 or fewer enrollees) are not in the sum: the true figure lies between enrollment and enrollment + 10 x suppressed_cells. - Medicare only. An insurer's commercial and Medicaid members are not counted. ### `medicare_enrollment_state` People with Medicare per state and year, split into Original Medicare (fee-for-service) and Medicare Advantage. The denominator for every fee-for-service table: it says what share of a state's Medicare population those tables can see. One row is one state, per year. Key: `(state, year)`. How it is read: - To caveat or scale a 2024 fee-for-service figure, join on state and year = 2024: FFS share = original_medicare_benes / total_benes. - Never add years together. For 'now' use year = 2026. | Column | Type | Meaning | |---|---|---| | `state` | char(2) | Two-letter USPS state code of the beneficiaries. | | `year` | smallint | Calendar year. | | `month` | smallint | NULL for a yearly figure; the month number when the row is a single month (the newest year). | | `total_benes` | bigint, people | People with Medicare Part A or B. | | `original_medicare_benes` | bigint, people | People in Original Medicare (fee-for-service). | | `ma_other_benes` | bigint, people | People in Medicare Advantage and other health plans. | | `ma_share` | double precision, fraction | ma_other_benes / total_benes, 0 to 1. | | `aged_benes` | bigint, people | People entitled by age (65+). | | `disabled_benes` | bigint, people | People entitled by disability (under 65). | | `dual_benes` | bigint, people | People with both Medicare and Medicaid. | | `part_d_benes` | bigint, people | People with Part D drug coverage. | | `pdp_benes` | bigint, people | Part D enrollees in stand-alone drug plans. | | `mapd_benes` | bigint, people | Part D enrollees in Medicare Advantage drug plans. | Know before you use it: - CMS Medicare Monthly Enrollment. Years 2013 to 2025 are CMS's yearly figure (month is NULL); 2026 is the latest month published, August (month = 8). - The claims tables (medicare_provider, medicare_service, hospitals) cover only original_medicare_benes. Where ma_share is high (over half in many states) they see under half of Medicare patients. - States, DC and territories. The national row and CMS's 'foreign' and 'unknown' rows are left out, so states add up to slightly less than the US total. ### `medicare_enrollment_county` People with Medicare per county and year, split into Original Medicare (fee-for-service) and Medicare Advantage. One row is one county, per year. Key: `(county_fips, year)`. How it is read: - Never add years together: filter year. county_fips joins ma_enrollment_county. | Column | Type | Meaning | |---|---|---| | `county_fips` | char(5) | Five-digit county FIPS code. | | `state` | char(2) | Two-letter USPS state code of the county. | | `county` | text | County name. | | `year` | smallint | Calendar year. | | `month` | smallint | NULL for a yearly figure; the month number for the newest year. | | `total_benes` | bigint, people | People with Medicare Part A or B. | | `original_medicare_benes` | bigint, people | People in Original Medicare (fee-for-service). | | `ma_other_benes` | bigint, people | People in Medicare Advantage and other health plans. | | `ma_share` | double precision, fraction | ma_other_benes / total_benes, 0 to 1. | | `dual_benes` | bigint, people | People with both Medicare and Medicaid. | | `part_d_benes` | bigint, people | People with Part D drug coverage. | Indexed on `(state, year)`. Joins: `facilities` on `medicare_enrollment_county.county_fips = facilities.county_fips`; `ma_enrollment_county` on `medicare_enrollment_county.county_fips = ma_enrollment_county.county_fips`. Know before you use it: - CMS Medicare Monthly Enrollment. Years 2013 to 2025 are CMS's yearly figure (month is NULL); 2026 is the latest month published, August (month = 8). - A figure based on fewer than 11 people is NULL. Each state also has an 'Unknown' county row (county_fips ending 999). ## ACOs ### `acos` Medicare Shared Savings Program accountable care organizations: track, size, savings and quality, with the ACO's published executive contact. One row is one ACO. Key: `aco_id`. How it is read: - state is the ACO's office; service_area lists every state it operates in ('AZ, NV'): match it with ILIKE '%TX%'. - Members are in aco_participants (join on aco_id), which links to groups and, through group_members, to clinicians. | Column | Type | Meaning | |---|---|---| | `aco_id` | text | CMS ACO identifier, for example A1033. | | `name` | text | Name of the ACO. | | `participating` | boolean | True when the ACO is in the program in 2026. | | `service_area` | text | States the ACO operates in, comma-separated USPS codes. | | `state` | char(2) | Two-letter USPS state code of the ACO's office. | | `city` | text | City of the ACO's office. | | `zip5` | char(5) | ZIP code of the ACO's office. | | `address` | text | Office address as published. | | `track` | text | Risk track of the ACO. `BASIC` BASIC track (levels A to E; A and B carry no downside risk), `ENHANCED` ENHANCED track, highest risk and reward. | | `basic_track_level` | text | Level A to E within the BASIC track. | | `revenue_class` | text | CMS revenue class. `high` high revenue, typically hospital-led, `low` low revenue, typically physician-led. | | `assignment` | text | How patients are assigned: prospective or retrospective. | | `agreement_period` | smallint | Number of the ACO's current agreement period. | | `initial_start_date` | date | Date the ACO first joined the program. | | `current_start_date` | date | Start of the current agreement period. | | `snf_waiver` | boolean | True when the ACO holds the skilled-nursing 3-day rule waiver. | | `website` | text | Public reporting website of the ACO. | | `executive_name` | text | ACO executive, as published. | | `executive_email` | text | Executive's published e-mail address. | | `executive_phone` | text | Executive's published phone number. | | `medical_director_name` | text | ACO medical director, as published. | | `participants` | integer, participants | Participant organizations listed for 2026. | | `results_year` | smallint | Performance year of the result columns (2025). NULL when none. | | `assigned_benes` | integer, patients | Medicare patients assigned to the ACO in the results year. | | `benchmark` | double precision, USD | Total benchmark expenditure the ACO was measured against. | | `expenditures` | double precision, USD | Total actual expenditure for assigned patients. | | `generated_savings` | double precision, USD | Benchmark minus expenditures; negative is a loss. | | `earned_savings` | double precision, USD | Shared savings paid to the ACO; negative is a loss owed. | | `savings_rate` | double precision, fraction | generated_savings / benchmark, as a fraction. | | `quality_score` | double precision, score | Quality score, 0 to 1. | Indexed on `state`, `name` for substring search. Joins: `aco_participants` on `acos.aco_id = aco_participants.aco_id`. Know before you use it: - Medicare Shared Savings Program only. ACO REACH, Medicare Advantage and commercial ACO contracts are not included. - Organization details are performance year 2026. Results (assigned_benes through quality_score) are performance year 2025, the latest CMS has published: an ACO new in 2026 has none, and an ACO that left after 2025 is kept with participating = false. - Assigned beneficiaries are Original Medicare patients attributed to the ACO's clinicians, not members who enrolled. - Contact names, e-mail addresses and phone numbers are the ones each ACO must publish through CMS. ### `aco_participants` The organizations taking part in each Medicare Shared Savings Program ACO in 2026: practices, hospitals and clinics, by legal business name. One row is one participant organization in one ACO. Key: `id`. How it is read: - Clinicians in an ACO: aco_participants ap JOIN group_members gm ON gm.group_pac_id = ap.group_pac_id, then medicare_provider or providers on npi. - Is a group in an ACO: filter group_pac_id. Join acos on aco_id for the ACO's name, track and results. | Column | Type | Meaning | |---|---|---| | `id` | integer | Row number; no meaning outside this table. | | `aco_id` | text | ACO identifier; joins acos. | | `participant_name` | text | Legal business name of the participant, as published. | | `entries` | integer, entries | Times the name is listed for the ACO (separate tax IDs with one name). | | `group_pac_id` | bigint | Matched group practice in groups. NULL when not matched. | Indexed on `aco_id`, `group_pac_id`, `participant_name` for substring search. Joins: `acos` on `aco_participants.aco_id = acos.aco_id`; `groups` on `aco_participants.group_pac_id = groups.group_pac_id`; `group_members` on `aco_participants.group_pac_id = group_members.group_pac_id`. Know before you use it: - CMS publishes participant names only: no tax ID and no NPI. - group_pac_id is our own link, made only when the name equals exactly one group practice in the ACO's service-area states. 75% of rows are linked; solo practitioners listed under a person's name and ambiguous names are not. - A participant's clinicians are found through the group link (group_members), which covers clinicians who bill through that group. It is not CMS's official ACO provider list. ## Experts ### `trials` Clinical trials: every interventional study registered on ClinicalTrials.gov with at least one US site, with condition, sponsor, phase and status. One row is one study (NCT number). Key: `nct_id`. How it is read: - conditions and interventions are '; '-separated free text: match with ILIKE '%heart failure%'. - status: RECRUITING, NOT_YET_RECRUITING, ACTIVE_NOT_RECRUITING, COMPLETED, TERMINATED, WITHDRAWN. sponsor_class 'INDUSTRY' is a company; 'NIH', 'OTHER' is mostly academic. - Sites are in trial_sites and people in trial_investigators, both joined on nct_id. | Column | Type | Meaning | |---|---|---| | `nct_id` | text | ClinicalTrials.gov identifier, for example NCT04224961. | | `title` | text | Brief title of the study. | | `status` | text | Overall recruitment status. | | `phase` | text | Phase: PHASE1, PHASE2, PHASE3, PHASE4, combinations like PHASE1/PHASE2, or NA for device and behavioral studies. | | `start_date` | date | Study start date (may be an estimate). | | `primary_completion_date` | date | Primary completion date (may be an estimate). | | `last_update_date` | date | Date the record was last updated. | | `enrollment` | integer, participants | Participants enrolled or planned. | | `conditions` | text | Conditions studied, '; '-separated free text. | | `intervention_types` | text | Kinds of intervention: DRUG, DEVICE, BIOLOGICAL, PROCEDURE, BEHAVIORAL and others, '; '-separated. | | `interventions` | text | Intervention names (drug or device), '; '-separated, at most 12. | | `sponsor` | text | Lead sponsor. | | `sponsor_class` | text | Kind of sponsor. `INDUSTRY` company, `NIH` NIH, `FED` other federal agency, `OTHER` university, hospital or other. | | `us_sites` | integer, sites | Number of US sites listed. | | `us_states` | integer, states | Number of US states with a site. | Indexed on `sponsor`, `start_date`, `conditions` for substring search. Joins: `trial_sites` on `trials.nct_id = trial_sites.nct_id`; `trial_investigators` on `trials.nct_id = trial_investigators.nct_id`. Know before you use it: - ClinicalTrials.gov as downloaded 2026-12-05. Interventional studies with a US site only: observational studies and studies with no US site are not included. - Entered by sponsors: conditions and interventions are free text, not coded, and dates can be estimates or wrong (a few start dates are far in the future). ### `trial_sites` The US sites of each clinical trial: facility name and location as the sponsor entered them. One row is one US site of one study. Key: `id`. How it is read: - 1.4M rows. Filter state (and city) or nct_id. Count trials with count(DISTINCT nct_id). Match a hospital with facility ILIKE '%mayo clinic%'. | Column | Type | Meaning | |---|---|---| | `id` | integer | Row number; no meaning outside this table. | | `nct_id` | text | Study identifier; joins trials. | | `facility` | text | Site name as entered by the sponsor. | | `city` | text | City of the site. | | `state` | char(2) | Two-letter USPS state code of the site. | | `zip5` | char(5) | ZIP code of the site. | | `recruitment_status` | text | Recruitment status of this site, when the study is still recruiting. | Indexed on `nct_id`, `(state, city)`. Joins: `trials` on `trial_sites.nct_id = trials.nct_id`; `trial_investigators` on `trial_sites.nct_id = trial_investigators.nct_id`. Know before you use it: - Facility names are free text typed by sponsors: the same hospital appears under several spellings and is not linked to hospitals.ccn. - Some industry studies hide the facility name ('Research Site'), so facility is missing or generic for about 6% of rows. ### `trial_investigators` The people named on clinical trials: principal investigators, study chairs and directors, and site investigators, linked to an NPI where the name is unambiguous. A signal of who the clinical experts are. One row is one named person in one role on one study (and one site, for site investigators). Key: `id`. How it is read: - For clinicians, filter npi IS NOT NULL and join providers or medicare_provider on npi. Count trials per person with count(DISTINCT nct_id). - Join trials on nct_id for condition, sponsor, phase and status. role 'PRINCIPAL_INVESTIGATOR' is the main one. | Column | Type | Meaning | |---|---|---| | `id` | integer | Row number; no meaning outside this table. | | `nct_id` | text | Study identifier; joins trials. | | `source` | text | Where the person is listed. `overall_official` study-level official, `site` investigator at one site. | | `role` | text | Role: PRINCIPAL_INVESTIGATOR, SUB_INVESTIGATOR, STUDY_CHAIR or STUDY_DIRECTOR. | | `name` | text | Name as published, often with degrees. | | `affiliation` | text | Affiliation of a study-level official, as published. | | `facility` | text | Site the person is attached to, when known. | | `city` | text | City of that site. | | `state` | char(2) | Two-letter USPS state code where the person was placed. NULL when it cannot be told. | | `zip5` | char(5) | ZIP code of that site. | | `state_basis` | text | How the state was decided. `site` the person's own site, `affiliation_is_site` the affiliation is one of the study's sites, `only_state` every US site of the study is in this state. | | `npi` | bigint | Linked National Provider Identifier. NULL when not linked. | | `match_confidence` | text | Strength of the NPI link. `high` unique name in the state, same city or ZIP, `medium` unique name in the state only. | Indexed on `npi`, `nct_id`, `state`. Joins: `trials` on `trial_investigators.nct_id = trials.nct_id`; `trial_sites` on `trial_investigators.nct_id = trial_sites.nct_id`; `medicare_provider` on `trial_investigators.npi = medicare_provider.npi`; `medicare_service` on `trial_investigators.npi = medicare_service.npi`; `providers` on `trial_investigators.npi = providers.npi`; `partd_provider` on `trial_investigators.npi = partd_provider.npi`; `partd_drug` on `trial_investigators.npi = partd_drug.npi`; `hospitals` on `trial_investigators.npi = hospitals.npi`; `group_members` on `trial_investigators.npi = group_members.npi`; `open_payments` on `trial_investigators.npi = open_payments.npi`; `clinician_facilities` on `trial_investigators.npi = clinician_facilities.npi`; `facilities` on `trial_investigators.npi = facilities.npi`; `nih_grants` on `trial_investigators.npi = nih_grants.npi`. Know before you use it: - ClinicalTrials.gov publishes names without NPIs. npi is our own link, made only when the name parses as one person, the investigator can be placed in a state, exactly one person in the NPI registry has that first and last name in that state, and that person is a doctoral-level clinician. 45% of rows are linked (67% of site principal investigators). - match_confidence 'high' means the registry address is in the investigator's city or ZIP; 'medium' means same state only. A name match can still be a different person: treat 'medium' as a lead to verify. - No npi means not linked, not that the person is no clinician: common names, non-clinician scientists, sponsor staff ('Medical Director') and multi-state studies whose official cannot be placed stay unlinked. - Site investigators are published only while a site is recruiting, so older studies list just the study-level officials. ### `nih_grants` NIH research funding: funded projects with their principal investigators, organization and award, fiscal years 2024 to 2026, linked to an NPI where the name is unambiguous. One row is one principal investigator on one funded project, per fiscal year. Key: `id`. How it is read: - Money: sum(award_amount) with is_contact_pi AND NOT is_subproject, and filter fiscal_year, or dollars are counted several times. - Funded clinicians: npi IS NOT NULL, joined to providers or medicare_provider on npi. activity_code 'R01' is the standard research grant; 'K' codes are career awards. | Column | Type | Meaning | |---|---|---| | `id` | integer | Row number; no meaning outside this table. | | `application_id` | bigint | NIH application ID: one funded project-year. | | `fiscal_year` | smallint | Federal fiscal year of the award (October to September). | | `project_num` | text | Full project number, for example 5R01CA244947-05. | | `core_project_num` | text | Project number without year and type: the same across a grant's years. | | `activity_code` | text | Grant mechanism: R01, R21, K23, U01, P30 and others. | | `institute` | text | NIH institute administering the award: NCI, NHLBI, NIA and others. | | `title` | text | Project title. | | `organization` | text | Organization receiving the award, upper case. | | `org_city` | text | City of the organization. | | `state` | char(2) | Two-letter USPS state code of the organization. | | `zip5` | char(5) | ZIP code of the organization. | | `organization_type` | text | Kind of organization, for example SCHOOLS OF MEDICINE. | | `pi_name` | text | Principal investigator's name. | | `pi_profile_id` | bigint | NIH's identifier for the investigator, the same across projects. | | `pi_title` | text | Investigator's position title as recorded by NIH. | | `is_contact_pi` | boolean | True for the project's contact investigator (exactly one per project). | | `pi_count` | smallint, people | Number of principal investigators on the project. | | `is_subproject` | boolean | True for a subproject of a larger center or program grant. | | `award_amount` | double precision, USD | Total award for the project-year, repeated on each investigator's row. | | `direct_cost` | double precision, USD | Direct costs of the award. | | `indirect_cost` | double precision, USD | Indirect (overhead) costs of the award. | | `project_start_date` | date | Start of the whole project. | | `project_end_date` | date | Planned end of the whole project. | | `npi` | bigint | Linked National Provider Identifier. NULL when not linked. | | `match_confidence` | text | Strength of the NPI link. `high` unique name in the state, same city, `medium` unique name in the state only. | Indexed on `npi`, `(state, fiscal_year)`, `application_id`, `organization`. Joins: `medicare_provider` on `nih_grants.npi = medicare_provider.npi`; `medicare_service` on `nih_grants.npi = medicare_service.npi`; `providers` on `nih_grants.npi = providers.npi`; `partd_provider` on `nih_grants.npi = partd_provider.npi`; `partd_drug` on `nih_grants.npi = partd_drug.npi`; `hospitals` on `nih_grants.npi = hospitals.npi`; `group_members` on `nih_grants.npi = group_members.npi`; `open_payments` on `nih_grants.npi = open_payments.npi`; `clinician_facilities` on `nih_grants.npi = clinician_facilities.npi`; `facilities` on `nih_grants.npi = facilities.npi`; `trial_investigators` on `nih_grants.npi = trial_investigators.npi`. Know before you use it: - NIH RePORTER, fiscal years 2024 to 2026, organizations in US states and territories. About 4% of FY2024 and FY2025 projects have no state in RePORTER and are not included. FY2026 was downloaded 2026-12-05 and may still gain late awards. - A project with several principal investigators has one row each, and every row repeats the project's award_amount. Subprojects of center grants are rows too, and their money is already inside the parent award. - RePORTER has no NPI. npi is our own link: exactly one doctoral-level clinician in the NPI registry with that first and last name in the organization's state. 21% of rows are linked, because most NIH investigators are scientists without an NPI. 'medium' links (same state, different city) need verifying. ## Catalog ### `sources` The receipt behind every number: which file each table was built from, its version, and when it was loaded. One row is one loaded dataset (one table). Key: `dataset`. Postgres only: it has no copy in the lake. | Column | Type | Meaning | |---|---|---| | `dataset` | text | Dataset name, the same as the table it loads. | | `title` | text | Title of the source file as the publisher names it. | | `publisher` | text | Who published the source file. | | `url` | text | Download link of the exact file version that was loaded. | | `version` | text | Publisher's release or version label. | | `data_year` | smallint | Year the data describes. | | `table_name` | text | Table the dataset is loaded into. | | `row_count` | bigint, rows | Rows in the table after the last load. | | `raw_keys` | text[] | Object Storage keys of the files exactly as published. | | `parquet_key` | text | Object Storage key of the cleaned Parquet file in the lake. | | `in_postgres` | boolean | True when the table is also loaded into Postgres. False means lake only. | | `parquet_bytes` | bigint, bytes | Size of the Parquet file. | | `loaded_at` | timestamp with time zone | When the table was last loaded. | Know before you use it: - Written by the pipeline at load time. Postgres only: it has no copy in the lake. ### `catalog_columns` Profile statistics for every column of every dataset: how full it is, how many distinct values it has, its range and its most common values. One row is one column of one dataset. Key: `(dataset, column_name)`. Postgres only: it has no copy in the lake. | Column | Type | Meaning | |---|---|---| | `dataset` | text | Table the column belongs to. | | `column_name` | text | Name of the column. | | `ordinal` | integer | Position of the column in its table, starting at 1. | | `null_pct` | double precision, percent | Share of rows where the column is NULL, 0 to 100. | | `distinct_count` | bigint, values | Number of distinct non-NULL values. Exact for tables up to 50 million rows, approximate above. | | `min` | text | Smallest value, as text. Numbers and dates only. | | `max` | text | Largest value, as text. Numbers and dates only. | | `median` | double precision | Median value. Numeric columns only. | | `top_values` | jsonb | Most common values with their row counts, as a JSON array of {v, n}. Only for category columns with at most 10,000 distinct values. | | `profiled_at` | timestamp with time zone | When the statistics were computed. | Know before you use it: - Computed from the Parquet files when the pipeline runs, so it describes the data as of profiled_at. - Identifier, name, address and phone columns carry only null_pct and distinct_count. Their min, max, median and top_values are always NULL. --- # Caveats URL: https://openpipe.health/docs/data/caveats/ Markdown: https://openpipe.health/docs/data/caveats.md > What the data does not show. Read this before quoting a number. ## Volumes are Medicare fee-for-service only Every service, patient and payment count comes from traditional Medicare Part B and Part D claims. It leaves out: - Commercial insurance - Medicare Advantage - Medicaid - Self-pay A surgeon's `services` is therefore a floor, not their total volume. The share that Medicare fee-for-service represents varies a lot by specialty and region: it is high for cataract surgery and joint replacement, and close to nothing for paediatrics and obstetrics. Use the numbers to **rank and compare** clinicians within a specialty. Do not present them as total procedure counts. The same scope applies to hospital DRG volumes (`hospital_drgs`) and to the Medicare patients, days and payments on care sites (`facilities`). To see how much of an area's Medicare population fee-for-service covers, read `ma_share` on [`GET /api/market/payers`](https://openpipe.health/docs/api/payers-acos.md#get-medicare-payers-in-a-state-or-the-nation): where it is above one half, these tables see under half of Medicare patients. A few datasets cover other populations, and each says so in its response: Medicare Part D plans, Medicaid, and Medicare private-plan enrollment. See [Drug markets, payers and ACOs](#drug-markets-payers-and-acos). None of the data is commercial insurance. ## Small cells are suppressed CMS withholds any figure based on fewer than 11 patients. In the Medicare files those rows are missing or the value is `NULL`. - A clinician who performed a procedure on 10 Medicare patients does not appear for that procedure. - Sums over many small rows undercount. - `NULL` means "withheld", not zero. Sorts put `NULL` last. The threshold differs a little by source: | Data | Withheld when | |---|---| | Medicare Part B and Part D by clinician | Fewer than 11 patients | | Hospital DRG volume | Fewer than 11 discharges for that hospital and DRG | | Medicaid drug utilization | Fewer than 11 prescriptions in a cell | | Medicare Advantage and Part D enrollment | 10 or fewer enrollees in a plan-county cell | | Medicare enrollment by county | Fewer than 11 people | ## Utilization is from 2024 Medicare and Part D data describe calendar year 2024. Registry, group and ownership data are from late 2026. A clinician who moved in 2025 shows their new address in `providers` and their old city in `medicare_provider`. ## Specialty names differ between tables `medicare_provider.provider_type` uses Medicare specialty names (`Cardiology`). `providers.specialty` uses the NUCC taxonomy (`Internal Medicine` with subspecialty `Cardiovascular Disease`). Read a specialty against the table it came from: a result's `sources` says which. ## Names are stored as published Registry and hospital names are UPPERCASE. Medicare names are mixed case. Substring filters in the search endpoints ignore case. ## Hospital financials come from cost reports Revenue, cost and income are self-reported by each hospital on its Medicare cost report for the fiscal year ending in `fiscal_year_end`. Hospitals that have not filed have `NULL` financials. ## Private-equity flags are CMS's `has_private_equity_owner` and `is_private_equity` come from the ownership disclosures hospitals file with CMS. They reflect what was disclosed, and CMS has said the reporting is incomplete. The same holds for [care sites](https://openpipe.health/docs/api/care-sites.md#owner-flags-are-self-reported). The private-equity, REIT, holding-company and management-company flags in `facility_owners` are the filer's own answers. Owner data exists only for nursing homes, home health agencies, hospices, FQHCs and rural health clinics. ## Open Payments is aggregated `open_payments` holds one row per clinician and company with the year's total, not individual payments. Research payments and ownership interests are not included. ## Hospital quality, EHR and health systems Details and examples are on [Hospitals and systems](https://openpipe.health/docs/api/hospital-intel.md#caveats). - **Quality** (`hospital_quality`, `hospital_measures`) is the Care Compare release of November 2026. Each measure has its own measurement period. `NULL` means CMS published no value, and about 40% of hospitals have no overall star rating. Scores are not on one scale, so do not average across measures. - **EHR** (`hospital_ehr`, `hospital_ehr_products`) is what each hospital attested to CMS for program year 2024 (2023 where 2024 is missing), published by ONC in January 2026. It covers about 4,200 hospitals, 85% of acute care hospitals. No row means unknown, not "no EHR", and a go-live since 2024 is not reflected. Only ONC-certified products are listed. - **Health systems** (`hospital_systems`) are derived from the home office each hospital names on its fiscal year 2024 Medicare cost report. No row means independent or unknown. `system_id` is stable only within one load of the data. - **DRG volume** (`hospital_drgs`) is calendar year 2024 for about 2,900 hospitals paid under the inpatient prospective payment system. Critical access hospitals and Maryland hospitals are not included. ## Clinician affiliations come from claims `clinician_facilities` is the CMS Doctors and Clinicians release of November 2026. CMS lists a facility when the clinician billed Medicare for patients there in recent months. It is not employment, admitting privileges or a medical-staff roster. CMS publishes at most five hospitals per clinician, and clinicians who see no Medicare patients are absent. ## Care sites Details are on [Care sites](https://openpipe.health/docs/api/care-sites.md#caveats). - Acute-care hospitals are in `hospitals`, not `facilities`. - HRSA health center sites and CMS-certified FQHCs are two registries of largely the same clinics. Count one type or the other. - `star_rating` means something different per facility type. Compare within one type. - Certification data is the third quarter of 2026, listings and ratings are September to November 2026, HRSA sites are 4 December 2026, and Medicare volumes are calendar year 2024. ## Drug markets, payers and ACOs Details are on [Drug markets](https://openpipe.health/docs/api/drug-markets.md#caveats) and [Payers and ACOs](https://openpipe.health/docs/api/payers-acos.md#caveats). - **Part D by state** (`rollup_drug_state`) is Medicare Part D only, 2024. The `total_*` columns are CMS's state totals. The others are summed from prescribers and undercount. - **Medicaid** (`medicaid_drug_state`, `rollup_medicaid_drug_state`) is calendar years 2024 and 2025. Amounts are before manufacturer rebates, which are large in Medicaid. Suppressed cells are left out of the sums. - **Drug spending** (`drug_spending`) is national only, 2020 to 2024, before rebates. Part D and Medicaid list each drug once per manufacturer and once as `Overall`. Adding all rows doubles it. - **Plans and enrollment** (`ma_plans`, `ma_enrollment_county`, `ma_enrollment_state`) are Medicare private plans for November 2026. Commercial and Medicaid members are not counted. 94% of plan-county cells are withheld, though they hold few enrollees, so every sum is slightly low. - **Medicare enrollment** (`medicare_enrollment_state`, `medicare_enrollment_county`) is yearly for 2013 to 2025 and August for 2026. - **ACOs** (`acos`, `aco_participants`) are the Medicare Shared Savings Program only. Organization details are performance year 2026 and results are performance year 2025. Participants are linked to group practices by exact name, for about 75% of rows. ## Trials and grants are linked by name ClinicalTrials.gov and NIH RePORTER publish no NPI. The `npi` on `trial_investigators` and `nih_grants` is a link made here, only when exactly one doctoral-level clinician in the NPI registry has that first and last name in that state. - `match_confidence` is `high` when the registry address is in the same city or ZIP, and `medium` when only the state matches. Verify a `medium` link. - 45% of trial investigator rows and 21% of NIH grant rows are linked. No `npi` means not linked. - Trials are interventional studies with a US site, as downloaded on 5 December 2026. Conditions are free text. - NIH grants cover fiscal years 2024 to 2026. A project with several principal investigators repeats its award on each row. More on [Experts](https://openpipe.health/docs/api/experts.md#caveats). --- # Rank surgeons by procedure URL: https://openpipe.health/docs/guides/surgeons-by-procedure/ Markdown: https://openpipe.health/docs/guides/surgeons-by-procedure.md > Build a call list of the highest-volume operators for a procedure in a territory. This guide builds a ranked list of clinicians who perform a given procedure in a given state, then pulls a full profile for the top name. The first three steps spend 3 credits. ## 1. Find the code ```sh curl "$OPH_API/api/procedures?q=knee%20arthroplasty" -H "Authorization: Bearer $OPH_KEY" ``` Take the `code` of the row you want. Total knee replacement is `27447`. ## 2. Rank clinicians ```sh curl "$OPH_API/api/providers?hcpcs=27447&state=AZ&min_services=50&limit=50" \ -H "Authorization: Bearer $OPH_KEY" ``` Rows come back sorted by `services`, highest first. `min_services` drops occasional operators. To narrow to one metro, add `city=Phoenix`. The match is on the whole city name, so `Phoenix` will not return `Scottsdale`; run one call per city. ## 3. Profile the top name ```sh curl "$OPH_API/api/providers/1234567893" -H "Authorization: Bearer $OPH_KEY" ``` The parts a rep usually wants: - `procedures`: the rest of their case mix, with `place_of_service` showing hospital (`F`) against office (`O`). - `groups`: the practice to route the account to. - `payments`: which manufacturers already pay them, and how much. ## 4. Export the whole list The search returns up to 200 rows a page. For every clinician that matches, send the same filters to [exports](https://openpipe.health/docs/api/exports.md) (10 credits): ```sh curl "$OPH_API/api/exports" \ -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \ -d '{"list": "providers", "params": {"hcpcs": "27447", "state": "AZ", "min_services": 50}}' ``` The response has a `url` to a CSV with the same columns as the search. ## A figure the search does not return For something the search has no column for, such as each surgeon's share of cases done in a hospital, ask in plain English (25 credits): ```sh curl "$OPH_API/api/ask" \ -H "Authorization: Bearer $OPH_KEY" \ -H "Content-Type: application/json" -H "Accept: application/json" \ -d '{"question": "For the top knee replacement surgeons in Arizona, what share of their cases are done in a facility?"}' ``` Each tile in the answer carries the `sql` the model wrote, so you can see how the share was computed. > **Caution:** These are Medicare fee-for-service volumes. They rank surgeons well, and undercount every one of them. See [Caveats](https://openpipe.health/docs/data/caveats.md). --- # Find PE-owned hospitals URL: https://openpipe.health/docs/guides/pe-owned-hospitals/ Markdown: https://openpipe.health/docs/guides/pe-owned-hospitals.md > List hospitals with a private-equity owner and see who the owners are. ## 1. Search ```sh curl "$OPH_API/api/facilities?private_equity=true&state=TX&min_beds=100&sort=revenue" \ -H "Authorization: Bearer $OPH_KEY" ``` Each row has `top_owner` and the cost-report financials. Drop `state` to search nationally. ## 2. See the owners of one hospital ```sh curl "$OPH_API/api/facilities/450000" -H "Authorization: Bearer $OPH_KEY" ``` `owners` lists up to 50 parties with `pct_ownership`, `role`, and the `is_private_equity`, `is_reit` and `is_holding_company` flags. ## 3. Group hospitals by owner The search endpoint ranks hospitals, not owners. To see which firms hold the most beds, ask (25 credits): ```sh curl "$OPH_API/api/ask" \ -H "Authorization: Bearer $OPH_KEY" \ -H "Content-Type: application/json" -H "Accept: application/json" \ -d '{"question": "Which private-equity owners hold the most hospitals and beds?"}' ``` The answer is one JSON document. Each tile has `columns` and `rows`, and `sql` shows how the model grouped them. Check it for one thing: a hospital with two private-equity owners is counted under both, so a `beds` column does not sum to a national total. Keep the `id` from the response: it opens the answer again for free. ## 4. Export the full list Send the same filters as the search, without paging: ```sh curl "$OPH_API/api/exports" \ -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \ -d '{"list": "facilities", "params": {"private_equity": true, "sort": "beds"}}' ``` Download the CSV from `url` within the hour, or call `GET /api/exports` later for a fresh link. To export a tile of the answer from step 3, send `{"dashboard": "", "tile": 0}`. See [Exports](https://openpipe.health/docs/api/exports.md). > **Note:** The private-equity flags come from ownership disclosures filed with CMS, which are known to be incomplete. Treat the list as a starting point. See [Caveats](https://openpipe.health/docs/data/caveats.md#private-equity-flags-are-cmss). --- # Stream Ask in JavaScript URL: https://openpipe.health/docs/guides/stream-ask/ Markdown: https://openpipe.health/docs/guides/stream-ask.md > Read the Ask event stream with fetch in a browser, Node, Bun or Deno. [`POST /api/ask`](https://openpipe.health/docs/api/ask.md) responds with server-sent events by default. If you do not need tiles as they arrive, skip this guide and use [JSON mode](https://openpipe.health/docs/api/ask.md#json-mode): one `fetch`, one `await res.json()`. For the stream: The browser's `EventSource` cannot send a `POST` or an `Authorization` header, so read the stream with `fetch`. ## A minimal reader ```js async function* ask(question, { base, token }) { const res = await fetch(`${base}/api/ask`, { method: 'POST', headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json', accept: 'text/event-stream' }, body: JSON.stringify({ question }), }); if (!res.ok) throw new Error((await res.json()).error); const reader = res.body.pipeThrough(new TextDecoderStream()).getReader(); let buffer = ''; for (;;) { const { value, done } = await reader.read(); if (done) return; buffer += value; let end; while ((end = buffer.indexOf('\n\n')) !== -1) { const block = buffer.slice(0, end); buffer = buffer.slice(end + 2); let event = 'message'; let data = ''; for (const line of block.split('\n')) { if (line.startsWith('event:')) event = line.slice(6).trim(); else if (line.startsWith('data:')) data += line.slice(5).trim(); } if (data) yield { event, data: JSON.parse(data) }; } } } ``` ## Use it ```js const tiles = []; for await (const { event, data } of ask('Which states do the most cataract surgeries?', { base: process.env.OPH_API, token: process.env.OPH_KEY, })) { if (event === 'plan') { console.log(data.title, '-', data.summary); tiles.length = data.tiles.length; // reserve a slot per planned tile } if (event === 'tile') tiles[data.index] = data; if (event === 'tile_error') console.warn(`Tile ${data.index} failed: ${data.error}`); if (event === 'error') throw new Error(data.error); if (event === 'done') console.log(`${data.tiles - data.failed} of ${data.tiles} tiles in ${data.ms} ms, stored as dashboard ${data.id}`); } ``` ## Rendering advice - **Show a waiting state until `usage`.** Nothing is sent while the model plans, which takes a few seconds. `usage` arrives when the plan exists and the workspace has been charged, with `plan` right behind it. - **Draw placeholders from `plan`.** It has every tile's `type` and `title`, so you can lay out the dashboard before any data exists. - **Place tiles by `index`.** They arrive in the order they finish, which is rarely the planned order. - **Show `plan.summary`.** It carries the caveat for the answer, such as Medicare-only volumes. - **Show the receipt.** Each tile has `tile.sql`, `sources` and `engine`. A "how this was computed" link costs you nothing and is why people trust the number. It is for reading: no endpoint takes SQL back. - **Keep `done.id`.** It is the stored dashboard. Open it again for free with [`GET /api/dashboards/:id`](https://openpipe.health/docs/api/saved.md#open-a-dashboard), retry failed tiles with a free [refresh](https://openpipe.health/docs/api/saved.md#refresh-a-dashboard), and pass it to [exports](https://openpipe.health/docs/api/exports.md#export-a-tile-of-an-answer) for every row of a tile. - **Handle the missing `done`.** If the connection drops or an `error` event arrives, `done` never comes. Stop your loading state when the stream closes. An `error` event with `charged: false` means no plan could be made and nothing was charged. - **Do not ask again after a dropped connection.** The server finishes, charges and stores the answer whether or not you are still listening. Look for it in [`GET /api/dashboards`](https://openpipe.health/docs/api/saved.md#list-dashboards) first. ## In a browser The same function works unchanged. Use the signed-in user's session token as `token`, not an API key: anything you ship to a browser is visible to its user.