Certain records may consist of multiple activities that make up the entire record. In these cases, the segments object is used to present the different sub-records within the larger record. For instance, a nutrition record can also consist of multiple segments that make up the entire nutrition meal. The Segments object is used to record a specific part as part of a nutrition record. The segment object not only stores high-level information about the entire nutrition record, but it also acts as a container for the detailed items/measurements for the nutrition record.

📘

Note: Parsing Segment Data

Segment data is available when a source provides a more granular breakdown of
metrics. The handling of segment data is driven by the customer use case. Segments are provided as an array accessed by the 'segments' field. Simply checking the length of that
field's value will provide insight into whether segment data is available for processing.

{
  "data": [
    {
      "id": "3d5961cd5ba41b344a7fdbb29f44fe16",
      "name": "Unknown",
      "type": "nutrition",
      "user": {
        "uid": "demotestuser1",
        "user_id": "58dbc86SAMPLE001e6b7c7",
        "organization_id": "58cb5SAMPLEda50001f75db3"
      },
      "log_id": "2017-03-29",
      "source": {
        "type": "fitbit"
      },
      "metrics": [
        {
          "type": "energy_consumed",
          "unit": "kcal",
          "value": 319,
          "origin": "unknown"
        },
        {
          "type": "dietary_fiber",
          "unit": "g",
          "value": 6,
          "origin": "unknown"
        },
        {
          "type": "water",
          "unit": "mL",
          "value": 0,
          "origin": "unknown"
        },
        {
          "type": "carbohydrate",
          "unit": "g",
          "value": 50,
          "origin": "unknown"
        },
        {
          "type": "fat",
          "unit": "g",
          "value": 8,
          "origin": "unknown"
        },
        {
          "type": "protein",
          "unit": "g",
          "value": 16,
          "origin": "unknown"
        },
        {
          "type": "sodium",
          "unit": "mg",
          "value": 437000,
          "origin": "unknown"
        }
      ],
      "version": "1.0",
      "category": "other",
      "checksum": "328c016c3a3ac6a3428dcd627bf008f8",
      "end_time": "2017-03-30T03:59:59Z",
      "segments": [
        {
          "name": "Breakfast Summary",
          "metrics": [
            {
              "type": "energy_consumed",
              "unit": "kcal",
              "value": 319,
              "origin": "unknown"
            },
            {
              "type": "dietary_fiber",
              "unit": "g",
              "value": 6,
              "origin": "unknown"
            },
            {
              "type": "carbohydrate",
              "unit": "g",
              "value": 50,
              "origin": "unknown"
            },
            {
              "type": "fat",
              "unit": "g",
              "value": 8,
              "origin": "unknown"
            },
            {
              "type": "protein",
              "unit": "g",
              "value": 16,
              "origin": "unknown"
            },
            {
              "type": "sodium",
              "unit": "mg",
              "value": 437000,
              "origin": "unknown"
            }
          ]
        }
      ],
      "created_at": "2017-03-29T14:54:00.490Z",
      "start_time": "2017-03-29T04:00:00Z",
      "utc_offset": -14400,
      "offset_origin": "profile"
    }
  ]
}

What’s Next