Skip to main content

Implementation

Implementation

There are two ways to implement the ROOKScore:

  • Implementation via webhook
    • Real-time data-sync
    • Requires providing a webhook
    • ROOK automatically sends you the Health Score of your users whenever they are generated
  • Implementation via API
    • On-demand data-sync
    • Requires making a request to our API
    • Allows you to obtain historical information about your users' Health Score

Implementation Via Webhook

To use this method, You must register to the Data Webhook in your portal. ROOK will automatically send the Health Score of your users to this webhook as it is generated.

This implementation follows this flow:

  1. Your user generates data using their wearable.
  2. ROOK receives the data from the wearable.
  3. ROOK structures and normalizes the data.
  4. ROOK generates a Health Score with the structured information.
  5. ROOK sends the Health Score to your webhook.
  6. You receive the Health Score.

You will receive a JSON for each user every time new data is generated.

Example Structure

{
"data_structure": "health_score",
"version": 1,
"score": {
"health_score_data": {
"user_id": "<USER_ID>",
"datetime": "2020-01-01T00:00:00.000000Z",
"global_score": 92,
"activity_readiness_score": 88,
"activity_sleep_score": 95,
"readiness_sleep_score": 93,
"activity": {
"datetime": "2020-01-01T00:00:00.000000Z",
"activity_score": 90,
"generic_score": true,
"missing_data": [
"sex",
"age"
]
},
"readiness": {
"datetime": "2020-01-01T00:00:00.000000Z",
"readiness_score": 85,
"generic_score": true,
"missing_data": [
"sex",
"age"
]
},
"sleep": {
"datetime": "2020-01-01T00:00:00.000000Z",
"sleep_score": 100,
"generic_score": true,
"missing_data": [
"age"
]
}
}
}
}

Implementation Via API

This method requires making a query to the ROOK API, specifying the date range for which you want to retrieve the Health Score of a user. You will need to use the <CLIENT_UUID> and <SECRET_KEY> provided to you when you subscribed to the service.

This implementation follows this flow:

  1. Your user generates data using their wearable device.
  2. ROOK receives the data from the wearable.
  3. ROOK structures and normalizes the data.
  4. ROOK generates a Health Score with the structured information.
  5. ROOK stores the Health Score.
  6. You query the historical Health Score via an API request to ROOK.

Example Of Request To ROOK's API.

GET <ROOK_API_URL>/v1/processed_data/health_score

Authentication

  • Type: Basic.
  • Username: <CLIENT_UUID>.
  • Password: <SECRET_KEY>.

Request Parameters

  • user_id (required)
    • The ID with which you have registered your user.
  • start_date (required)
    • Initial date of the time period you want to query.
    • It must follow the format YYYY-MM-DD.
  • end_date (required)
    • End date of the time period you want to query.
    • It must follow the format YYYY-MM-DD.

Response Body

{
"data_structure": "health_score",
"version": 1,
"score": {
"health_score_data": [
{
"user_id": "<USER_ID>",
"datetime": "2020-01-01T00:00:00.000000Z",
"global_score": 92,
"activity_readiness_score": 88,
"activity_sleep_score": 95,
"readiness_sleep_score": 93,
"activity": {
"datetime": "2020-01-01T00:00:00.000000Z",
"activity_score": 90,
"generic_score": true,
"missing_data": [
"sex",
"age"
]
},
"readiness": {
"datetime": "2020-01-01T00:00:00.000000Z",
"readiness_score": 85,
"generic_score": true,
"missing_data": [
"sex",
"age"
]
},
"sleep": {
"datetime": "2020-01-01T00:00:00.000000Z",
"sleep_score": 100,
"generic_score": true,
"missing_data": [
"age"
]
}
},
{
"user_id": "<USER_ID>",
"datetime": "2020-01-02T00:00:00.000000Z",
"global_score": 92,
"activity_readiness_score": 88,
"activity_sleep_score": 95,
"readiness_sleep_score": 93,
"activity": {
"datetime": "2020-01-02T00:00:00.000000Z",
"activity_score": 90,
"generic_score": true,
"missing_data": [
"sex",
"age"
]
},
"readiness": {
"datetime": "2020-01-02T00:00:00.000000Z",
"readiness_score": 85,
"generic_score": true,
"missing_data": [
"sex",
"age"
]
},
"sleep": {
"datetime": "2020-01-02T00:00:00.000000Z",
"sleep_score": 100,
"generic_score": true,
"missing_data": [
"age"
]
}
}
]
}
}

Response Codes

  • 200: OK
  • 422: The user_id does not exist

About The Generic Score

Sometimes, data providers may not have the ability to provide basic user data such as gender, age, weight, and height. The Health Score requires this data to generate a fully customized score for your user. In such cases, the Health Score includes two keys indicating whether the score calculation was personalized:

  • generic_score
    • Data type: bool.
    • Possible values: [true, false].
    • Description: If true, indicates that the user does not have the basic data required to obtain a personalized score.
  • missing_data
    • Data type: array.
    • Possible values: ["sex", "age", "weight", "height"]
    • Description: Indicate which basic user data is missing to generate a personalized score.

About Null Values

Not all wearables can obtain all the data required to calculate the Health Score. In such cases, the score for the affected section and all related keys will contain a null value. The composite scores will not take these null values into account.

Example Of Score With Null Values

{
"data_structure": "health_score",
"version": 1,
"score": {
"health_score_data": {
"user_id": "<USER_ID>",
"datetime": "2020-01-01T00:00:00.000000Z",
"global_score": 65,
"activity_readiness_score": 50,
"activity_sleep_score": 80,
"readiness_sleep_score": 65,
"activity": {
"datetime": null,
"activity_score": null,
"generic_score": null,
"missing_data": [

]
},
"readiness": {
"datetime": "2020-01-01T00:00:00.000000Z",
"readiness_score": 50,
"generic_score": true,
"missing_data": [
"sex",
"age"
]
},
"sleep": {
"datetime": "2020-01-01T00:00:00.000000Z",
"sleep_score": 80,
"generic_score": true,
"missing_data": [
"age"
]
}
}
}
}