Intraday
Intraday reference on the official Fitbit documentation.
These set of functions are used to query the Intraday Time Series data, there are several particularities for these set of data so reading the official reference for the endpoint on the link above is encouraged.
This function will receive a Carbon date, a Resource, and a Detail Level and will return a JSON encoded list with the data for the given day with the resolution specified by the detail level. Example call:
$resource = new \Namelivia\Fitbit\Activity\Resource\Resource(\Namelivia\Fitbit\Activity\Resource\Resource::CALORIES);
$detailLevel = new \Namelivia\Fitbit\Activity\DetailLevel(\Namelivia\Fitbit\Activity\DetailLevel::ONE_MINUTE);
$yesterday = Carbon\Carbon::yesterday();
$intraday = $fitbit->activities()->intraday()->getForOneDay(
$yesterday,
$resource,
$detailLevel
);
Example formatted JSON output:
dataset
array abbreviated, just including the first and last elements.
{
"activities-calories":[
{
"dateTime":"2019-07-22",
"value":"2985"
}
],
"activities-calories-intraday":{
"dataset":[
{
"level":1,
"mets":28,
"time":"00:00:00",
"value":3.0657200813293457
},
{
"level":1,
"mets":24,
"time":"23:59:00",
"value":2.6277599334716797
}
],
"datasetInterval":1,
"datasetType":"minute"
}
}
This function will receive three Carbon instances representing the day, the start time and the end time for the query, a Resource, and a Detail Level and will return a JSON encoded list with the data for the given day between the specified start time and end time with the resolution specified by the detail level. Example call:
$resource = new \Namelivia\Fitbit\Activity\Resource\Resource(\Namelivia\Fitbit\Activity\Resource\Resource::CALORIES);
$detailLevel = new \Namelivia\Fitbit\Activity\DetailLevel(\Namelivia\Fitbit\Activity\DetailLevel::ONE_MINUTE);
$yesterday = Carbon\Carbon::yesterday();
$oneHourAgo = Carbon\Carbon::now()->subHours(1);
$twoHoursAgo = Carbon\Carbon::now()->subHours(2);
$intraday = $fitbit->activities()->intraday()->getForOneDayAndTimeRange(
$yesterday,
$twoHoursAgo,
$oneHourAgo,
$resource,
$detailLevel
);
Example formatted JSON output:
dataset
array abbreviated, just including the first and last elements.
{
"activities-calories":[
{
"dateTime":"2019-07-22",
"value":"99.2"
}
],
"activities-calories-intraday":{
"dataset":[
{
"level":0,
"mets":10,
"time":"15:07:00",
"value":1.0949000120162964
},
{
"level":0,
"mets":11,
"time":"16:07:00",
"value":1.204390048980713
}
],
"datasetInterval":1,
"datasetType":"minute"
}
}
This function will receive two Carbon instances representing a start date and an end date and a Resource and will return a JSON encoded list with the data for the days between the specified start date and end time date. Example call:
$resource = new \Namelivia\Fitbit\Activity\Resource\Resource(\Namelivia\Fitbit\Activity\Resource\Resource::CALORIES);
$yesterday = Carbon\Carbon::yesterday();
$intraday = $fitbit->activities()->intraday()->getForADateRange(
Carbon\Carbon::today()->subMonths(1),
$yesterday,
$resource
);
Example formatted JSON output:
dataset
array abbreviated, just including the first and last elements.
{
"activities-calories":[
{
"dateTime":"2019-06-23",
"value":"2549"
},
{
"dateTime":"2019-07-22",
"value":"2985"
}
]
}
This function will receive two Carbon instances representing a start datetime and an end datetime, a Resource, and a Detail Level and will return a JSON encoded list with the data for the days between the specified start datetime and end time datetime the resolution specified by the detail level. Example call:
$resource = new \Namelivia\Fitbit\Activity\Resource\Resource(\Namelivia\Fitbit\Activity\Resource\Resource::CALORIES);
$detailLevel = new \Namelivia\Fitbit\Activity\DetailLevel(\Namelivia\Fitbit\Activity\DetailLevel::ONE_MINUTE);
$intraday = $fitbit->activities()->intraday()->getForADateTimeRange(
Carbon\Carbon::today()->addHours(2),
Carbon\Carbon::now(),
$resource,
$detailLevel
);
Example formatted JSON output:
dataset
array abbreviated, just including the first and last elements.
{
"activities-calories":[
{
"dateTime":"2019-07-23",
"value":"1213.81"
}
],
"activities-calories-intraday":{
"dataset":[
{
"level":0,
"mets":10,
"time":"02:00:00",
"value":1.0949000120162964
},
{
"level":0,
"mets":10,
"time":"17:07:00",
"value":1.0949000120162964
}
],
"datasetInterval":1,
"datasetType":"minute"
}
}
A DetailLevel
represents a valid period of resolution for querying intraday data. Possible values are:
\Namelivia\Fitbit\Activity\DetailLevel::ONE_MINUTE
\Namelivia\Fitbit\Activity\DetailLevel::FIFTEEN_MINUTES