Use SmartBand 2 sensor data for Android and iOS apps
As an app developer, you can retrieve sensor data from SmartBand 2 using standard sets of APIs for Android and iOS platforms. Depending on the platform you are developing for, you can use Sony’s Lifelog API, Google Fit APIs or Apple’s HealthKit. You can then analyze and process the sensor data to provide useful insights and visualizations that can help your users live a healthier lifestyle.
SmartBand 2 is compatible with any smartphone running at least Android 4.4 or iOS 8.2, and it’s equipped with an accelerometer and a heart rate monitor. It tracks steps and activities like walking, running, and sleeping, while also monitoring heart rate (HR) and heart rate variability (HRV). This way, the SmartBand 2 will provide data allowing for biometric tracking and insights into overall fitness, excitement, stress and recovery levels throughout the day and night.
In the following sections you will find information about the different sets of APIs that can be used to collect sensor data from SmartBand:
Use Lifelog API to develop innovative fitness apps or services
The Lifelog app lets users track their lifestyle, fitness, and health through sensors in the smartphone and connected wearables like SmartBand 2. The Lifelog app uploads sensor data to the Lifelog platform data store, a cloud based repository. Your app can access this data using the Lifelog API, if your users agree to share it with your app.
The Lifelog API is a REST-based web-service API, from which you can get information through three different endpoints:
- User profile, basic personal information such as name, age, height, and weight.
- Activities, data such as “walk” and “sleep”.
- Locations, coordinates that tracks where the user has been and how the user has moved.
SmartBand 2 provides the following Activities data types to the Lifelog platform data store:
- physical (with the subtype walk)
The Lifelog web API uses OAuth2 authentication and all requests are made using the HTTPS protocol. The following example of an API call illustrates how to retrieve data for the activity data type “physical” and subtype “walk”:
The Lifelog API can be used for apps on any platform. To learn more and start using the Lifelog API, go to the Lifelog get started page.
Use Google Fit APIs to store and access fitness data from any wearable and sensor
Google Fit is an open ecosystem that allows developers to upload and store sensor data to a central cloud based repository. If your users grant you permission, you can access their data using the Google Fit APIs.
The Google Fit APIs consist of two sets of APIs:
- Google Fit Android APIs included in Google Play services, for Android apps.
- Google Fit REST API, for apps on any platform.
Both sets of the Google Fit APIs work with three types of data: Public data types, Custom data types, and Shareable data types. SmartBand 2 provides the following Public data types to the Google Fitness Store:
- google.step_count.delta (steps)
- google.heart_rate.bpm (heart rate in bpm)
- google.activity.segment (sleeping, walking, running)
Using the Google Fit REST API, you first make an API call to get a list of available data sources (you might have several):
The data sources contain data sets which hold the activity data you are interested in, for instance where the data type is com.google.step_count.delta (steps) and the source is com.sonymobile.hostapp.everest (SmartBand 2). The API call for getting data sets is:
|dataSourceId||string||The format of the dataSourceId created by an Android application is: type:dataType.name:application.packageName:device.manufacturer:device.model:device.uid:dataStreamName|
|datasetId||string||The datasetId is formatted like “startTime-endTime”, where startTime and endTime are 64 bit integers.|
Based on this, the call to retrieve step count data from For SmartBand 2 would look like this:
To learn more about Google Fit, and get started using the Google Fit APIs, visit the Gooogle Fit platform overview.
Use HealthKit to manage, use and share fitness data on devices running iOS
The HealthKit framework is designed to let apps use and share fitness data from a wide range of sources and sensors. All collected data are stored locally in the HealthKit store on the user’s device, and can be accessed using HealthKit, the accompanying API included in the iOS SDK. The users can edit the permissions to read, write, and share, for each app and each data type.
HealthKit data is divided into two main groups: characteristics and samples. Characteristics data includes for example the user’s birth date and blood type – data that typically does not change. The Samples data can be partitioned into four types: Category samples, Quantity samples, Correlations, and Workouts.
SmartBand 2 provides Quantity and Category samples to the HealthKit store, which can be identified by:
- HKQuantityTypeIdentifierStepCount (steps)
- HKQuantityTypeIdentifierHeartRate (heart rate)
- HKCategoryTypeIdentifierSleepAnalysis (sleeping)
To query the HealthKit store for data, you call the initializer initWithSampleType:predicate:limit:sortDescriptors:resultsHandler:, and then run the query by calling the executeQuery: method.
Learn more about HealthKit by visiting The HealthKit Framework page.