Rust SDK
neivi-iqx-lookup — Rust client for the IQX Lookup API using reqwest (blocking).
Installation
Add to your Cargo.toml:
[dependencies]
neivi-iqx-lookup = "0.2.1"
Quick Start
use iqx_lookup::IqxLookup;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = IqxLookup::builder()
.api_key("ALk-your-api-key")
.build()?;
// Validate an email
let email = client.validate_email("user@example.com")?;
println!("Valid format: {}", email.valid_format);
println!("Disposable: {}", email.disposable_email);
// Validate a phone number
let phone = client.validate_phone("+34912345678", Some("ES"))?;
println!("Valid: {}", phone.valid);
// Geolocate an IP
let ip = client.geolocate_ip(Some("8.8.8.8"))?;
println!("Country: {}", ip.country_name);
// Validate a VAT number
let vat = client.validate_vat("ES", "B87387775")?;
println!("Valid: {}", vat.valid);
// Parse a user-agent string
let ua = client.parse_user_agent(Some("Mozilla/5.0..."))?;
println!("Browser: {}", ua.browser_family);
Ok(())
}
Configuration
use std::time::Duration;
let client = IqxLookup::builder()
.api_key("ALk-your-api-key") // required
.base_url("https://api.iqxlookup.neivi.es") // optional
.timeout(Duration::from_secs(15)) // optional, default 10s
.build()?;
API Reference
All methods return Result<T, IqxLookupError>:
| Method | Returns | Description |
|---|---|---|
validate_email(&self, address) | EmailValidationResult | Email format, MX, disposable, free provider checks |
validate_phone(&self, number, country_code) | PhoneValidationResult | Phone validation (Option<&str>) |
geolocate_ip(&self, ip) | IpGeolocation | IP geolocation + ASN (None = caller's IP) |
validate_vat(&self, country_code, number) | VatValidationResult | EU VIES VAT validation |
parse_user_agent(&self, ua) | UserAgentResult | UA parsing — browser, OS, device brand & model |
validate_iban(&self, iban) | IbanValidationResult | IBAN structure, checksum, bank info |
validate_bic(&self, bic) | BicValidationResult | BIC/SWIFT format, institution info |
lookup_dns(&self, domain, types) | DnsLookupResult | DNS records, SPF/DKIM/DMARC security |
check_ssl(&self, domain) | SslCertificateResult | SSL certificate, chain, grade |
analyze_password(&self, password) | PasswordStrengthResult | Strength score, crack time, breach check |
validate_credit_card(&self, number) | CreditCardValidationResult | Luhn check, card network, BIN lookup |
last_rate_limit_info(&self) | Option<RateLimitInfo> | Rate limit from last response |
Error Handling
use iqx_lookup::IqxLookupError;
match client.validate_email("user@example.com") {
Ok(result) => println!("Valid: {}", result.valid_format),
Err(IqxLookupError::RateLimited { retry_after, .. }) => {
println!("Retry after: {}s", retry_after);
}
Err(IqxLookupError::Unauthorized { .. }) => {
println!("Check your API key");
}
Err(e) => eprintln!("Error: {}", e),
}
Error Variants
| Variant | HTTP Status | Description |
|---|---|---|
Unauthorized | 401 | Missing API key |
Forbidden | 403 | Invalid or inactive API key |
NotFound | 404 | Resource not found |
RateLimited | 429 | Rate limit exceeded (with retry_after, limit, remaining, reset) |
ServiceUnavailable | 503 | Service not configured |
Http | other | Generic HTTP error |
Request | — | Network/transport error |
Config | — | Builder configuration error |
Requirements
- Rust 2021 edition
- Dependencies:
reqwest(blocking),serde,serde_json,thiserror