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

Overview

๐Ÿ”Ž 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.3" }

# with cache encryption enabled
public-ip-address = { version = "0.3", features = ["encryption"] }

# with `async` disabled
public-ip-address = { version = "0.3", features = ["blocking"] }

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 = public_ip_address::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 = public_ip_address::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 500 / day (with key 30000 / month) โœ”๏ธ โœ”๏ธ
MyIpCom https://myip.com unlimited ๏ธ ๏ธ
GetJsonIp https://getjsonip.com unlimited ๏ธ ๏ธ
Ipify https://www.ipify.org unlimited ๏ธ ๏ธ

Roadmap

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

License

Licensed under either of

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.

Comments
  • Support IP2Location.io API

    Support IP2Location.io API

    You are currently supporting 15 IP geolocation API.

    I would like to introduce you the IP2Location.io API which is free (500 queries per day tokenless, or 30,000 queries per month using token upon registration).

    https://www.ip2location.io

    Kindly ping me if you need further assistance about the API.

    enhancement 
    opened by ip2location 1
  • Convert async

    Convert async

    Description

    Motivation and Context

    Types of Changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [x] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [x] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [ ] My code follows the code style of this project.
    • [x] I have updated the documentation accordingly.
    • [x] I have formatted the code with rustfmt.
    • [x] I checked the lints with clippy.
    • [x] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
    enhancement 
    opened by ghztomash 0
  • bump version

    bump version

    Description

    Motivation and Context

    Types of Changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [ ] My code follows the code style of this project.
    • [ ] I have updated the documentation accordingly.
    • [ ] I have formatted the code with rustfmt.
    • [ ] I checked the lints with clippy.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by ghztomash 0
  • feat: cache target lookups as binary tree map

    feat: cache target lookups as binary tree map

    Description

    Motivation and Context

    Types of Changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [ ] My code follows the code style of this project.
    • [ ] I have updated the documentation accordingly.
    • [ ] I have formatted the code with rustfmt.
    • [ ] I checked the lints with clippy.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by ghztomash 0
  • feat: reverse target lookup

    feat: reverse target lookup

    Description

    Adds possibility to look up arbitrary addresses

    Motivation and Context

    Types of Changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [x] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [x] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [x] My code follows the code style of this project.
    • [x] I have updated the documentation accordingly.
    • [x] I have formatted the code with rustfmt.
    • [x] I checked the lints with clippy.
    • [x] I have added tests to cover my changes.
    • [x] All new and existing tests passed.
    opened by ghztomash 0
  • feat: support IP2Location.io API closes #5

    feat: support IP2Location.io API closes #5

    Description

    Adds support for IP2Location.io API

    Motivation and Context

    https://github.com/ghztomash/public-ip-address/issues/5

    Types of Changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [ ] My code follows the code style of this project.
    • [ ] I have updated the documentation accordingly.
    • [ ] I have formatted the code with rustfmt.
    • [ ] I checked the lints with clippy.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by ghztomash 0
  • refactor: cache module

    refactor: cache module

    Description

    Motivation and Context

    Types of Changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [x] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [x] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [ ] My code follows the code style of this project.
    • [ ] I have updated the documentation accordingly.
    • [ ] I have formatted the code with rustfmt.
    • [ ] I checked the lints with clippy.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by ghztomash 0
  • feat: add iplocate.io provider

    feat: add iplocate.io provider

    Description

    Motivation and Context

    Types of Changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [ ] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [ ] My code follows the code style of this project.
    • [ ] I have updated the documentation accordingly.
    • [ ] I have formatted the code with rustfmt.
    • [ ] I checked the lints with clippy.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by ghztomash 0
  • doc: add example using provider directtly

    doc: add example using provider directtly

    Description

    Motivation and Context

    Types of Changes

    • [ ] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] Breaking change (fix or feature that would cause existing functionality to change)
    • [x] Documentation (no code change)
    • [ ] Refactor (refactoring production code)
    • [ ] Other

    Checklist:

    • [ ] My code follows the code style of this project.
    • [ ] I have updated the documentation accordingly.
    • [ ] I have formatted the code with rustfmt.
    • [ ] I checked the lints with clippy.
    • [ ] I have added tests to cover my changes.
    • [ ] All new and existing tests passed.
    opened by ghztomash 0
