Skip to content

evalphobia/ipregistry-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipregistry-go

License: MIT GoDoc Release Build Status Coveralls Coverage Codecov Coverage Go Report Card Code Climate BCH compliance CodeFactor codebeat Scrutinizer Code Quality FOSSA Status

Unofficial golang library for Ipregistry.

Quick Usage for API

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).

Environment variables

Name Description
IPREGISTRY_APIKEY Ipregistry API Key.