Ruby SDK · Feature

Fraud Detection & Risk Scoring in Ruby

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 ip_reputation 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. risk_score_ip 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 risk_score_ip

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

client = Ipapi::Client.new(api_key: ENV.fetch("IP_API_IO_KEY"))

risk = client.risk_score_ip("185.220.101.1")

puts risk.score      # 88
puts risk.risk_level # "high"
if risk.factors.ip
  puts "#{risk.factors.ip.tor_node?} #{risk.factors.ip.datacenter?}"
end

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

Score an email with email_risk_score

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

risk = client.email_risk_score("user@mailinator.com")

puts "#{risk.score} #{risk.risk_level}" # 90 high
puts risk.factors.email.disposable? if risk.factors.email # true
3

Raw signals with ip_reputation

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

reputation = client.ip_reputation("185.220.101.1")
puts reputation
Reference

Response reference

RiskScore (from risk_score_ip / email_risk_score)

MethodTypeDescription
scoreFloatRisk score, 0 (safe) – 100 (high risk)
risk_levelStringBucketed level, e.g. "low", "medium", "high"
ipString, nilScored IP (when applicable)
emailString, nilScored email (when applicable)
factorsRiskScoreFactorsip and/or email (nil when not applicable)

factors.ip: proxy?, vpn?, tor_node?, spam?, datacenter?, risk_contribution. factors.email: disposable?, valid_syntax?, risk_contribution.

FAQ

Frequently asked questions

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

Call client.risk_score_ip(ip). It returns a score from 0 (safe) to 100 (high risk), a human risk_level, and the factors that drove it. Use risk_score to score the caller's own IP.

Can I score an email address too?

Yes. client.email_risk_score(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 risk_score_ip and ip_reputation?

risk_score_ip gives you a computed 0–100 score and bucketed level you can act on directly. ip_reputation(ip) returns the underlying reputation record as a hash — 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 Ruby SDK

Run gem install ip-api-io, drop in your free API key, and ship in minutes — one client object 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 ip-api-io gem is open source. Open an issue or pull request on GitHub and we'll take a look.

Open on GitHub