Zum Hauptinhalt springen

Go SDK

github.com/Neivi-IT/iqx-lookup-go — Go 1.21+ client for the IQX Lookup API using net/http (zero dependencies).

Installation

go get github.com/Neivi-IT/iqx-lookup-go

Quick Start

package main

import (
"context"
"fmt"
"log"

iqxlookup "github.com/Neivi-IT/iqx-lookup-go"
)

func main() {
client := iqxlookup.New("ALk-your-api-key")
ctx := context.Background()

// Validate an email
email, err := client.ValidateEmail(ctx, "user@example.com")
if err != nil {
log.Fatal(err)
}
fmt.Println("Valid format:", email.ValidFormat)
fmt.Println("Disposable:", email.DisposableEmail)

// Validate a phone number
phone, err := client.ValidatePhone(ctx, "+34912345678", "ES")
if err != nil {
log.Fatal(err)
}
fmt.Println("Valid:", phone.Valid)

// Geolocate an IP
ip, err := client.GeolocateIP(ctx, "8.8.8.8")
if err != nil {
log.Fatal(err)
}
fmt.Println("Country:", ip.CountryName)

// Validate a VAT number
vat, err := client.ValidateVat(ctx, "ES", "B87387775")
if err != nil {
log.Fatal(err)
}
fmt.Println("Valid:", vat.Valid)

// Parse a user-agent string
ua, err := client.ParseUserAgent(ctx, "Mozilla/5.0...")
if err != nil {
log.Fatal(err)
}
fmt.Println("Browser:", ua.BrowserFamily)
}

Configuration

import "time"

// With options
client := iqxlookup.New("ALk-your-api-key",
iqxlookup.WithBaseURL("https://api.iqxlookup.neivi.es"), // optional
iqxlookup.WithTimeout(15 * time.Second), // optional, default 10s
)

API Reference

All methods take context.Context as the first parameter and return (result, error):

MethodReturnsDescription
ValidateEmail(ctx, address)*EmailValidationResultEmail format, MX, disposable, free provider checks
ValidatePhone(ctx, number, countryCode)*PhoneValidationResultPhone validation (empty countryCode = omit)
GeolocateIP(ctx, ip)*IPGeolocationIP geolocation + ASN (empty ip = caller's IP)
ValidateVat(ctx, countryCode, number)*VatValidationResultEU VIES VAT validation
ParseUserAgent(ctx, ua)*UserAgentResultUA parsing — browser, OS, device brand & model
ValidateIban(ctx, iban)*IbanValidationResultIBAN structure, checksum, bank info
ValidateBic(ctx, bic)*BicValidationResultBIC/SWIFT format, institution info
LookupDns(ctx, domain, types)*DnsLookupResultDNS records, SPF/DKIM/DMARC security
CheckSsl(ctx, domain)*SslCertificateResultSSL certificate, chain, grade
AnalyzePassword(ctx, password)*PasswordStrengthResultStrength score, crack time, breach check
ValidateCreditCard(ctx, number)*CreditCardValidationResultLuhn check, card network, BIN lookup
LastRateLimitInfo()*RateLimitInfoRate limit from last response

Error Handling

Use errors.As for typed error checking:

import "errors"

email, err := client.ValidateEmail(ctx, "user@example.com")
if err != nil {
var rateLimitErr *iqxlookup.RateLimitError
var unauthorizedErr *iqxlookup.UnauthorizedError

if errors.As(err, &rateLimitErr) {
fmt.Printf("Retry after: %ds\n", rateLimitErr.RetryAfter)
} else if errors.As(err, &unauthorizedErr) {
fmt.Println("Check your API key")
} else {
fmt.Println("Error:", err)
}
}

Requirements

  • Go 1.21+
  • Zero external dependencies (uses net/http from stdlib)