Search code examples
geolocationgoogle-geolocationip-geolocation

How can I approximate user location through their IP address on server side?


I know there are APIs for doing so but I want to do so as cheaply and locally as possible(without compromising on on quality of guesses ).


Solution

  • For a local solution, you can use a database file. You can find free ones with virtually limited accuracy below:

    There exists paying variants with better accuracy. However, when using a local database file, you should ask yourself some questions:

    • Do you want to implement the local database file loading/lookup by yourself?
    • Do you know how to update your database file with no service interruption (IP allocations change frequently)?
    • Is your solution scaling to your needs (in terms of requests/second and latency)?
    • Don't you need to deduce transient information (timezone, currency, etc.)?

    If the answer is No to one of the previous questions, you should most probably use an IP Geolocation API. I suggest having a look at my service, Ipregistry: it is fast, reliable and inexpensive.