Medicare

Medicare

Health

Access to the data from the CMS - medicare.gov; The Socrata Open Data API allows you to programmatically access a wealth of open data resources from governments, non-profits, and NGOs around the world.

Visit API

📚 Documentation & Examples

Everything you need to integrate with Medicare

🚀 Quick Start Examples

Medicare Javascript Examplejavascript
// Medicare API Example
const response = await fetch('https://data.medicare.gov/developers', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Exploring the Medicare API with JavaScript

The Medicare API provides access to a wealth of healthcare data from the Centers for Medicare & Medicaid Services (CMS). In this blog post, we'll explore how to use the API with JavaScript, using examples to showcase different features and endpoints.

Getting Started

Before we can start using the Medicare API, we need to obtain an API key. To do this, we'll need to create an account on the Medicare Developer Portal (https://data.medicare.gov/developers). Once we have an API key, we can use that to authenticate our requests.

Example 1: Retrieving Facility Data

In this first example, we'll retrieve data for all long-term care hospitals (LTCHs) in the United States. We'll use the /Facility endpoint to get this data, and we'll filter the results to include only LTCHs.

const API_KEY = "YOUR_API_KEY_HERE";

fetch(
  "https://data.medicare.gov/resource/xubh-q36u.json?provider_type=Long%20Term%20Care%20Hospital",
  {
    headers: {
      "X-API-KEY": API_KEY,
    },
  }
)
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error(error));

In this example, we're making a fetch request to the /Facility endpoint, specifying a filter for provider_type to only include LTCHs. We pass our API key in the request headers to authenticate the request. Once we receive the response, we log the data to the console.

Example 2: Retrieving Procedure Data

In this second example, we'll retrieve data for a specific procedure from the Inpatient Prospective Payment System (IPPS) dataset. We'll use the /Procedure endpoint to get this data.

const API_KEY = "YOUR_API_KEY_HERE";

fetch(
  "https://data.medicare.gov/resource/4pq5-n9py.json?drg_definition=470%20MAJOR%20JOINT%20REPLACEMENT%20OR%20REATTACHMENT%20OF%20LOWER%20EXTREMITY%20W/O%20MAJOR%20CC/MCC",
  {
    headers: {
      "X-API-KEY": API_KEY,
    },
  }
)
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error(error));

In this example, we're making a fetch request to the /Procedure endpoint, specifying a filter for drg_definition to only include data for the 470 MAJOR JOINT REPLACEMENT OR REATTACHMENT OF LOWER EXTREMITY W/O MAJOR CC/MCC procedure. Once we receive the response, we log the data to the console.

Example 3: Retrieving Provider Data

In this third example, we'll retrieve data for all providers in a specific state. We'll use the /Provider endpoint to get this data, and we'll filter the results to include only providers in the state of California.

const API_KEY = "YOUR_API_KEY_HERE";

fetch(
  "https://data.medicare.gov/resource/ukfj-tt6v.json?state=CA",
  {
    headers: {
      "X-API-KEY": API_KEY,
    },
  }
)
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error(error));

In this example, we're making a fetch request to the /Provider endpoint, specifying a filter for state to only include data for California. Once we receive the response, we log the data to the console.

Conclusion

The Medicare API provides a rich source of healthcare data for developers to explore and utilize in their applications. With JavaScript, we can make requests to different endpoints and retrieve data that is specific to our needs. These examples only scratch the surface of what's possible with the Medicare API, and there are many more endpoints and filters to explore.

📊 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jun 5Jun 7Jun 9Jun 11Jun 13Jun 15Jun 17Jun 19Jun 21Jun 23Jun 25Jun 27Jun 29Jul 1Jul 404008001440Minutes
Online
Offline

Related APIs in Health