Google Fit REST API - Overview

Overview

 
In this fast-paced world and hectic schedule, fitness is of the utmost importance. With technology advances, we can track our fitness activities. There are a number of fitness bands and apps available in the market and app stores, using which we can track all our daily activities. As a developer, we want to go one step ahead and start programming with our fitness data so that we can use it in any application and mold it further.
 
In this article, we are going to explore Google Fitness API and its support to start programming it.
 

Why Google Fit?

 
As I mentioned, there are a number of fitness bands and apps available. These are some of the reasons for me to go with Google Fit. 
  1. It’s free (mobile app)
  2. It does not need any additional band to be tied up on the wrist
More information about Google Fit can be found here.
 

Monitor Your Google Fit Data

 
Once the app is downloaded to mobile, it keeps track of all your activities (provided you are carrying your mobile during the activities of
running, jogging, walking, etc.). The Google Fit data can be seen over the web here.
 
Google Fit REST API  
 
You can customize the page to add your own activities and log your weight.
 

How to sync the data?

 
The data is recorded on your phone by an app. Use the Google Account Sync option to sync it with the web. Below are the steps for Android users.
  1. Go to the Settings > Accounts.
  2. Select "Google".
  3. Sync On the “Google Fit data”.

Google Fit REST API Keywords

 
Google Fit REST enables to store and access the user data in fitness store. There are a few keywords to understanding for Google Fit REST API.
  • Data Source
    Represents a unique source of sensor data. Data sources expose the raw data generated from hardware sensors. It can also expose derived data by transforming or merging multiple data sources. It uniquely identifies the data based on hardware device and app recorded or transformed the data.

  • Dataset
    Represents a set of points from a particular data source. It represents data at fixed boundaries.

  • Data Point
    Represents sample from particular data source. Data Point holds value for each field per timestamp.

  • Session
    Represents time interval. It allows querying the data. Start time and end time for sessions is controlled by applications and is used to represent user-friendly information like walking, running, bike ride, etc.

  • Data Type
    Represents the schema for the data being recorded. It only defines representation and format of data. As an example com.google.step_count.delta data type represents step count as delta between the start and the end time, whereas com.google.step_count.cumulative as the sum of steps between start and end time.

Fitness Data Types

 
The fitness data types are available under com.google namespace. A data type can represent
  • A particular reading (includes only timestamp)
  • An aggregate over the time interval (also includes timestamp for start of the interval)
You may also create your own data types if needed. There are 3 types of Data Types.
 
Public Data Types
 
These are the standard data types provided by the platform. Below are a few often-used public datatypes.
 
Data Type NameDescription
com.google.calories.expendedTotal calories expanded over given time interval
com.google.distance.deltaDistance covered since last reading
com.google.heart_rate.bpmHeart rate
com.google.heightUser height (in meters)
com.google.weightUser weight (in kg)
com.google.step_count.deltaNew steps since last reading
 
Custom Data Types
 
We can create our own custom data types to store the fitness data. Custom data types are created per application. Data type created in one application will not be available to use in other applications. To handle this scenario, use Shareable data types.
 
Shareable Data Types
 
These are custom data types approved by Google to be shared on Google Fit. To create a new shareable data type, send an email to [email protected] with the description of the requested data type and explaining how it will be useful to other users and developers.
 

Summary

 
Google Fit provides the REST APIs to store and access user data in fitness store. Google Fit has predefined data types to represent the fitness data. Using the data types, information can be shared within and across applications.


Similar Articles