Reliable and fast local geo-ip api based on MaxMind geoip2 database.
Database can be scheduled (set up a cron) to be updated every day with bin/update command.
- PHP 8.1+
 - Composer
 - MySQL / MariaDB database
 
- Download this project and run 
composer installto install dependencies. - Register at maxmind.com and get your free geolite2 license key and account id.
 - Copy 
config.sample.phptoconfig.phpand set your license key, account id and database credentials. - Make sure you are not using tables 
ip4_blocks,ip6_blocksandip_locationsas they will be overwritten. - Run 
bin/updateto download and import the database to your local db (~400MB). - Open a web server (for instance 
php -S localhost:1234 ./public/index.php) - Make a request to 
http://localhost:1234?ip=<ip> 
Feel free to dockerize this project or make PR with more customization options.
From url http://localhost:1234/?ip=8.8.8.8
{
  "continent_code": "NA",
  "continent_name": "North America",
  "country_iso_code": "US",
  "country_name": "United States",
  "city_name": null,
  "subdivision_1_iso_code": null,
  "subdivision_1_name": null,
  "subdivision_2_iso_code": null,
  "subdivision_2_name": null,
  "metro_code": null,
  "time_zone": "America/Chicago",
  "latitude": 37.751,
  "longitude": -97.822,
  "is_anonymous_proxy": false
}