Crate ipinfo[][src]

Expand description

IPinfo: The rust library to lookup IP address information

This is the Rust client library for the IPinfo.io IP address API. It allows you to lookup your own IP address, or get any of the following details for an IP:

  • IP geolocation (city, region, country, postal code, latitude and longitude)
  • ASN details (ISP or network operator, associated domain name, and type, such as business, hosting or company)
  • Company details (the name and domain of the business that uses the IP address)
  • Carrier details (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic)

Features

  • Smart LRU cache for cost and quota savings.
  • Structured and type checked query results.
  • Bulk IP address lookup using IPinfo batch API.

Example

use ipinfo::{IpInfo, IpInfoConfig};

fn main() {
  // Setup token and other configurations.
  let config = IpInfoConfig { token: Some("my token".to_string()), ..Default::default() };

  // Setup IpInfo structure and start looking up IP addresses.
  let mut ipinfo = IpInfo::new(config).expect("should construct");
  let res = ipinfo.lookup(&["8.8.8.8", "4.2.2.4"]);

  match res {
    Ok(r) => println!("{}: {}", "8.8.8.8", r["8.8.8.8"].hostname.as_ref().unwrap()),
    Err(e) => println!("error occurred: {}", &e.to_string()),
  }
}

Macros

Create a new error (of a given kind) with a formatted message

Structs

Abuse details.

ASN details.

Mobile carrier details.

Company details.

Domains details.

IP address lookup details.

The IpError type is the only error type that can be returned from this crate’s API.

IPinfo requests context structure.

IpInfo structure configuration.

Privacy details.

Enums

An enum of errors to represent the possible kinds of IpError.