quickstart/quickstart.rs
1//! Quickstart example for the ipdata.info Rust SDK.
2//! Run: cargo run --example quickstart
3
4use ipdatainfo::Client;
5
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}