Using the API is designed to be as easy as possible for developers.
Creating an instance of human requires the user's access token.
<?php
use Choccybiccy\HumanApi\Human;
$human = new Human("myAccessToken");
From there you can begin querying the HumanAPI endpoints.
Creating an endpoint instance only requires the endpoint name.
<?php
use Choccybiccy\HumanApi\Human;
$human = new Human("myAccessToken");
$endpoint = $human->get("Activities");
Endpoints support 3 different kinds of data retrieval.
$endpoint->getList(); // Returns all entries in descending order of creation date
$endpoint->getById($id); // Returns single entry matching the given entry ID
$endpoint->getRecent(); // Returns recent entries in descending order of creation date
It's possible to pass options to each method for pagination and refining.
$params = array(
"limit" => 5,
"offset" => 10,
);
$endpoint->getList($params);
$endpoint->getRecent($params);
Full list of parameters:
Parameter | Description |
---|---|
limit |
The max number of records to return in one query. Default is 20 |
offset |
The index of the first record to return. Default is 0 |
created_since |
Returns records that are created after the specified date. UTC date in format YYYYMMDDThhmmssZ |
updated_since |
Returns records that are udpated after the specified date. UTC date in format YYYYMMDDThhmmssZ |
created_before |
Returns records that are created after the specified date. UTC date in format YYYYMMDDThhmmssZ |
updated_before |
Returns records that are updated after the specified date. UTC date in format YYYYMMDDThhmmssZ |
Some endpoints support different methods to retrieve data, this is because of the kind of data that the endpoints contain. For example, while Activities supports all data retrieval methods, Meals only supports the list retrieval method, and doesn't support obtaining specific or recent records.
Attempting to use a method not supported for an endpoint will raise
an \Choccybiccy\HumanApi\Endpoint\UnsupportedEndpointMethodException
exception.
Here's a complete list of available endpoints that can be queried against, along with the types of data that can be retrieved.
Endpoint | getList | getById | getRecent |
---|---|---|---|
Activities | Yes | Yes | Yes |
BloodGlucose | Yes | Yes | Yes |
BloodyOxygen | Yes | Yes | Yes |
BloodPressure | Yes | Yes | Yes |
BodyFat | Yes | Yes | Yes |
BodyMassIndex | Yes | Yes | Yes |
Genetics | Yes | No | No |
HeartRate | Yes | Yes | Yes |
Height | Yes | Yes | Yes |
Locations | Yes | Yes | No |
Meals | Yes | No | No |
Profile | Yes | No | No |
Sleeps | Yes | Yes | Yes |
Sources | Yes | No | No |
Weight | Yes | Yes | Yes |