I'm developing a web application which requires to fetch user's steps count fromt Google Fit periodically.
I went through the API docs and found the REST End Point : https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate which gives the steps count.
I'm passing the data to this POST end point in below format.
{
"aggregateBy": [
{
"dataTypeName": "com.google.step_count.delta",
"dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps"
}
],
"bucketByTime": {
"durationMillis": 86400000
},
"startTimeMillis": 1630568107871,
"endTimeMillis": 1630571402415
}
The steps count returned from the above request is different from the ones showing in my Google Fit app.
I tried searching this for days but didn't found anything.
How can I get the correct steps from this API as shown on the Google Fit app
Related
I'm currently working on an app with GoogleMaps API using their PlacesAutocomplete plugin to fill an input.
The problem which I encountered is that for the result types for Airports I get only establishment. I tried using establishment and geocode for parameters in the API call but with no luck. I either get only establishment or maximum transit_station in the results. The problem with transit_station is that all the train stations, airports, bus stations are marked the same.
I need a way to get the specific type for each of them, could someone help me please, maybe I'm doing something wrong.
You can see in the screenshot below the result from the API
According to the documentation, currently the types parameter of places autocomplete supports only following values:
geocode
address
establishment
(regions)
(cities)
https://developers.google.com/maps/documentation/javascript/places-autocomplete#add_autocomplete
LE: Found a workaround
In order to get the place type I used another API this time Place Details
I took the placeId from the Autocomplete request and fired a new request to the Place Details with the fields parameter set to types
https://maps.googleapis.com/maps/api/place/details/json?key=[YOUR_KEY]&placeid=ChIJRQFUJVRhRUcR-C4yT1Y4KWk&fields=type
And the result was
{
"html_attributions": [],
"result": {
"types": [
"airport",
"point_of_interest",
"establishment"
]
},
"status": "OK"
}
So by combining the two calls I was able to get even the type which in the Autocomplete was not available
The docs for the the Place Details can be found here
I have a database with a list of locations and I have to get the route steps, drive distance and drive time for all combinations of locations in the database.
I have the latitude and longitude stored in the database for every location.
I'm using the google directions service api to get the information.
As long as the number of records was low, I could get the results from my code within a minute using threading.
However as the number of records increased, the number of records in combination increased exponentially (trust me, this is not the issue and the number of combinations have the potential to reach 100K), thereby causing an increase in the number of requests to be made to directions api and hence the time taken for retreival.
I understand since a large number of rest connections need to be made to the directions api, network latency plays in and the time taken to retrieve the results increases.
I googled and found that some of the maps api's (for instance waypoints in the directions service api) allow you to specify more than 1 value using the pipe operator ( | ).
I attempted to do the same and retrieve information for one source multiple destinations for every rest request however I get a NOT_FOUND status returned from the directions service.
Could someone please help me figure out how to get routes and the distance and time from the same origin but multiple destinations using the directions api.
Following is a sample url and the response I received (API_KEY was removed on purpose, cannot share that):
https://maps.googleapis.com/maps/api/directions/json?key=API_KEY&origin=49.794150,-84.564514&destination=49.244978,-88.146057|49.173205,-84.756775
{
"geocoded_waypoints" : [
{},
{
"geocoder_status" : "ZERO_RESULTS"
}
],
"routes" : [],
"status" : "NOT_FOUND"
}
Directions API doesn't support multiple origins or destinations. You can specify one origin, one destination and up to 23 waypoints.
https://developers.google.com/maps/documentation/directions/intro#Waypoints
The request with waypoints looks like:
https://maps.googleapis.com/maps/api/directions/json?origin=49.794150%2C-84.564514&destination=49.173205%2C-84.756775&waypoints=49.244978%2C-88.146057&key=YOUR_API_KEY
If you would like to test your routes and see the visual representation, you can use Directions calculator:
https://directionsdebug.firebaseapp.com/?origin=49.794150%2C-84.564514&destination=49.173205%2C-84.756775&waypoints=49.244978%2C-88.146057
Hope it helps!
I've been trying to find specific place in Google Places API with no success. When I type "La Cucina Trattoria" in Google Maps I get three results. However, when I run this query:
https://maps.googleapis.com/maps/api/place/autocomplete/json?key=API_KEY&input=la%20cucina%20trattoria
I only get two results. So I've tested more queries with similar effectiveness:
input=la%20cucina%20trattoria%20gmbh - no results
https://maps.googleapis.com/maps/api/place/search/json?key=API_KEY&location=48.139649,11.602685&rankby=distance&keyword=cucina - place missing in results (I've put its exact location as a parameter)
location=48.139649,11.602685&rankby=distance&keyword=Neherstraße%209 - place missing in results (however, it is returning results from the same street)
My client named two random places he knows and none of them could be found in Google Places API. Is it possible that Google Places API and Google Maps operate on two different databases? Or can these places be hidden in the public API?
I've come across similar issues, but usually changing the query gave better results. Aside from reporting it, you can manually add a place:
POST https://maps.googleapis.com/maps/api/place/add/json?key=AddYourOwnKeyHere HTTP/1.1
Host: maps.googleapis.com
{
"location": {
"lat": -33.8669710,
"lng": 151.1958750
},
"accuracy": 50,
"name": "Google Shoes!",
"phone_number": "(02) 9374 4000",
"address": "48 Pirrama Road, Pyrmont, NSW 2009, Australia",
"types": ["shoe_store"],
"website": "http://www.google.com.au/",
"language": "en-AU"
}
This should allow your application to immediately see the place and potentially have it added into Google Maps.
I was unable to find La Cucina Trattoria in Places, and I tried a number of different tactics, including a Text Search (https://maps.googleapis.com/maps/api/place/textsearch/xml?query=italian restaurant on Neherstraße in munich&key=MYKEY). I'd report it to the Place API Issues tracker here: https://code.google.com/p/gmaps-api-issues/issues/list?can=2&q=apitype:PlacesAPI%20type:Defect&sort=-stars&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Internal%20Stars
Check through the extensive list of existing bugs to see if you can add your name to an existing one and speed its resolution. Here are some similar confirmed bugs:
Some queries return no results when there should be many
Bug: Sparse search results in germany
Bug: Place details request returns wrong result
We are trying to use the Google Drive API to retrieve the model of a Realtime document (API reference). However, if I call the "get" method to retrieve details of a Realtime File generated through the Google Drive Realtime API Playground app (with a blank "revision" field), the result is always:
{
"appId": "292824132082",
"revision": 1,
"data": null
}
even after a lot of editing on the model. If I try to specify a different revision (say, "2") the result is a 500 error:
{
"error": {
"code": 500,
"message": null
}
}
Are we doing something wrong or is there a problem with this specific API?
Calling "get" using the API Playground gets the realtime document associated with the API playground app, not the realtime document associated with your app.
If you update and get both with the API playground you should see contents.
I am trying to use the Google Maps API to get the latitude and longitude of a few locations. For some reason, whenever I send a place name with an apostrophe, it does not return any results.
For instance, if I send the following requests for searching Berri's Pizza Cafe I get the results mentioned below
http://maps.googleapis.com/maps/api/geocode/json?address=berri%27s+pizza+cafe&sensor=false
{"results" : [], "status" : "ZERO_RESULTS"}
And this
http://maps.google.com/maps/geo?q=Berri%27s%20Pizza%20Cafe&output=json
{
"name": "Berri's Pizza Cafe",
"Status": {
"code": 602,
"request": "geocode"
}
}
I assume this is a problem with Google Maps API (found a forum post saying this was an issue in the javascript API but was supposedly fixed there, probably not in this)
Does anyone have a workaround for this situation?
Thanks.
The issue is that you are attempting to geocode a business name; the geocoder works with postal addresses. Omitting the apostrophe doesn't get any results either (thus proving it's not the apostrophe which is the problem).
Note that the Maps geocoder is far more sophisticated and uses a variety of data sources to locate targets, including address geolocation and business name lookup.
You may be able to find the data you're looking for using the Places API (but you will need to specify the city which you are currently omitting).