Public data types

Google Fit defines public data types for instantaneous readings.

Data types for instantaneous readings

The following table lists data types for instantaneous readings:

Data Type Name Description Permission Fields (Format—Unit)
com.google.active_minutes The user's Move Minutes. Activity duration (int—minutes)
com.google.activity.sample Instantaneous sample of the current activity. Activity activity (int—enum)
confidence (float—percent)
com.google.activity.segment Continuous time interval of a single activity. Activity activity (int—enum)
com.google.calories.expended Total calories expended over a time interval. Activity calories (float—kcal)
com.google.cycling
.pedaling.cadence
Instantaneous pedaling rate in crank revolutions per minute. Activity rpm (float—rpm)
com.google.cycling
.wheel_revolution.rpm
Instantaneous wheel speed. Location rpm (float—rpm)
com.google.distance.delta Distance covered since the last reading. Location distance (float—meters)
com.google.heart_points The user's Heart Points. Activity intensity (float—heart points)
com.google.heart_rate.bpm Heart rate in beats per minute. Body bpm (float—bpm)
com.google.height The user's height, in meters. Body height (float—meters)
com.google.nutrition Food item information Nutrition nutrients (Map<String, float>—calories/grams/IU)
meal_type (int—enum)
food_item (String—n/a)
com.google.power.sample Instantaneous power generated while performing an activity. Activity watts (float—watts)
com.google.speed Instantaneous speed over ground. Location speed (float—m/s)
com.google.step_count.cadence Instantaneous cadence in steps per minute. Activity rpm (float—steps/min)
com.google.step_count.delta Number of new steps since the last reading. Activity steps (int—count)
com.google.weight The user's weight. Body weight (float—kg)
com.google.activity.exercise A user's continuous workout routine. Activity exercise (int—enum)
repetitions (int—count)
resistance type (int—enum)
resistance (float—kg)
duration (int—milliseconds)
Table 1: Fitness data types for instantaneous readings

Using data types

Android

On Android, the fitness data types are defined as public fields of the DataType class. How you invoke the Fitness APIs with the data type depends on what you want to accomplish:

  • To record fitness data, use the Recording API to create a subscription for each data type you want to record.
  • To read fitness data, use the History API to submit a read request for each data type.
  • To insert data into the fitness history, use the History API to submit an insert request for each data type.
  • To create sessions, use the Sessions API to insert or record fitness data with session metadata.

To create data points for an instaneous DataType object, assign values with the correct format. The following example shows you how to assign the food item as a string, the meal type as a constant from the Field class, and nutrient contents as mapped float values by calling the setKeyValue() method.

DataSource nutritionSource = new DataSource.Builder()
        .setDataType(DataType.TYPE_NUTRITION)
        ...
        .build();

Map<String, Float> nutrients = new HashMap<>();
nutrients.put(Field.NUTRIENT_TOTAL_FAT, 0.4f);
nutrients.put(Field.NUTRIENT_SODIUM, 1f);
nutrients.put(Field.NUTRIENT_POTASSIUM, 422f);
DataPoint banana =
    DataPoint.builder(nutritionSource)
        .setTimestamp(now.getMillis(), TimeUnit.MILLISECONDS)
        .setField(Field.FIELD_FOOD_ITEM, "banana")
        .setField(Field.FIELD_MEAL_TYPE, Field.MEAL_TYPE_SNACK)
        .setField(Field.FIELD_NUTRIENTS, nutrients)
        .build();

After setting data points in your app, you can insert, read, or delete the data from the fitness history with the History API.

REST

The dataSources resource includes the data type (and a list of its fields) for each data source. You can specify one of these data types when you create data sources, and you can obtain the name of the data type and a list of its fields when you retrieve a data source from the fitness store.

For example, a data source representation specifies its data type as follows:

{
"dataStreamId": "exampleDataSourceId",
...
"dataType": {
  "field": [
    {
      "name": "steps",
      "format": "integer"
    }
  ],
  "name": "com.google.step_count.delta"
},
...
}

When using one of the public data types in a data source, the data type name and its field definitions must match those listed in the tables above.

Exceptions

Whilst any application can write data to a public data type, there are certain data types which can only be read by the application that wrote the data.

Data Type Name Description Fields (Format—Unit)
com.google.location.sample The user's current location. latitude (float—degrees)
longitude (float—degrees)
accuracy (float—meters)
altitude (float—meters)
com.google.location.bounding_box A bounding box for the user's location over a time interval. low_latitude (float—degrees)
low_longitude (float—degrees)
high_latitude (float—degrees)
high_longitude (float—degrees)