Data Integration
Scores & Insights
Sahha analyzes device activity daily (per 24 hours) (data such as sleep, steps and more) to create the Sahha Mental Health Scores, Wellbeing Scores and other health insights for each end user. You can display or action within your application or access through the Sahha REST API .
Each call to the analyze
method documented here returns each Sahha Health Scores
Consider exploring our design principles for best practices around displaying Sahha data.
How to get scores from the last 24 hours
Get the most recent scores for the previous 24 hours in the user's local timezone. The default time period for an analysis is the previous 24 hours.
// Analyze Previous 24 Hours// Leave date range empty
Sahha.analyze(includeSourceData: true) { error, json in if let error = error { print(error) } else if let json = json { print(json) }}
How to get scores by date range
You can provide an optional data range if you would like to receive multiple scores over a specific time period. The response will include an array of scores for each 24 hour segment in that time period.
// Analyze Previous 7 Days// Add a date range
let today = Date()let sevenDaysAgo = Calendar.current.date(byAdding: .day, value: -7, to: today) ?? Date()Sahha.analyze(dates: (startDate: sevenDaysAgo, endDate: today)) { error, json in if let error = error { print(error) } else if let json = json { print(json) }}
200 Response
The response will be in JSON format. An example response includes these fields:
{ "inferences": [ { "id": "26051AB2-867F-4F8D-B134-0031C20D3FDC", "type": "stress", "state": "low", "score": 0.34, "factors": [ { "name": "active_hours", "value": 0.017 }, { "name": "daily_steps", "value": 0.045 }, { "name": "activity_goals", "value": -0.002 }, { "name": "sedentary_periods", "value": -0.057 }, { "name": "activity_deviation", "value": 0.031 } ], "inputData": ["age", "sleep", "steps", "heart_rate"] }, { "id": "601ADC2F-4830-45E7-B538-F7821EC009EA", "type": "depression", "state": "none ", "score": 0.14, "factors": [ { "name": "active_hours", "value": 0.017 }, { "name": "daily_steps", "value": 0.045 }, { "name": "activity_goals", "value": -0.002 }, { "name": "sedentary_periods", "value": -0.007 }, { "name": "activity_deviation", "value": 0.001 } ], "inputData": ["age", "sleep", "steps"] }, { "id": "601ADC2F-4830-45E7-B538-F7821EC009EA", "type": "anxiety", "state": "medium", "score": 0.62, "factors": [ { "name": "active_hours", "value": 0.034 }, { "name": "daily_steps", "value": 0.015 }, { "name": "activity_goals", "value": -0.004 }, { "name": "sedentary_periods", "value": -0.007 }, { "name": "activity_deviation", "value": 0.02 } ], "inputData": ["age", "sleep", "steps", "screen"] }, { "id": "acde070d-8c4c-4f0d-9d8a-162843c10333", "type": "sleep", "state": "high", "score": 0.75, "factors": [ { "name": "active_hours", "value": 0.015 }, { "name": "daily_steps", "value": 0.085 }, { "name": "activity_goals", "value": -0.011 }, { "name": "sedentary_periods", "value": -0.007 }, { "name": "activity_deviation", "value": 0.021 } ], "inputData": ["age", "gender", "sleep", "activity"] } ], "createdAt": "2023-07-31T12:00:35+12:00"}
204 Response
An empty but successful response.
MINIMUM DATA REQUIREMENTS
The analysis engine requires a minimum amount of device sensor data to be uploaded and processed before an analysis can be determined.
If you call analyze
for a new user profile or a user that has been inactive lately, it's possible for the response to be 204 No Content
. This is not an error.
You will need to wait and try again every 24 hours until an analysis is available.
// An analysis is not ready yet// Try again in 24 hours// Empty JSON{}
Data Sources
Data sources are required to generate an analysis.
The analysis is created from various data sources
To receive an analysis, a minimum of one data source must be configured by the SDK.
The more data sources that you configure via the SDK, the better the analysis that will be generated.
Some data sources are not yet available on all platforms. Sahha continues to improve its analysis engine by bringing feature parity between platforms as well as adding new data sources.
Data Source | Description | Android | iOS |
---|---|---|---|
sleep | User sleep patterns | ✓ | ✓ |
steps | User walking patterns | ✓ | ✓ |
screen | User device screen time | ✓ | X |
heart | User heart patterns | X | ✓ |
blood | User blood patterns | X | ✓ |
age | User age | ✓ | ✓ |
gender | User gender | ✓ | ✓ |
Device Sensors
Use Sensors as a Data Source
Learn how to configure device sensors to collect device.
Demographics
Use Demographics as a Data Source
Learn how to configure demographics as a data source.