Skip to content

Swift SDK

Swift SPM

The IPWho Swift SDK wraps the IP geolocation API in idiomatic Swift — Codable response structs, structured error throwing, and zero-dependency SPM installation. One call returns the full payload: geolocation, timezone, currency, connection (ASN/ISP), security flags, and more.

Xcode: File → Add Package Dependencies…

https://github.com/lavrox/SDK-IPWho-IP-Geolocation-Swift
.package(url: "https://github.com/lavrox/SDK-IPWho-IP-Geolocation-Swift.git", from: "1.0.0")

Swift 5.9+.

import IPWho
let client = IPWhoClient(apiKey: ProcessInfo.processInfo.environment["IPWHO_API_KEY"] ?? "")
let resp = try await client.lookup(ip: "8.8.8.8") // GET /ip/{ip}
let me = try await client.me() // GET /me
let bulk = try await client.bulk(ips: ["8.8.8.8", "1.1.1.1"])
do {
let resp = try await client.lookup(ip: "8.8.8.8")
} catch let error as IPWhoError {
switch error {
case .invalidIP:
// malformed IP address (404)
case .rateLimitExceeded:
// plan limit reached (429)
case .apiError(let message):
// unexpected response
}
}
  • lookup(ip:) — GET /ip/{ip} (async throws)
  • me() — GET /me (async throws)
  • bulk(ips:) — GET /bulk/{a,b,c} (async throws)