How to retrieve today's step data for a google fit user using REST API? - google-fit

We are trying to retrieve the step count of our users in real time. If a user is currently running then we try to fetch the latest value of steps taken. While we are able to retrieve the value of steps one day before today we are not able to do so for the current date.
API URL: https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
Request Json:
{"aggregateBy":[
{"dataTypeName":"com.google.step_count.delta",
"dataSourceId":"derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"}],
"bucketByTime":{"durationMillis":86400000},
"startTimeMillis":1557685800000,
"endTimeMillis":1557772199999
}
Response received:
{"bucket":[
{"startTimeMillis":"1557685800000",
"endTimeMillis":"1557772199999",
"dataset":[
{"dataSourceId":"derived:com.google.step_count.delta:com.google.android.gms:aggregated",
"point":[]}
]}
]}

Related

Google Fit Running data

I am using Google API Client for fitness to retrieve user fitness data using the PHP Client library.
My usecase: To get users Total run time for the day, and also distance.
I am using the following code (sample code with key steps):
$service = new Google_Service_Fitness($google_client);
$dataSets = $service->users_dataset;
..
$aggBy->setDataTypeName("com.google.activity.segment");
..
$aggregates = $dataSets->aggregate('me',$aggReq);
I am using com.google.activity.segment as datatypename:
I get a response with run type with data
Activity type: 8
runtime : value in msec
no of segment: 2
Now i want to get the total distance travelled during running session,
From above response i can make out that user had 2 separate running activity, then how i can get the combined distance done by the particular activity?
Also how i can retrieve details about these in 2 running segment in details?
As said i am using PHP Client API.

Unable to retrieve item count for Sharepoint List through Microsoft Graph API

I am currently using the Microsoft Graph API to return data in JSON for a specific list through this URL:
https://graph.microsoft.com/v1.0/sites/{siteID}/lists/{listID}/items/{itemID}
I would like to return data for all the items in the list by iterating through the itemID which is a number like 1,2,3. Although I can do that, I don't know what number to iterate to - does anyone know the API call or the URL for getting the item count in a list. If I send a GET Request to the following URL:
https://graph.microsoft.com/v1.0/sites/{siteID}/lists/{listID}/items
I only get back 235 list item JSON objects (much less than the 1200 that actually exist in the list) so I can't read off the last json object ID as the count.
I can do a while loop till I get an 'id doesn't exist error' but there are some items that are being regularly deleted hence I may encounter the same error there as well.
It can retrieve only few items when sending the API query (100-200) items. So try to use the $top query parameter
Using top query parameter. You are able to retrieve maximum 3000 items using Graph API
https://graph.microsoft.com/v1.0/sites/{siteID}/lists/{listID}/items?$top=3000
Upvote if accepted as a answer

Make weather app using openweathermap api to display LAST x Days' Weather(3 hourly basis)

I want to make an app displaying LAST x days' temperature on 3 hourly basis using the openweathermap API only. I went through the available APIs. They either have the predicted forecast of next 5 days or the historical data expecting start and end as parameters which I tried to use then (https://openweathermap.org/history).
So just to check whether I have understood the params correctly or not, I tried fetching(through the address bar):
http://history.openweathermap.org/data/2.5/history/city?id=1275339&type=hour&appid=df78dcfa9580e72b15fdf62d406d34ec&start=1369728000&end=1369789200".
But I got HTTP error 401:
{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}
I fail to understand how should the parameters be entered to get the desired results (last 5 days temperature on 3 hourly basis) and also how do I enter "cnt" (if needed to) such that it gives me 3 hourly data.

getOffice365ActivationsUserDetail Graph API returns UnknownTenantId

I am trying to get the information about the users that have Activated Office 365 using:
/beta/reports/getOffice365ActivationsUserDetail?$format=text/csv
I am getting an error:
{
"code": "UnknownTenantId",
"message": "We do not recognize this tenant ID {MyTenantID}. Please double-check the tenant ID and try again."
}
The Read.Report.All permission is already assigned, and I am able to get other information from O365 using the Graph API.
Any suggestions how to resolve this issue?
You shouldn't be using the /beta/ release as this report is available in /v1.0/ and returns test/csv by default.
You also need to provide a valid period to the getOffice365ActiveUserDetail endpoint:
Specifies the length of time over which the report is aggregated. The supported values for {period_value} are: D7, D30, D90, and D180. These values follow the format Dn where n represents the number of days over which the report is aggregated.
For example, to get details for users active in past 7 days you would request:
https://graph.microsoft.com/v1.0/reports/getOffice365ActiveUserDetail(period='D7')

Unable to retrieve unlimited number of record via API

We are struggling to mine all time records for this year via API.
We have tried to include the :dont_limit_result GET variable and set it to 1, however it did not help us.
The version that we use is ACTIVE COLLAB 5.11.0, the URL we are hitting: projects?dont_limit_result=1&page=$page
Please give me some advise on how to proceed.
Most of API responses are paginated, and pagination can't be turned off using a GET switch. Instead, you should check following headers:
X-Angie-PaginationCurrentPage - indicates current page
X-Angie-PaginationItemsPerPage - indicates number of items per page
X-Angie-PaginationTotalItems - indicates number of items in the entire data set.
and walk through pages until you reach the end of data set.
Another option is to give project's filter a try. Here's an example request that will return all projects:
curl -H "X-Angie-AuthApiToken: YOUR-API-TOKEN" "http://your.activecollab.com/api/v1/reports/run?type=ProjectsFilter"
This one will return all active projects:
curl -H "X-Angie-AuthApiToken: YOUR-API-TOKEN" "http://your.activecollab.com/api/v1/reports/run?type=ProjectsFilter&completed_on_filter=is_not_set"
I'm using the php API wrapper 3.0 - how do i get the headers back to know there are more pages and then what is the correct form of the query to get further pages?
For example my basic query is:
$timeRecords = $client->get('projects/22/time-records')->getJson();
to get time records - but this only returns 100 and there are more!
Thanks,
P