Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you don't want to do this yourself, you can actually just get Cloudflare to do it for you for free using a simple Worker since all Cloudflare requests contain approximate IP location information.

You can also just send a request to my URL (Cloudflare Worker operated - so it should have global low latency): https://www.edenmaps.net/iplocation

Use it for small applications, I don't mind. Just don't start sending me 10M requests per day ;-)



Or you download an IP database rather than sharing with a third party which IP address is likely connecting to your service with a third party


Located 100km from the Somali coast... I'm in Brussels, Belgium, thx for protecting my privacy :D


The result is [lon, lat]. You’ve most likely copied it onto Google maps, which works with [lat, lon]. Believe it or not, the industry still hasn’t come up with a standard order.


You could also just return a json with lat and lon as fields so nobody is getting confused. {lat:5, lon:7}


Got me to within 1km, that's pretty crazy


Same here. Scaring.


Does anyone know how accurate Cloudflare geolocation is (for workers requests)?


As accurate as MaxMind[1], since that's what they use [2]. In my experience, it's reasonably accurate for the US, less so for other countries. MaxMind publishes some accuracy data which might be an interesting starting point [3]

That said, for any analytics use cases of this data, be aware that MaxMind will group a lot of what should be unknowns in the middle of a country. Or, in the case the US now, I think they all end up in the middle of some lake, since some farm owners in Butler County, Kansas got tired of cops showing up and sued MaxMind. It can cause odd artifacts unless you filter the addresses out somehow.

1 https://developers.cloudflare.com/support/network/configurin...

2 https://www.maxmind.com/en/geoip-demo

3 https://www.maxmind.com/en/geoip2-city-accuracy-comparison


Yeah, MaxMind is the best I have used with caveats. You need to update it frequently, and you need to allow for overrides.


I work for IPinfo and we do ping based geolocation. The best thing you can do to verify geolocation accuracy is the following:

- Download a few free IP databases - Generate a random list of IP addresses - Do the IP address lookups across all those databases - Identify the IP address that can be pinged - Visit a site that can ping an IP address from multiple server - Sort the results by lowest avg ping time

Then check where the geolocation provider is locating the IP address and what is the nearest server from there.


On one hand, I love that there’s some good alternatives in the geolocation space, but misleading geolocation precision can lead to very undesirable side effects[0].

[0] https://www.theguardian.com/technology/2016/aug/09/maxmind-m...


That is part of the reason why I am here in HN. I am pretty down to earth and willing to talk with anyone about IP metadata.

Our business approach is that we will come to you before you come to us. Whenever people complain about something related to IP data, I will just reach out to them and verify that we provide good data. Our support team is extremely responsive. We also have a community where we walk through users about IP metadata. I am super active on HN, Reddit and Twitter.

The challenge for me is usually that we will tell people, "We are providing good geolocation data for you, but the service that provides geolocation data to the service you are complaining about is not using our data. Our hands are tied." I have reached out to bigger corporations and streaming services to say, "You are providing bad data to your customers. I am not even trying to sell you something. Even using our free database could lead you to better results." But I have not heard from them yet. It is frustrating to me as it is for the person with bad IP data.

IP geolocation is never going to be absolutely accurate or precise. We understand that completely. Aside from continuously investing in improving our data from a product standpoint, we also take a very human approach of trying to fix every geolocation complaint one by one.


This is excellent!

Would you mind open sourcing the code for that?


This is the code running this endpoint:

  export function onRequest(context) {
    return new Response(JSON.stringify([parseFloat(context.request.cf.longitude), parseFloat(context.request.cf.latitude)]), {headers: {"Content-Type": "application/json;charset=UTF-8"}})
  }

This is a function on Cloudflare Pages (which is just a different name for Cloudflare Workers). Minor adjustment needed for Workers (get rid of "context", I believe)


I'm in Munich. Cloudflare tells a position that is 730km to the north in a random forest.


You've inverted lat, lon.


No, the other one was in the ocean




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: