Future of Google Location History API
Asked Answered
E

4

41

Google will be retiring Latitude soon, along with Latitude's API. But they say on their blog that Location History will still be stored and users will be able to access their history on Google Maps' Location History Dashboard. Do you know if there will be any API for receiving that location history, as there was for Google Latitude?

Equiponderance answered 11/7, 2013 at 9:24 Comment(0)
E
20

I've discovered that I can dynamically load my location history for any date using the following url:

https://maps.google.com/locationhistory/b/0/kml?startTime=1373666400000&endTime=1373752800000

by changing timestamps in "startTime" and "endTime" parameters. Unfortunately it's in .kml and no granularity data is included. Come on, Google - Latitude has some devoted users who relay on it on daily basis, don't kill it :(

Equiponderance answered 13/7, 2013 at 4:29 Comment(6)
This might technically work but is very likely not allowed due to google's terms of service.Carcajou
Any idea how to do that programmatically? I also need a way to do it. Or whereistristan.com - is going to go dark :(Masto
I found a way to get the data as JSON, see answer below.Septempartite
Unfortunately this URL doesn't result in a download any more.Differentiable
play.google.com/store/apps/details?id=mg.locations.track5 how this app getting location history am surprised..Guidotti
its showing on title powered by google, is this app using any api to get location from google.Guidotti
S
18

In case you want the data as JSON with accuracy and not just the locations, you can just make the same request that the website makes. Looking at the inspector shows that it makes a request to https://maps.google.com/locationhistory/b/0/apps/pvjson?t=0. You can replay the same request with cURL (or any other way to make a POST request).

curl 'https://maps.google.com/locationhistory/b/0/apps/pvjson?t=0' -H 'origin: https://maps.google.com' -H 'accept-encoding: gzip,deflate,sdch' -H 'x-manualheader: [SOME STRING]' -H 'accept-language: en-GB,en;q=0.8,en-US;q=0.6,de;q=0.4,pt;q=0.2' -H 'cookie: GDSESS=[COOKIE DATA]' -H 'x-client-data: [ANOTHER STRING]' -H 'user-agent: [UA STRING]' -H 'content-type: application/x-www-form-urlencoded;charset=UTF-8' -H 'accept: */*' -H 'cache-control: max-age=0' -H 'referer: https://maps.google.com/locationhistory/b/0' -H 'dnt: 1' --data '[null,[BEGIN],[END],true]' --compressed

I left out my private cookie data and some details (in [..]) but you can google chrome ask to generate this for you in the developer console (right click on request -> copy as cURL). Just adapt the begin adn end times and download your location history as JSON. However, you need to download ranges of a couple of days and not everything at once. I'll leave this as an exercise for the reader.

Septempartite answered 28/4, 2014 at 3:21 Comment(3)
Is that url documented anywhere?Apocarp
@Apocarp well, it is the url that google uses to get the data, not really documentedSeptempartite
Is there a description for the json result? First datapiece of a point is alwasy null. Second seems to be the recording time in unix format. Third and Fourth the lat and lon. 5th the distance to the starting point. 6th the confidence?! 7th the recordtime again? Sometimes the points have a subresultset containing null, a single digit number and a timepoint after the recording date. Somebody know which datapiece stands for what?Heeheebiejeebies
P
9

I too am searching for an alternative solution to get my location back from Google.

Here are some facts:

  • Latitude will be replaced with location sharing on Google+
  • Android devices will continue to report location data to Google
  • Latitude will be removed (API, friends, website ...)

If devices will still be sending location data, Google should give us an API to fetch that data.

I've been looking into it and my location is shown on my G+ profile, but no info about granularity or timestamp. It just says "Current location: [geocoded city]". Reverse geocoding that address isn't very accurate. If I click on the address, Google Maps is opened in a new tab with coordinates, which seem to be pretty accurate. So, if my location is on G+, I should be able to get it via the G+ API, right?

Well..

The only thing I've been able to find was this:

https://developers.google.com/+/api/latest/people

  "currentLocation": string,

As you can see, the location data is returned as a string. I haven't tried it yet, but I would bet money that it would return the same as on my profile, just the name of the city, but not more accurate than that.

Right now it sucks. I want to get my location info, if the device is already sending it. Installing a 3rd party app on my phone to feed my location on another service is redundant. And let's not forget about the additional battery drain and mobile data usage.

The logical step would be to put all of the latitude functionality to Google+.

We'll see, I doubt it.

Right now it just seems that they will be feeding on our privacy without us having any control or insight into it. :(

Pawn answered 13/7, 2013 at 0:17 Comment(0)
C
9

You can also download the data from Google Takeout. I know that this isn't an API, per se, but even a manual import is probably better than nothing.

https://google.com/takeout/

Cis answered 20/8, 2014 at 15:14 Comment(1)
If manual import would be an option then downloading kml from location history would be the answer not takeout.Overcoat

© 2022 - 2024 — McMap. All rights reserved.