Swift SDK · Feature

Fraud Detection & Risk Scoring in Swift

Collapse every signal — geolocation, proxy/VPN/Tor flags, datacenter hosting, disposable email, syntax — into a single 0–100 risk score you can act on at sign-up, checkout, or login. Or pull the raw ipReputation record when you want to build your own rules.

Trusted by thousands of businesses
Fast JSON API responses
Real-time validation
Simple integration, SDKs & examples
What it does

One score from every signal

Individual flags are powerful, but acting on each one is fiddly. riskScore weighs geolocation, anonymizer flags, datacenter hosting, and email quality into a single number with a bucketed level, so you can make a block / review / allow decision in one comparison — and still drill into the contributing factors when you need to explain a decision.

Prerequisites

1

Score an IP with riskScore

Returns a score (0–100) and a human riskLevel, plus the factors that drove it. Use riskScore() for the caller's IP.

let client = IpApiClient(apiKey: ProcessInfo.processInfo.environment["IP_API_IO_KEY"]!)

let risk = try await client.riskScore(ip: "185.220.101.1")

print(risk.score)     // 88.0
print(risk.riskLevel) // "high"
if let ip = risk.factors.ip {
    print(ip.isTorNode, ip.isDatacenter)
}

if risk.score >= 75 {
    // block, or send to manual review / step-up auth
}
2

Score an email with emailRiskScore

Same 0–100 scale, driven by email signals (disposable provider, invalid syntax). Use it to grade leads or gate sign-ups by address quality.

let risk = try await client.emailRiskScore(email: "user@mailinator.com")

print(risk.score, risk.riskLevel) // 90.0 high
if let email = risk.factors.email {
    print(email.isDisposable) // true
}
3

Raw signals with ipReputation

Returns the underlying reputation data for an IP — use it when you want the source signals rather than a computed score.

let reputation = try await client.ipReputation(ip: "185.220.101.1")
print(reputation)
Reference

Response reference

RiskScore (from riskScore / emailRiskScore)

FieldTypeDescription
scoreDoubleRisk score, 0 (safe) – 100 (high risk)
riskLevelStringBucketed level, e.g. "low", "medium", "high"
ipString?Scored IP (when applicable)
emailString?Scored email (when applicable)
factorsRiskScoreFactorsip and/or email (optional)

factors.ip: isProxy, isVpn, isTorNode, isSpam, isDatacenter, riskContribution. factors.email: isDisposable, isValidSyntax, riskContribution.

FAQ

Frequently asked questions

How do I score an IP for fraud risk in Swift?

Call try await client.riskScore(ip: ip). It returns a score from 0 (safe) to 100 (high risk), a human riskLevel, and the factors that drove it. Use riskScore() to score the caller's own IP.

Can I score an email address too?

Yes. try await client.emailRiskScore(email: email) returns the same 0–100 scale driven by email signals such as disposable provider and invalid syntax — use it to grade leads or gate sign-ups by address quality.

What's the difference between riskScore and ipReputation?

riskScore gives you a computed 0–100 score and bucketed level you can act on directly. ipReputation(ip:) returns the underlying reputation record — use it when you want the source signals to build your own rules.

What threshold should I block at?

A common pattern is to allow low scores, send medium scores to step-up verification, and block or manually review high scores (e.g. risk.score >= 75). Tune the cutoffs to your own fraud tolerance and false-positive budget.

Start building with the ip-api.io Swift SDK

Add ipapi-swift via Swift Package Manager, drop in your free API key, and ship in minutes — one async client for geolocation, fraud detection, and email validation.

Need support?

Explore how IP-API.io can enhance your security, provide robust bot protection, and improve IP geolocation accuracy for your applications.

Contact Support

Found a bug in the SDK?

The ipapi-swift package is open source. Open an issue or pull request on GitHub and we'll take a look.

Open on GitHub