Fitness Data Types

Google Fit provides a set of fitness data types under the com.google namespace. You can also define custom data types in your own namespace.

Data types define the format of the values inside data points. A data point can represent:

  • An instantaneous reading or observation
  • An aggregate with statistics over a time interval

Google Fit defines data types for instantaneous observations and data types for aggregate data. Data points consist of values for the fields of a data type and timestamp information. Points that represent instantaneous observations include a timestamp, and points of an aggregate data type also include the start time for the interval.

Google Fit enables you to define new data types in your app and to share your new data types with other apps.

Data types

Google Fit features the following data types:

Public data types

Standard data types provided by the platform, like com.google.step_count.delta. Any app can read and write data of these types.
For more information, see Public Data Types.

Private custom data types

Custom data types defined by an specific app. Only the app that defines the data type can read and write data of this type.
For more information, see Custom Data Types.

Shareable data types

Custom data types submitted to the platform by an app developer. Once approved, any app can read data of a shareable type, but only whitelisted apps as specified by the developer can write data of that shareable type.
For more information, see Shareable Data Types.

Restricted data types

Google Fit restricts write access for the data types in HealthDataTypes to only certain developers.
For more information, see Restricted Data Types.

Public data types

Google Fit defines data types for instantaneous readings and data types for aggregate data.

Data types for instantaneous readings

These data types are defined as public fields of the DataType class. Their field names start with the TYPE_ prefix.

