geolocation of an IP address while using GAE sdk or otherwise
Asked Answered
A

2

6

I have hosted my web-app on google appengine (GAE). Does GAE sdk offer any way to find the geolocation of an IP ? If yes please suggest how can I do this .

Ambrosine answered 12/9, 2012 at 11:21 Comment(0)
E
6

Yes, you can use request headers to get the geolocation of the IP.

https://cloud.google.com/appengine/docs/standard/go/reference/request-response-headers#app_engine-specific_headers

X-AppEngine-Country Country from which the request originated, as an ISO 3166-1 alpha-2 country code. App Engine determines this code from the client's IP address.

Other headers that are useful for location are X-AppEngine-Region, X-AppEngine-City and X-AppEngine-CityLatLong

I don't think this will return valid values when running on your local sdk.

Eraste answered 12/9, 2012 at 13:9 Comment(4)
what city does it tell ? one of ISP ?Ambrosine
because it is not telling mineAmbrosine
Getting location based on IP addresses isn't always accurate. If you want something more accurate, then use html5 geolocation api (and fallback to appengine) see this postEraste
Also, have a look at some alternative services like ip-geo.appspot.com which is free for less than 10 000 calls per day and may suit your requirements.Eraste
W
1

It is not clear from your question if you want to determine location of the http request being made to your GAE application or whether you want a service on GAE that can give you the geolocation of any IP address.

GAE provides support for certain HTTP headers that contain geolocation information like country, city, region and IP address. Refer to the two articles over here for more details:

The above articles discuss the headers like

  • X-AppEngine-country
  • X-AppEngine-Region
  • X-AppEngine-City
  • X-AppEngine-CityLatLong

If you are simply looking for a service to give you geolocation details based on IP then GAE does not provide that. There are various external web services available like the one mentioned above in one of the answers.

Will answered 12/9, 2012 at 16:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.