Prerequisites
- A Swift 5.9+ project with
ipapi-swiftadded - A free ip-api.io API key
Read suspiciousFactors on any lookup
No dedicated call needed — the fields ride along with a normal lookup.
let client = IpApiClient(apiKey: ProcessInfo.processInfo.environment["IP_API_IO_KEY"]!)
let info = try await client.lookup(ip: "185.220.101.1")
let f = info.suspiciousFactors
print(f.isVpn) // VPN service
print(f.isProxy) // open / anonymizing proxy
print(f.isTorNode) // Tor node
print(f.isDatacenter) // hosting / datacenter IP (often a bot)
print(f.isSpam) // known spam source
print(f.isCrawler) // known crawler / bot
print(f.isThreat) // listed on a threat feed
if f.isVpn || f.isProxy || f.isTorNode {
// require step-up verification (CAPTCHA, 2FA)
} Confirm a Tor exit node with torCheck
A dedicated check against the live Tor node list, with a count of matching nodes.
let tor = try await client.torCheck(ip: "185.220.101.1")
print(tor.isTor) // true
print(tor.torNodeCount) // number of matching Tor nodes riskScore(ip:).