pub struct Client { /* private fields */ }Expand description
Client for the ipdata.info IP geolocation, ASN, and threat-intelligence API.
Build one with Client::new (free tier) or Client::builder (to set
an API key, custom base URL, or timeout).
Implementations§
Source§impl Client
impl Client
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a client targeting the free tier with the default 10s timeout.
Examples found in repository?
6fn main() {
7 // Free tier — no API key needed. For higher limits + batch, get a free
8 // key at https://ipdata.info/register and use Client::builder().api_key("...").
9 let client = Client::new();
10
11 let info = client.lookup("8.8.8.8").expect("lookup failed");
12 println!(
13 "{} is in {:?}, {:?} (ASN {:?} — {:?})",
14 info.ip, info.city, info.country, info.asn, info.asn_org
15 );
16
17 let threat = client
18 .threat_domain("example.com")
19 .expect("threat lookup failed");
20 println!("example.com listed as a threat: {}", threat.listed);
21}Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Returns a ClientBuilder for configuring an API key, base URL, or
timeout.
Sourcepub fn lookup(&self, ip: &str) -> Result<IpInfo, Error>
pub fn lookup(&self, ip: &str) -> Result<IpInfo, Error>
Returns the full geolocation record for ip. Pass "" for the
caller’s own IP.
Examples found in repository?
6fn main() {
7 // Free tier — no API key needed. For higher limits + batch, get a free
8 // key at https://ipdata.info/register and use Client::builder().api_key("...").
9 let client = Client::new();
10
11 let info = client.lookup("8.8.8.8").expect("lookup failed");
12 println!(
13 "{} is in {:?}, {:?} (ASN {:?} — {:?})",
14 info.ip, info.city, info.country, info.asn, info.asn_org
15 );
16
17 let threat = client
18 .threat_domain("example.com")
19 .expect("threat lookup failed");
20 println!("example.com listed as a threat: {}", threat.listed);
21}Sourcepub fn batch(&self, ips: &[&str]) -> Result<Vec<IpInfo>, Error>
pub fn batch(&self, ips: &[&str]) -> Result<Vec<IpInfo>, Error>
Looks up many IPs in a single request. Requires an API key (paid
tier); anonymous requests receive 403.
Sourcepub fn asn_detail(&self, number: u32) -> Result<Value, Error>
pub fn asn_detail(&self, number: u32) -> Result<Value, Error>
Returns the detailed ASN record (prefixes, peering) as a raw JSON value; the shape is large and only loosely specified.
Sourcepub fn asn_whois_history(&self, number: u32) -> Result<Value, Error>
pub fn asn_whois_history(&self, number: u32) -> Result<Value, Error>
Returns the ASN whois history as a raw JSON value.
Sourcepub fn asn_changes(&self) -> Result<Value, Error>
pub fn asn_changes(&self) -> Result<Value, Error>
Returns the ASN change feed as a raw JSON value.
Sourcepub fn threat_domain(&self, domain: &str) -> Result<ThreatMatch, Error>
pub fn threat_domain(&self, domain: &str) -> Result<ThreatMatch, Error>
Looks up a domain in the threat-intel store.
Examples found in repository?
6fn main() {
7 // Free tier — no API key needed. For higher limits + batch, get a free
8 // key at https://ipdata.info/register and use Client::builder().api_key("...").
9 let client = Client::new();
10
11 let info = client.lookup("8.8.8.8").expect("lookup failed");
12 println!(
13 "{} is in {:?}, {:?} (ASN {:?} — {:?})",
14 info.ip, info.city, info.country, info.asn, info.asn_org
15 );
16
17 let threat = client
18 .threat_domain("example.com")
19 .expect("threat lookup failed");
20 println!("example.com listed as a threat: {}", threat.listed);
21}Sourcepub fn threat_hash(&self, hash: &str) -> Result<ThreatMatch, Error>
pub fn threat_hash(&self, hash: &str) -> Result<ThreatMatch, Error>
Looks up a file hash (md5/sha1/sha256) in the threat-intel store.
Sourcepub fn threat_url(&self, url: &str) -> Result<ThreatMatch, Error>
pub fn threat_url(&self, url: &str) -> Result<ThreatMatch, Error>
Looks up a URL in the threat-intel store (the server falls back to the URL’s domain on a miss).