Use SmartBand 2 sensor data for innovative Android and iOS applications

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 analyse 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, and how to get started.

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)
  • sleep

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”:

https://platform.lifelog.sonymobile.com/v1/users/me/activities?start_time=2015-09-03T00:00:00.000Z&end_time=2015-09-04T00:00:00.000Z&type=physical: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.

Overview of the Lifelog API architecture. The Lifelog app populates the cloud based repository with logged data, and a third-party app or service uses the Lifelog API to access the logged data.

Overview of the Lifelog API architecture. The Lifelog app populates the cloud based repository with logged data, and a third-party app or service uses the Lifelog API to access the logged data.

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)

For the Google Fit Android APIs, steps, walking, running, sleeping, and heart-rate history are available in the History API, while real time heart rate is available in the Sensors API.

To retrieve, for example, the daily total steps you can pass the TYPE_STEP_COUNT_DELTA data type to the HistoryApi.readDailyTotal() method.

Using the Google Fit REST API, you first make an API call to get a list of available data sources (you might have several):

https://www.googleapis.com/fitness/v1/users/me/dataSources

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:

https://www.googleapis.com/fitness/v1/users/me/dataSources/dataSourceId/datasets/datasetId

Where:

Property nameValueDescription
dataSourceIdstringThe format of the dataSourceId created by an Android application is: type:dataType.name:application.packageName:device.manufacturer:device.model:
device.uid:dataStreamName
datasetIdstringThe 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:

https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.step_count.delta:com.sonymobile.hostapp.everest:Sony%20Mobile%20Communications%20Inc.:SWR12:6ec1bef:/datasets/1438387200000000-1441714884591000000

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.

***

Are you eager to start developing apps that utilize sensor data from SmartBand 2? Drop us a comment and let us know which set of APIs that best suits your objectives and why.

More information

Comments 6

Sort by: Newest | Oldest | Most popular

  1. By Rei Kagetsuki

    #1

    I’m trying to implement an application that requires step delta or cadence from real time sensors through the Google Fit API. Is there any way to get real time step count from the SmartBand 2? I’m able to get BPM just fine, but really need step counts.

  2. By Bharat Bollampally

    #2

    Hi , How can i get the Raw accelerometer data using rest APIS from google fit

    • By Vidhi S

      #3

      Hi Bharat, were you able to obtain the Raw accelerometer data?

  3. By Jacky Kan

    #4

    How often does Lifelog uploads the data to the Lifelog Platform Data store? Cause I would like to know in real time what activity is the user doing etc!

  4. By Nico Teuschler

    #5

    Why is herat rate not avialable to read, is your HRV patented?

  5. By Sonny Johanssin

    #6

    Lovely!

1-6 of 6 comments.