maxmind_geo_ip2 API client
Full documentation here: https://docs.rs/maxmind_geo_ip2/
Crates.io page here: https://crates.io/crates/maxmind_geo_ip2
WARNING: This is still very much a work in progress - this should probably/definitely NOT BE USED IN PRODUCTION.
This is my first Rust crate, so any suggestion about improvements, etc are very welcome.
To-dos:
- error handling
- response status checks
Dependencies
reqwest = { version = "0.11.3", features = ["rustls", "json"] }
serde = { version = "1.0.125", features = ["derive"] }
Usage
Import the api client from the crate:
use maxmind_geo_ip2::ApiClient;
Initialize the client with Maxmind API credentials:
let maxmind_client = ApiClient::new_client(String::from("user_id_here"), String::from("license_key_here"));
Methods
Get Country
API endpoint:
https://geoip.maxmind.com/geoip/v2.1/country/{ip_address}
Method signature:
get_country
Response:
Get City
API endpoint:
https://geoip.maxmind.com/geoip/v2.1/city/{ip_address}
Method signature:
get_city
Response:
Get Insights
API endpoint:
https://geoip.maxmind.com/geoip/v2.1/insights/{ip_address}
Method signature:
get_insights
Response: