Data API Overview

Retrieving user data from Human API

πŸ“˜

For a full list of queries, see the reference.

What is the Data API?

The Data API is a REST API that provides comprehensive health data served via JSON for request and response payloads.

The Data API is composed of two distinct types of health data:

Wellness - personal health data from wearable devices and apps
Medical - patient medial records from health providers

🚧

This section assumes that you have registered users and have retrieved their access tokens using the Human Connect popup. If you haven't done that yet, please go through the Authenticating Users section of the documentation.

Querying a user's health data

To query a user's health data all you need to do is use their accessToken in a GET request to one of the Human API endpoints. A standard query looks like this:

curl -H "Authorization: Bearer demo" "https://api.humanapi.co/v1/human"

πŸ‘

Demo data

You can always give an endpoint a try with the access_token demo. See Demo Data for more info.

Before you start to write your data retrieval infrastructure you will want to review a few things:

  1. The Patterns and Conventions section, which covers all important conventions Human API follows.

  2. The SDKs and Libraries section, which has examples and libraries in various languages you can use.

  3. The Demo Data section, which covers how to work with demo data while you prototype and integrate.

  4. The API Reference page, which provides a comprehensive list of all the endpoints the Data API provides.

Setting Up Your Data Retrieval Infrastructure

Now that you know how to query an individual user's health data, you need to set up your data retrieval infrastructure. An example of a basic data retrieval using Node.js would be:

var headers = {
  'Authorization': 'Bearer ' + accessToken,
  'Accept': 'application/json'
};
var url = 'https://api.humanapi.co/v1/human'

request({
  method: 'GET',
  uri : url,
  headers : headers
  }, function (error, res, body) {
    var parsedResponse;
    if (error) {
      callback(new Error('Unable to connect to the Human API endpoint.'));
    } else {
      if(res.statusCode == 401) {
        logger.debug("Unauthorized request, validate access token");
        callback(null, { status: 'unauthorized' });
      } else {
        try {
          parsedResponse = JSON.parse(body);
        } catch (error) {
          return callback(new Error('Error parsing JSON response from Human API.'));
        }
        // At this point you can use the JSON object to access the results
        console.log("Latest blood glucose measurement");
        console.log(parsedResponse.bloodGlucose.value);
        return callback(null, parsedResponse);
      }
    }
});

That's all there is to it! Now that you have implemented Human Connect and started to retrieve data via the Data API, you can continue building out your application.

Since you have the basics down, you may be interested in learning more about:

Best Practices

Displaying Data

Check out the Chart API for a quick and easy way to display data in your application.