Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rixafy/freelocalgeoipapi
📡 Free geo ip PHP API that can be run locally based on MaxMind geoip2 database.
https://github.com/rixafy/freelocalgeoipapi
api geoip2 geolocation geolocation-api ip-api maxmind maxmind-db maxmind-geoip maxmind-geoip2-api php php-ip php8
Last synced: 8 days ago
JSON representation
📡 Free geo ip PHP API that can be run locally based on MaxMind geoip2 database.
- Host: GitHub
- URL: https://github.com/rixafy/freelocalgeoipapi
- Owner: Rixafy
- Created: 2023-11-23T01:01:14.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T19:35:38.000Z (about 2 months ago)
- Last Synced: 2024-09-15T20:48:26.078Z (about 2 months ago)
- Topics: api, geoip2, geolocation, geolocation-api, ip-api, maxmind, maxmind-db, maxmind-geoip, maxmind-geoip2-api, php, php-ip, php8
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Free Local Geo-IP PHP Api
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.
## Requirements
- PHP 8.1+
- Composer
- MySQL / MariaDB database## Installation
1. Download this project and run `composer install` to install dependencies.
2. Register at [maxmind.com](https://www.maxmind.com/en/geolite2/signup) and get your free geolite2 license key and account id.
3. Copy `config.sample.php` to `config.php` and set your license key, account id and database credentials.
4. Make sure you are not using tables `ip4_blocks`, `ip6_blocks` and `ip_locations` as they will be overwritten.
5. Run `bin/update` to download and import the database to your local db (~400MB).
5. Open a web server (for instance `php -S localhost:1234 ./public/index.php`)
6. Make a request to `http://localhost:1234?ip=`Feel free to dockerize this project or make PR with more customization options.
## Example response
From url `http://localhost:1234/?ip=8.8.8.8`
```json
{
"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
}
```