Consumer Health


Browse our guides and interact with our API reference for more information about MEDSAPI NAH Reference Center. Try the API and learn about core concepts.





Clone a Code Sample

After you explore our API reference and code samples, you can clone one of our code samples to get you started. Our documentation contains a code sample for each resource in five different languages. Whatever language that you are using, you can use our Python code sample below as a model and tweak the parameters to get your desired request.

In the following guide, we create a code sample for the MedsAPI Consumer Health service. The process of creating the code sample for the resource is described below. For this particular example, we used windows and installed Python 3.6.0 prior to creating the sample.

Note: If you need to look up the URL or parameters for a resource, refer back to the API reference or code sample documentation.

To Create a Code Sample:

  1. Note the request URL for your desired resource.

Request URL

  1. Determine the parameters that you would like to use for your request.  For example, search might need these parameters to get additional pages of responses. (Articles does not take any query parameters).


page = '2'
pageSize = '10'
Authorization = 'Bearer ' + {Access TOKEN obtained from the OAuth2.0 protocol}

  1. Create a new file for your sample code.
  2. Add the following code to  The code below forms the request URL, forms the request headers, and sends the request and receives the response back.

# get an article

# Form the URL
url = "/medsapi-consumer-health/v1/content/articles/t12345"

# Create Connection Instance
conn = http.client.HTTPSConnection("")

# Create the Request Headers
headers = {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": "Bearer TOKEN"

queryParams = {}  // No query parameters needed for auth

# Send Request
conn.request("GET", url, queryParams, headers)

  1. Change "TOKEN" in the script to the token aquired via the Authentication process (e.g. "aBc...X1z").

Note: If you would like to use a different resource, you will need to form the URL in the code to match the resource.  Also, you will need to take into account the parameters for the new resource.  Refer to our code samples in our service reference for additional guidance.

  1. Save your file.
  2. Run your script by entering python in a Command Prompt.  If successful, a JSON response with the requested Consumer Health content details will be returned and displayed on the screen.

You have completed your first code sample consuming the Consumer Health API.  You are on your way.  Have fun!