Skip to content

Go SDK

Go module

The IPWho Go SDK wraps the IP geolocation API in idiomatic Go — typed structs with pointer-based optional fields, standard-library HTTP, and no extra registry. One call returns the full payload: geolocation, timezone, currency, connection (ASN/ISP), security flags, and more.

Terminal window
go get github.com/lavrox/SDK-IPWho-IP-Geolocation-Go

Go 1.21+. Stdlib only.

client, err := ipwho.NewClient(os.Getenv("IPWHO_API_KEY"))
resp, err := client.Lookup("8.8.8.8", nil) // GET /ip/{ip}
me, err := client.Me(nil) // GET /me
bulk, err := client.Bulk([]string{"8.8.8.8", "1.1.1.1"}, nil) // []IpGeoResponse

Optional JSON fields are pointers — check before dereference.

fmt.Println(*resp.Data.GeoLocation.Country) // United States
resp, err := client.Lookup("8.8.8.8", nil)
if err != nil {
var invalidErr *ipwho.InvalidIPError
var rateErr *ipwho.RateLimitError
switch {
case errors.As(err, &invalidErr):
// malformed IP address (404)
case errors.As(err, &rateErr):
// plan limit reached (429)
default:
// APIResponseError or other
}
}
  • Lookup(ip string, opts *LookupOptions) (*IpGeoResponse, error) — GET /ip/{ip}
  • Me(opts *MeOptions) (*IpGeoResponse, error) — GET /me
  • Bulk(ips []string, opts *BulkOptions) ([]IpGeoResponse, error) — GET /bulk/{a,b,c}