Skip to content

evalphobia/ipqualityscore-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipqualityscore-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 IPQualityScore.

Quick Usage for API

package main

import (
	"fmt"

	"github.com/evalphobia/ipqualityscore-go/config"
	"github.com/evalphobia/ipqualityscore-go/ipqs"
)

func main() {
	conf := config.Config{
		// you can set auth values to config directly, otherwise used from environment variables.
		APIKey:   "<your API Key>",
		Debug:    false,
	}

	svc, err := ipqs.New(conf)
	if err != nil {
		panic(err)
	}

	// execute API
	resp, err := svc.IPReputation("8.8.8.8")
	if err != nil {
		panic(err)
	}
	if resp.HasError() {
		panic(fmt.Errorf("code=[%d] message=[%s]", resp.ErrData.StatusCode, 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
IPQS_APIKEY IPQualityScore API Key.