SportTracks REST API: Health Metrics

Get User Health Metrics

To get the authenticated user's health metrics send an HTTP GET to this URL:

https://api.sporttracks.mobi/api/v2/metrics

If successful, the method returns a JSON encoded object that contains all the user health metrics. The object is indexed by metric type where each value is an array of [timestamp, value] tuples

Update health metrics

You can update health metrics by sending an HTTP POST request to this URL:

http://api.sporttracks.mobi/api/v2/metrics

The update method performs an upsert. If the data is not present in the user's account it will be added. If the data is present it will be overwritten by the new value. To delete a value at a particular time pass in a null for the metric value.

If multiple duplicate metrics are present for the same time, later data will overwrite prior data.

The entire update is performed in a single atomic transaction; either all data will be updated or none will.

The POST data must contain JSON encoded health metric data. You may specify data in one of several formats depending on the scenario you need to support.

Scenario #1: Updating multiple metrics for one time point

If you want to update one or more metrics for a single point in time, pass in an object with the data specified below:

Key Data type Description
timestamp string (ISO 8601 DateTime) The date/time of the metric data (required)
Metric ID [1] real number The value for the metric
...
Metric ID [N] real number The value for the metric

Where Metric ID is an identifier from the list of valid metric IDs

Examples

Add a weight of 68 kilograms and body fat measurement of 7.8% on January 1, 2016 at noon UTC:

{
  "timestamp": "2016-01-01T12:00:00Z",
  "weight": 68,
  "bodyFat": 0.078
}

Scenario #2: Updating multiple metrics for multiple times

If you want to update one or more metrics for multiple points in time, for example to do a bulk upload, or if the user has recorded multiple entries since the last sync, pass in an object with the data specified below:

Key Data type Description
Metric ID [1] Samples object List of time, value pairs
...
Metric ID [N] Samples object List of time, value pairs

Where Metric ID is an identifier from the list of valid metric IDs

Metric Samples

The samples object is an object whose keys are the date/time of the metric data, and whose value is the metric value:

Key Value
Timestamp [1] (ISO 8601 DateTime) The value for the metric at time [1]
...
Timestamp [N] (ISO 8601 DateTime) The value for the metric at time [N]

Examples

Add HRV measurements for 3 days

{
  "hrv": [
    "2016-01-01T12:00:00Z": 78.2,
    "2016-01-02T12:00:00Z": 75.2,
    "2016-01-03T12:00:00Z": 66.9,
  ],
  "rmssd": [
    "2016-01-01T12:00:00Z": 60,
    "2016-01-02T12:00:00Z": 65,
    "2016-01-03T12:00:00Z": 63,
  ],
  "pnn50": [
    "2016-01-01T12:00:00Z": 0.123,
    "2016-01-02T12:00:00Z": 0.098,
    "2016-01-03T12:00:00Z": 0.162,
  ],
}

Valid metric IDs

The following table lists the valid metric ids.

ID Units Description
weight Kilograms The athlete's body weight
bodyFat Percent (0 to 1) The athlete's body fat percentage
restingHeartrate Beats per minute The athlete's resting heart rate
maximumHeartrate Beats per minute The athlete's maximum heart rate
rmssd Miliseconds The root mean square of successive distances for heart rate beats
pnn50 Percent (0 to 1) The percentage of successive beats that vary by greater than 50 milliseconds
hrv real number The HRV score, as defined by the partner app. Typically a value from 0 to 100(ish)