This API is used to fetch data on device activation. Once a pack of devices is given to a research participant, it's important that research participant activate the devices by pairing with Spire Health mobile application. Based upon data returned by this API, research owner can understand if device is activated or not. It also provides information on who activated the device and when. If a research paricipant doesn't activate the device, research owner may need to follow up with that user.
Headers
This API just requires API Access Token available at the Research portal. Set this up as HTTP header before calling the API.
Response format
This API returns User data in a JSON format -
[
{
"pack_id": 0,
"device_id": "string",
"is_registered": "string",
"registered_email": "string",
"time_zone": "string",
"paired_at": "2019-02-21T04:16:16.965Z",
"last_connected": "2019-02-21T04:16:16.965Z",
"firmware": "2019-02-21T04:16:16.965Z",
"raw_capture_setting": "2019-02-21T04:16:16.965Z"
}
]
Response Code | Description |
---|---|
200 | Successful Operation |
401 | Access token is missing or invalid |
403 | Not a valid key value pair in Authorization header |
404 | The requested API could not be found. Please review your URL |
429 | Too many requests hit the API too quickly |
Output Data
Field Name | Type | Description |
---|---|---|
pack_id | Integer | Pack id of the devices |
device_id | String | Serial number of the device |
is_registered | String | Indicates whether device is registered or not |
registered_email | String | Indicates whether device is registered or not |
time_zone | String | Timezone in which data was captured. For example - 'America/Chicago','Australia/Brisbane','Europe/Stockholm'. More detailed list available at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones |
paired_at | date-time | Date on which device was paired |
last_connected | date-time | Date on which device connected last time |
firmware | String | Note that Firmware version of the device |
raw_capture_setting | String | Indicates whether raw data capture is enabled or not |
Program samples to test out API
Use the program samples below to test out APIs with your own research data -
cURL
curl -X GET \
https://research-api.spire.io/v1/device_compliance \
-H 'Authorization: Bearer 9f33707110d21885da378b7482e530492de0a1b2b0d279172112357b975f4fc1'
Python
Python program sample below calls Device compliance API to get device compliance data and saves the data into a Pandas data frame.
import requests
from http import HTTPStatus
import pandas as pd
headers = {'Authorization': str('Bearer 9f33707110d21885da378b7482e530492de0a1b2b0d279172112357b975f4fc1'), 'Content-type': 'application/json'}
device_compliance = requests.get(f'https://research-api.spire.io/v1/device_compliance', headers=headers)
if device_compliance.status_code == HTTPStatus.OK:
device_compliance_pandas = pd.DataFrame(device_compliance.json(),columns=device_compliance.json()[0].keys())
print (device_compliance_pandas.head())
else:
print ("Returned status code is: " + str(device_compliance.status_code))
print (device_compliance.text)