15 releases

0.3.6 Nov 9, 2023
0.3.5 Mar 27, 2021
0.3.3 Feb 24, 2021
0.3.0 Jan 21, 2021
0.2.6 Nov 25, 2020

#1075 in Network programming

Download history 71/week @ 2024-01-01 69/week @ 2024-01-08 83/week @ 2024-01-15 53/week @ 2024-01-22 163/week @ 2024-01-29 67/week @ 2024-02-05 99/week @ 2024-02-12 92/week @ 2024-02-19 117/week @ 2024-02-26 95/week @ 2024-03-04 101/week @ 2024-03-11 61/week @ 2024-03-18 39/week @ 2024-03-25 114/week @ 2024-04-01 74/week @ 2024-04-08 83/week @ 2024-04-15

317 downloads per month
Used in 4 crates

GPL-3.0 license

26KB
447 lines

ipgeolocate

Crates.io API Crates.io

Get IP address geolocation information freely.

ipgeolocate = "0.3.5"

Add to Cargo.toml.

Example

Because ipgeolocate is an async library, you need an async runtime like tokio or async-std to run.

Using ipgeolocate is really quite easy:

use ipgeolocate::{Locator, Service};

// Prints the city where 1.1.1.1 is.
#[tokio::main]
async fn main() {
    let service = Service::IpApi;
    let ip = "1.1.1.1";

    match Locator::get(ip, service).await {
        Ok(ip) => println!("{} - {} ({})", ip.ip, ip.city, ip.country),
        Err(error) => println!("Error: {}", error),
    };
}

This and more examples are found in the examples directory.

Query Limits

Each service included in this library has a weekly, hourly, or monthly limit. Some have more free queries, but are less reliable.

Here are the query limits:

Service Limit
ipwhois.app 10,000/month
freegeoip.app 15,000/hour
ip-api.com 45/minute
ipapi.co 1,000/day (30,000/month)

You can use each of these just by running the function of the same name.

freegeoip.app is not recommended because it has issues reliably getting the correct latitude and longitude for IP addresses.

Fields

The API can get these fields about IP addresses.

  • ip
  • latitude
  • longitude
  • city
  • region
  • country
  • timezone

Credits

Grant Handy grantshandy@gmail.com

APIs included:

Written with love, in Rust.

Dependencies

~5–19MB
~264K SLoC