Releases(v0.3.2)
  • v0.3.2(Apr 25, 2024)

    [0.3.2] - 2024-04-25

    ๐Ÿš€ Features

    • Return error if provider does not support target lookup

    โš™๏ธ Miscellaneous Tasks

    • Remove inline
    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Apr 25, 2024)

  • v0.3.0(Apr 25, 2024)

    [0.3.0] - 2024-04-25

    ๐Ÿš€ Features

    • Add ProviderRepsponse trait
    • Provide cache file name
    • Maybe async feature flag

    ๐Ÿšœ Refactor

    • Provider trait
    • Remove make_api_request from Provider trait

    ๐Ÿ“š Documentation

    • Update doc tests
    • Update documentation for async
    • Update documentation for blocking feature
    • Add blocking example

    โš™๏ธ Miscellaneous Tasks

    • Remove changelog workflow
    • Update dev dependencies
    • Run basic example in ci
    • Move integration tests to separate module
    Source code(tar.gz)
    Source code(zip)
  • v0.2.2(Apr 19, 2024)

    [0.2.2] - 2024-04-19

    ๐Ÿš€ Features

    • Encryption feature flag
    • Inject logging

    ๐Ÿ“š Documentation

    • Update documentation for cache encryption

    โš™๏ธ Miscellaneous Tasks

    • Add publish and changelog workflows
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Apr 10, 2024)

    What's Changed

    • refactor: cache module by @ghztomash in https://github.com/ghztomash/public-ip-address/pull/6
    • feat: support IP2Location.io API closes #5 by @ghztomash in https://github.com/ghztomash/public-ip-address/pull/7
    • feat: reverse target lookup by @ghztomash in https://github.com/ghztomash/public-ip-address/pull/8
    • feat: cache target lookups as binary tree map by @ghztomash in https://github.com/ghztomash/public-ip-address/pull/9

    Full Changelog: https://github.com/ghztomash/public-ip-address/compare/v0.1.1...v0.2.0

    Source code(tar.gz)
    Source code(zip)
  • v0.1.1(Apr 3, 2024)

    [0.1.1] - 2024-04-03

    ๐Ÿš€ Features

    • Add iplocate.io provider (#4)
    • Add ipleak.net provider
    • Add mullvad.net provider
    • Add abstractapi.com provider with API key
    • Add ipgeolocation.io provider
    • Add ipdata.co provider

    ๐Ÿ“š Documentation

    • Add git cliff
    • Add readme badges
    • Add example using provider directly (#3)
    • Update map example

    โš™๏ธ Miscellaneous Tasks

    • Bump reqwest version
    • Updates rusty-hook config
    • Update pr template
    • Update ci/cd workflows
    • Typos config
    Source code(tar.gz)
    Source code(zip)
Owner
Tomash Ghz
Record collector, modular enthusiast and designer of electronic instruments.
Tomash Ghz
Zei is a library that provide tools to create and verify public transaction with confidential data.

#Zei: Findora's Cryptographic Library Zei is a library that provide tools to create and verify public transaction with confidential data. Support: Bas

Findora Foundation 0 Oct 23, 2022
A guide for Mozilla's developers and data scientists to analyze and interpret the data gathered by our data collection systems.

Mozilla Data Documentation This documentation was written to help Mozillians analyze and interpret data collected by our products, such as Firefox and

Mozilla 75 Dec 1, 2022
Nostr Vanity Address Generator (Windows, Linux and macOS)

Nostr Vanity Address Generator CLI tool to generate vanity addresses for Nostr Usage Download the latest release built by GitHub CI from the releases

Chawye Hsu 7 Mar 1, 2023
Custom Ethereum vanity address generator made in Rust

ethaddrgen Custom Ethereum address generator Get a shiny ethereum address and stand out from the crowd! Disclaimer: Do not use the private key shown i

Jakub Hlusiฤka 153 Dec 27, 2022
A bitcoin vanity address generator written with the Rust programming language.

btc-vanity A bitcoin vanity address generator written with the Rust programming language. With btc-vanity you can create a private key which has a com

Emirhan TALA 22 Aug 7, 2023
Generate Nice Solana Address By Template

Yes, I know about GPU generators. https://smith-mcf.medium.com/solana-vanity-address-using-gpus-5a68ad94d1d4 ./solana-nice-address --help solana-nice-

Kirill Fomichev 18 Jun 18, 2022
Radix Babylon vanity address finder allowing easy import into Radix mobile Wallet.

Rad Vanity address finder for Radix Babylon which you can import directly into your Radix Wallet using QR scanner using Import from a Legacy Wallet fe

Alexander Cyon 6 Nov 13, 2023
The Zero Knowledge Whitelist Tool is a powerful utility for managing an address whitelist using Zero-Knowledge (ZK) proofs.

zk_whitelist: A Zero Knowledge Whitelist Tool The Zero Knowledge Whitelist Tool is a powerful utility for managing an address whitelist using Zero-Kno

Nikos Koumbakis 4 Nov 21, 2023
The Nervos CKB is a public permissionless blockchain, and the layer 1 of Nervos network.

Nervos CKB - The Common Knowledge Base master develop About CKB CKB is the layer 1 of Nervos Network, a public/permissionless blockchain. CKB uses Pro

Nervos Network 1k Dec 30, 2022
The public source and documentation for Xenon iOS tweak.

THE GUIDE HAS BEEN MOVED TO THE WIKI This is the public source for the Xenon iOS tweak. The full version is available for $1.99 on Chariz. Differences

aspen 1 Dec 28, 2022
Manage secret values in-repo via public key cryptography

amber Manage secret values in-repo via public key cryptography. See the announcement blog post for more motivation. Amber provides the ability to secu

FP Complete 82 Nov 10, 2022
Composable proof transcripts for public-coin arguments of knowledge

Merlin: composable proof transcripts for public-coin arguments of knowledge Merlin is a STROBE-based transcript construction for zero-knowledge proofs

dalek cryptography 99 Dec 22, 2022
The Hybrid Public Key Encryption (HPKE) standard in Python

Hybrid PKE The Hybrid Public Key Encryption (HPKE) standard in Python. hybrid_pke = hpke-rs โž• PyO3 This library provides Python bindings to the hpke-r

Cape Privacy 4 Nov 7, 2022
reth-indexer reads directly from the reth db and indexes the data into a postgres database all decoded with a simple config file and no extra setup alongside exposing a API ready to query the data.

reth-indexer reth-indexer reads directly from the reth db and indexes the data into a postgres database all decoded with a simple config file and no e

Josh Stevens 306 Jul 12, 2023
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Dec 30, 2022
Demonstrates Solana data account versioning used in supporting the Solana Cookbook article: Account Data Versioning

versioning-solana This repo demonstrates ONE rudimentary way to upgrade/migrate account data changes with solana program changes. What is data version

Frank V. Castellucci 6 Sep 30, 2022
Library with support for de/serialization, parsing and executing on data-structures and network messages related to Bitcoin

Rust Bitcoin Library with support for de/serialization, parsing and executing on data-structures and network messages related to Bitcoin. Heads up for

Rust Bitcoin Community 1.3k Dec 29, 2022
โ‹ฐยทโ‹ฐ Feeless is a Nano cryptocurrency node, wallet, tools, and Rust crate.

โ‹ฐยทโ‹ฐ Feeless What is Feeless? Feeless is a Nano cryptocurrency node, wallet, tools, and Rust crate. This is not the official project for Nano, only an

null 127 Dec 5, 2022
`llm-chain` is a powerful rust crate for building chains in large language models allowing you to summarise text and complete complex tasks

llm-chain ?? llm-chain is a collection of Rust crates designed to help you work with Large Language Models (LLMs) more effectively. Our primary focus

Sobel IO 36 Apr 6, 2023