ghztomash
public-ip-address
Rust

Rust crate to retrieve public IP address and geolocation data. ๐Ÿฆ€

Last updated Jul 7, 2026
210
Stars
30
Forks
2
Issues
0
Stars/day
Attention Score
52
Language breakdown
No language data available.
โ–ธ Files click to expand
README

๐Ÿ”Ž Public IP Address Lookup and Geolocation Information

Crates.io Documentation cargo build Crates.io License

Demo

public-ip-address is a simple Rust library for performing public IP lookups from over a dozen of various services.

It provides a unified interface to fetch public IP address and geolocation information from multiple providers. Arbitrary IP address lookup and access API keys are supported for certain providers. The library provides an asynchronous and blocking interfaces to make it easy to integrate with other async codebase.

The library also includes caching functionality to improve performance for repeated lookups and minimize reaching rate-limiting thresholds. The cache file can be encrypted when enabled through a feature flag for additional privacy.

Usage

Add the following to your Cargo.toml file:

[dependencies]
public-ip-address = { version = "0.4" }

with cache encryption enabled

public-ip-address = { version = "0.4", features = ["encryption"] }

with async disabled

public-ip-address = { version = "0.4", features = ["blocking"] }

for targets that do not support openssl

public-ip-address = { version = "0.4", default-features = false, features = ["rustls-tls"] }

Example

The simplest way to use this library is to call the perform_lookup() function, which returns a Result with a LookupResponse.

use std::error::Error;

#[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { // Perform my public IP address lookup let result = publicipaddress::perform_lookup(None).await?; println!("{}", result); Ok(()) }

With blocking interface enabled:

use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> { // Perform my public IP address lookup let result = publicipaddress::perform_lookup(None)?; println!("{}", result); Ok(()) }

More examples can be found in the examples directory. And run them with the following command:

cargo run --example <example_name>

Running the examples with the blocking feature enabled:

cargo run --example <example_name> --features blocking

Providers

| Provider | URL | Rate Limit | API Key | Target Lookup | | --- | --- | --- | --- | --- | | FreeIpApi | https://freeipapi.com | 60 / minute | โœ”๏ธ | โœ”๏ธ | | IfConfig | https://ifconfig.co | 1 / minute | | โœ”๏ธ | | IpInfo | https://ipinfo.io | 50000 / month | โœ”๏ธ | โœ”๏ธ | | MyIp | https://my-ip.io | ? / day | ๏ธ | ๏ธ | | IpApiCom | https://ip-api.com | 45 / minute | | โœ”๏ธ | | IpWhoIs | https://ipwhois.io | 10000 / month | ๏ธ | โœ”๏ธ | | IpApiCo | https://ipapi.co | 30000 / month | | โœ”๏ธ | | IpApiIo | https://ip-api.io | ? / day | โœ”๏ธ | โœ”๏ธ | | IpBase | https://ipbase.com | 10 / hour | โœ”๏ธ | โœ”๏ธ | | IpLocateIo | https://iplocate.io | 50 / day | โœ”๏ธ | โœ”๏ธ | | IpLeak | https://ipleak.net | ? / day | ๏ธ | โœ”๏ธ | | Mullvad | https://mullvad.net | ? / day | ๏ธ | ๏ธ | | AbstractApi | https://abstractapi.com | 1000 / day | โœ”๏ธ | โœ”๏ธ | | IpGeolocation | https://ipgeolocation.io | 1000 / day | โœ”๏ธ | โœ”๏ธ | | IpData | https://ipdata.co | 1500 / day | โœ”๏ธ | โœ”๏ธ | | Ip2Location | https://ip2location.io | 50000 / month | โœ”๏ธ | โœ”๏ธ | | MyIpCom | https://myip.com | unlimited | ๏ธ | ๏ธ | | GetJsonIp | https://getjsonip.com | unlimited | ๏ธ | ๏ธ | | Ipify | https://www.ipify.org | unlimited | ๏ธ | ๏ธ | | IpQuery | https://ipquery.io | unlimited | | โœ”๏ธ |

Roadmap

  • [x] Initial release
  • [x] Add more providers
  • [x] Add support for additional providers with API key
  • [x] Add reverse lookup feature
  • [x] Add asynchronous and synchronous interface support
  • [ ] Bulk lookup
  • [ ] Offline reverse lookup

License

Licensed under either of

  • Apache License, Version 2.0
(LICENSE-APACHE or )
  • MIT license
(LICENSE-MIT or )

at your option.

Contribution

Contributions are welcome! Please submit a pull request.

Support

If you encounter any problems or have any questions, please open an issue in the GitHub repository.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท ghztomash/public-ip-address ยท Updated daily from GitHub