geoip-api
If you do not require an auto-updating database or prometheus metrics, you should check out ffissore/geoip-rs, the inspiration for this project.
geoip-api is a geoip service: it provides geographical information about the specified IP address. It supports both IPV4 and IPV6.
-
When called with the
ipquery param, it resolves the specified IP address. For example: https://localhost:3000/?ip=216.58.205.132If the provided IP address is invalid, it returns an error
-
By default, responses will be in english. An optional
langquery param can be provided: if a translation is available, returned data will be in that language. Current list includes:de,en,es,fr,ja,pt-BR,ru,zh-CH. For example: https://localhost:3000/?ip=216.58.205.132&lang=ja -
Instead of reading from a file, geoip-api will regularly check for updates to the maxminddb online. See the usage below, on how to configure this.
Example response
Valid ip address:
Not found (private) ip address (will return an 400 error code):
AddressNotFoundError: Address not found in database
Speed
I was able to achieve 150k requests per second on my machine.
geoip-api does choose to hold the entire database in memory, rather than writing it to a file. Since it must download the new database while still serving requests from the old one, please allow at least 512 MB of memory for this.
Usage
Install geoip-api with
If you don't have cargo, install it with
|
or read the tutorial for additional instructions.
You can specify options via the command-line or environment variables,
e.g.
# or
License
This project is licensed under the Apache License, Version 2.0