Unofficial golang library for Ipregistry.
package main
import (
"fmt"
"github.com/evalphobia/ipregistry-go/config"
"github.com/evalphobia/ipregistry-go/ipregistry"
)
func main() {
conf := config.Config{
// you can set auth values to config directly, otherwise used from environment variables.
APIKey: "<your Ipregistry API Key>",
Debug: false,
}
svc, err := ipregistry.New(conf)
if err != nil {
panic(err)
}
// execute score API
resp, err := svc.SingleIP("8.8.8.8")
if err != nil {
panic(err)
}
if resp.HasError() {
panic(fmt.Errorf("code=[%s] message=[%s]", resp.ErrData.Code, resp.ErrData.Message))
}
// just print response in json format
b, _ := json.Marshal(resp)
fmt.Printf("%s", string(b))
}
see example dir for more examples, and see official API document for more details (especially request/response).
Name | Description |
---|---|
IPREGISTRY_APIKEY |
Ipregistry API Key. |