ipapico

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const StandardURL = "https://ipapi.co"

Primary URL.

Variables

View Source
var (
	ErrReservedRange = errors.New("reserved ip address")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	GetLocationForIP(ctx context.Context, ip string) (*Location, error)
}

func NewClient

func NewClient() Client

func NewClientWithAPIKey

func NewClientWithAPIKey(apiKey string) Client

type Location

type Location struct {
	IP                 string  `json:"ip"`
	City               string  `json:"city"`
	Region             string  `json:"region"`
	RegionCode         string  `json:"region_code"`
	Country            string  `json:"country"`
	CountryName        string  `json:"country_name"`
	ContinentCode      string  `json:"continent_code"`
	InEu               bool    `json:"in_eu"`
	Postal             string  `json:"postal"`
	Latitude           float32 `json:"latitude"`
	Longitude          float32 `json:"longitude"`
	Timezone           string  `json:"timezone"`
	UtcOffset          string  `json:"utc_offset"`
	CountryCallingCode string  `json:"country_calling_code"`
	Currency           string  `json:"currency"`
	Languages          string  `json:"languages"`
	Asn                string  `json:"asn"`
	Org                string  `json:"org"`
	IsError            bool    `json:"error"`
	Reason             string  `json:"reason"`
}

Location contains all the relevant data for an IP.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL