myip-foo
Official Rust client for myip.foo - a free, privacy-focused IP lookup API.
Features
- Async/await support with tokio
- Full type definitions with serde
- Dual-stack IPv4/IPv6 support
- Connection type detection
- No API key required
Installation
Add to your Cargo.toml:
[]
= "1.0"
= { = "1.0", = ["full"] }
Quick Start
use ;
async
API Reference
Functions
get_ip() -> Result<String>
Returns your IP address as plain text.
get_ip_data() -> Result<IpData>
Returns full IP data including geolocation.
get_dual_stack() -> Result<DualStackData>
Returns both IPv4 and IPv6 addresses using dedicated endpoints.
get_connection_type() -> Result<ConnectionTypeData>
Detects if connection is residential, VPN, or datacenter.
get_headers() -> Result<HashMap<String, String>>
Returns all HTTP headers as seen by the server.
get_user_agent() -> Result<String>
Returns your user agent string.
Types
Examples
Get Dual-Stack IPs
use get_dual_stack;
async
Check Connection Type
use get_connection_type;
async
Dual-Stack Endpoints
The get_dual_stack() function uses dedicated subdomains:
ipv4.myip.foo/ip- Returns IPv4 only (A record)ipv6.myip.foo/ip- Returns IPv6 only (AAAA record)
Privacy
myip.foo does not log IP addresses or use cookies. See Privacy Policy.
Links
- Website: myip.foo
- API Docs: myip.foo/api-docs
- GitHub: myip-packages
License
MIT License - see LICENSE for details.