Skip to content

Rust SDK

crates.io docs.rs GitHub

The IPWho Rust SDK wraps the IP geolocation API in idiomatic Rust — serde-backed structs with Option for nullable fields, Result-based error handling, and a single cargo add. One call returns the full payload: geolocation, timezone, currency, connection (ASN/ISP), security flags, and more.

Terminal window
cargo add ipwho-sdk

Tokio + reqwest. Client: IPWhoClient.

use ipwho_sdk::IPWhoClient;
let client = IPWhoClient::new(std::env::var("IPWHO_API_KEY")?)?;
let resp = client.lookup("8.8.8.8", None, None).await?; // GET /ip/{ip}
let me = client.me(None, None).await?; // GET /me
let bulk = client.bulk(&["8.8.8.8", "1.1.1.1"]).await?;
match client.lookup("8.8.8.8", None, None).await {
Ok(resp) => { /* use resp.data */ }
Err(IpWhoError::InvalidIP) => { /* malformed IP (404) */ }
Err(IpWhoError::RateLimitExceeded) => { /* plan limit (429) */ }
Err(e) => { /* APIResponseError or transport */ }
}
  • lookup(ip, fields, lang) — GET /ip/{ip} (async, returns Result<IpGeoResponse>)
  • me(fields, lang) — GET /me (async, returns Result<IpGeoResponse>)
  • bulk(ips) — GET /bulk/{a,b,c} (async)