diff --git a/explorer-api/README.md b/explorer-api/README.md index 49532965ca..d05c19064b 100644 --- a/explorer-api/README.md +++ b/explorer-api/README.md @@ -14,4 +14,8 @@ TODO: * grab mixnode description info via reqwest and serve it (avoid mixed-content errors) * serve it all over http * dependency injection -* tests \ No newline at end of file +* tests + +## Running + +- Supply the environment variable `GEO_IP_SERVICE_API_KEY` with a key from https://freegeoip.app/ \ No newline at end of file diff --git a/explorer-api/src/country_statistics/mod.rs b/explorer-api/src/country_statistics/mod.rs index 6f588e4eef..681cc7cc32 100644 --- a/explorer-api/src/country_statistics/mod.rs +++ b/explorer-api/src/country_statistics/mod.rs @@ -90,7 +90,15 @@ impl CountryStatistics { } async fn locate(ip: &str) -> Result { - let response = reqwest::get(format!("{}{}", crate::GEO_IP_SERVICE, ip)).await?; + let api_key = ::std::env::var("GEO_IP_SERVICE_API_KEY") + .expect("Env var GEO_IP_SERVICE_API_KEY is not set"); + let response = reqwest::get(format!( + "{}{}?apikey={}", + crate::GEO_IP_SERVICE, + ip, + api_key + )) + .await?; let location = response.json::().await?; Ok(location) }