Data Type Name Description Permission Fields (Format—Unit)
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)
(deprecated) com.google.calories.consumed Total calories consumed over a time interval. Activity calories (float—kcal)
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_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.location.sample The user's current location. Location latitude (float—degrees)
longitude (float—degrees)
accuracy (float—meters)
altitude (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

Set data point values

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();

DataPoint banana = DataPoint.create(nutritionSource);
banana.setTimestamp(now.getMillis(), TimeUnit.MILLISECONDS);
banana.getValue(Field.FIELD_FOOD_ITEM).setString("banana");
banana.getValue(Field.FIELD_MEAL_TYPE).setInt(Field.MEAL_TYPE_SNACK);
banana.getValue(Field.FIELD_NUTRIENTS).setKeyValue(Field.NUTRIENT_TOTAL_FAT, 0.4f);
banana.getValue(Field.FIELD_NUTRIENTS).setKeyValue(Field.NUTRIENT_SODIUM, 1f);
banana.getValue(Field.FIELD_NUTRIENTS).setKeyValue(Field.NUTRIENT_POTASSIUM, 422f);

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

Data types for aggregate data

These data types are defined as public fields of the DataType class. Their field names start with the AGGREGATE_ prefix.

Data Type Name Description Permission Fields (Format—Unit)
com.google.activity.summary Total time and number of segments in a particular activity for a time interval. Activity activity (int—enum)
duration (int—ms)
num_segments (int—count)
com.google.heart_rate.summary Average, maximum, and minimum beats per minute for a time interval. Body average (float—bpm)
max (float—bpm)
min (float—bpm)
com.google.location.bounding_box A bounding box for the user's location over a time interval. Location low_latitude (float—degrees)
low_longitude (float—degrees)
high_latitude (float—degrees)
high_longitude (float—degrees)
com.google.nutrition.summary User's nutrition intake during a time interval. Nutrition nutrients (Map<String, float>—calories/grams/IU)
meal_type (int—enum)
food_item (String—n/a)
com.google.power.summary Average, maximum, and minimum power generated while performing an activity. Activity average (float—watts)
max (float—watts)
min (float—watts)
com.google.speed.summary Average, maximum, and minimum speed over ground over a time interval. Location average (float—m/s)
max (float—m/s)
min (float—m/s)
com.google.weight.summary Average, maximum, and minimum weight over a time interval. Body average (float—kg)
max (float—kg)
min (float—kg)
Table 2: Fitness data types for aggregate data

Using fitness data types on 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.

Custom data types

Google Fit enables you to create custom data types for your app and to use them to store fitness data. When you create custom data types, ensure that:

  • Google Fit does not already provide a similar data type
  • The data type name is clear
  • The data type name accurately represents the underlying data
  • The prefix of the data type name matches your app's package name

Create a custom data type

To create a custom data type for the first time, use the ConfigApi.createCustomDataType method:

// 1. Build a request to create a new data type
DataTypeCreateRequest request = new DataTypeCreateRequest.Builder()
    // The prefix of your data type name must match your app's package name
    .setName("com.app.custom_data_type")
    // Add some custom fields, both int and float
    .addField("field1", Field.FORMAT_INT32)
    .addField("field2", Field.FORMAT_FLOAT)
    // Add some common fields
    .addField(Field.FIELD_ACTIVITY)
    .build();


// 2. Invoke the Config API with:
// - The Google API client object
// - The create data type request
PendingResult<DataTypeResult> pendingResult =
    ConfigApi.createCustomDataType(mClient, request);


// 3. Check the result asynchronously
// (The result may not be immediately available)
pendingResult.setResultCallback(
    new ResultCallback<DataTypeResult>() {
        @Override
        public void onResult(DataTypeResult dataTypeResult) {
            // Retrieve the created data type
            DataType customType = dataTypeResult.getDataType();
            // Use this custom data type to insert data in your app
            // (see other examples)
            ...
        }
    }
);

Retrieve your custom data types

To access a custom data type, use the ConfigApi.readDataType method:

// 1. Invoke the Config API with:
// - The Google API client object
// - The custom data type name
PendingResult<DataTypeResult> pendingResult =
    ConfigApi.readDataType(mClient, "com.app.custom_data_type");

// 2. Check the result asynchronously
// (The result may not be immediately available)
pendingResult.setResultCallback(
    new ResultCallback<DataTypeResult>() {
        @Override
        public void onResult(DataTypeResult dataTypeResult) {
            // Retrieve the custom data type
            DataType customType = dataTypeResult.getDataType();
            // Use this custom data type to insert data in your app
            // (see other examples)
            ...
        }
    }
);

Create data points of custom data types

To create data points for the custom data type above, obtain each component of the data point and assign a value with the correct format as follows:

// Create a data point for a data source that provides
// data of type "com.app.custom_data_type" (created above)
DataPoint dataPoint = DataPoint.create(myDataSource);

// Set values for the data point
// This data type has two custom fields (int, float) and a common field
dataPoint.getValue(0).setInt(mField1IntValue);
dataPoint.getValue(1).setFloat(mField2FloatValue);
dataPoint.getValue(Field.FIELD_ACTIVITY).setInt(mActivityValue);

When you create custom data types that contain both int and float fields, you can't use the DataPoint.setFloatValues() and DataPoint.setIntValues() methods for those fields. In this case, obtain the components of the data point and assign a value to each component individually as shown in this example.

Shareable data types

Shareable data types are custom data types that have been approved by Google to be shared on Google Fit. You can submit a request to create a new shareable data type, and applications can use existing shareable data types in accordance with the terms and conditions set by the developer who created the data type.

Guidelines for new shareable data types

In addition to the guidelines for custom data types, ensure that your proposed shareable data type:

  • Does not duplicate an existing public data type.
  • Uses standard units when possible.
  • Represents fitness-related data.
  • Represents data that is relevant to other fitness apps.

Request a new shareable data type

To request a new shareable data type:

  1. Send an email to google-fit-shareable@google.com with a request to add a new shareable data type to Google Fit. Provide a brief description of your data type and explain why this data type might be useful to users and developers.

  2. If your proposed data type adheres to the Google Fit developer terms, follows the guidelines above, and has a compelling developer use case, we will send you a form to fill out.

  3. After you receive the form, provide the following data:

    Form Item Description
    Data type name

    Your data type name should accurately represent the underlying data. For example, one of the Google data types is com.google.location.sample, which represents a latitude-longitude location sample.

    The prefix of your data type name should not be tied to your application's package name, so developers can read this data type even if your application is not installed on the device.

    Use lowercase words to name your data type.

    Example of a good name: com.mycompanyname.mydatatypename

    Data type description

    Explain the following:

    • What the data type is
    • Roughly how it is calculated
    • Which of your devices and/or apps can provide data of this type
    • How can users and developers use data of this type
    Data type fields

    Provide the following:

    • Field names
    • Field types (only int and float are currently supported)
    • Field units (degrees, beats per minute, calories, and so on)

    For example, com.google.location.sample has these fields:

    • latitude (float – degrees)
    • longitude (float – degrees)
    Whitelisted accounts A list of Google Accounts to whitelist for access to these data types during development and testing.
    Apps that can write data A list of app package names that can write data of this type.

  4. Once we review your responses, you may get questions from our team before approval.

    For a shareable developer data type to be approved, the data type must:

    • Follow the guidelines listed above.
    • Be consistent with Google policies.
    • Have its format reviewed and approved by the Google Fit engineering team to ensure good design. The data type:
      • should not be ambiguous
      • should use standard units as much as possible
      • should include only fitness-related data
      • shouldn't be too broad (as close to raw data as possible)
    • Have its usefulness reviewed by the Google Fit product team. The data type:
      • should not be too specific or only enable one-to-one interactions
      • must enable making data accessible and useful by any app

  5. Your approved shareable data type will be launched within a mutually-agreed timeframe, and it will be listed in the Available Shareable Data Types section.

Available shareable data types

For more information about these shareable data types, see the third party developer terms and documentation for each data type.

Data Type Name Third Party Description Permission Fields
(Format—Unit)
Third Party Documentation
com.nike.NIKEFUEL Nike NikeFuel is a universal metric for movement that allows athletes to measure and compare all day activity and training intensity, and get real time feedback for any sport, at any skill level. Activity NIKEFUEL
(int—NikeFuel points)
Terms of Use
com.adidas.jump.height Adidas Jump height measures the height in inches for each jump recorded over a given period of time. Activity height
(float—inches)
Terms of Use
com.adidas.hustle Adidas Hustle measures how much force (effort) one generates through events (sprints, cuts and jumps) over a given period of time. Activity hustle
(float—m/s2/min)
Terms of Use
com.adidas.quickness Adidas Quickness is determined by how quick (on average) one changes their upper body linear speed or direction. Activity quickness
(float—m/s2/sec)
Terms of Use
Table 3: Available shareable data types

Retrieve a shareable data type

To obtain an approved shareable data type, pass the name of the shareable data type as an argument to the ConfigApi.readDataType method.

Inserting data of a shareable type

Only apps approved by the developer of a shareable data type can write data of this type. Apps that create data of a shareable data type must implement at least one of these three approaches:

  • Insert data directly
  • Define an application sensor
  • Annotate sessions
  • Respond to data creation intents

For details on how to create fitness data of a particular shareable type, see the documentation for the data type in table 2.

Insert data directly

Apps approved by the data type developer can write fitness data directly to the fitness store using the History API.

Define an application sensor

To enable real-time collection and persistent storage of the data type by any Android app, the app from the developer of the data type defines an application sensor that provides this data. If an app tries to register for data of a shareable type, and the corresponding app is not installed, Google Fit gives an error. Other apps can use the error to fire an intent to install the app from the developer of the data type.

Anotate sessions

If data of a shareable type can be generated after-the-fact, the app from the data type developer can listen on new sessions being created and insert data of the shareable type shortly after the session ends. This app can read any raw data required from Google Fit, perform computations, and insert the derived data of the shareable type. This approach does not require direct intervention from other apps.

Respond to data creation intents

If data of a shareable type can be generated after-the-fact, the app from the developer of the data type can listen for the following intent:

  • Action - com.google.android.gms.fitness.COMPUTE_DATA
  • Type - com.google.android.gms.fitness.data_type/com.developer.<data_type>
  • Extras - start_time, end_time, other parameters

Apps that are interested in creating data of a shareable data type can fire this intent. If the app from the data type developer is not installed, Google Fit fires an intent to install it.

Apps need user permission to read and write data of a shareable type. Google Fit presents users an authorization screen before an app can read or write data of these types.

Restricted data types

Because health data is potentially sensitive, Google Fit restricts write access for the data types in HealthDataTypes to only certain developers. Apps need user permission to read and write data of a restricted type. Any application can read fitness data of a restricted data type, but only Google-approved applications can write data of this type. If you would like to write to a restricted data type:

  1. Send an email to google-fit-restricted@google.com and request to be added to the whitelist of apps allowed to write data of a restricted type to Google Fit. Provide a brief description of the data types you would like access to.
  2. If the data from your application can originate from connected devices, please include the following details about your use case and connected devices:

    • Data Type(s) to be written to.
    • Device model.
    • Validation Protocols Met (e.g. ESH 2002, BHS, ISO15197:2013).

Send feedback about...