Prerequisites
- Go 1.21+ with
ipapi-goinstalled - A free ip-api.io API key
Score an IP with RiskScoreIP
Returns a Score (0–100) and a human RiskLevel, plus the
Factors that drove it. Use RiskScore(ctx) for the caller's IP.
client := ipapi.NewClient(ipapi.WithAPIKey(os.Getenv("IP_API_IO_KEY")))
ctx := context.Background()
risk, err := client.RiskScoreIP(ctx, "185.220.101.1")
if err != nil {
log.Fatal(err)
}
fmt.Println(risk.Score) // 88
fmt.Println(risk.RiskLevel) // "high"
if risk.Factors.IPFactors != nil {
fmt.Println(risk.Factors.IPFactors.IsTorNode, risk.Factors.IPFactors.IsDatacenter)
}
if risk.Score >= 75 {
// block, or send to manual review / step-up auth
} 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.
risk, _ := client.EmailRiskScore(ctx, "user@mailinator.com")
fmt.Println(risk.Score, risk.RiskLevel) // 90 high
if risk.Factors.EmailFactors != nil {
fmt.Println(risk.Factors.EmailFactors.IsDisposable) // true
} Raw signals with IPReputation
Returns the underlying reputation data for an IP as a map[string]any — use
it when you want the source signals rather than a computed score.
reputation, _ := client.IPReputation(ctx, "185.220.101.1")
fmt.Println(reputation)