Documentation
¶
Overview ¶
Package ipinfo is the library behind the ipinfo command line: the HTTP client, request shaping, and typed data models for the ipinfo.io IP geolocation API (https://ipinfo.io/).
The basic tier (50k lookups/month) requires no API key. The Client paces requests, sets a real User-Agent, and retries transient failures (429 and 5xx).
Index ¶
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every API request is built from.
const DefaultUserAgent = "ipinfo-cli/0.1.0 (github.com/tamnd/ipinfo-cli)"
DefaultUserAgent identifies the client to ipinfo.io.
const Host = "ipinfo.io"
Host is the API hostname.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the ipinfo.io API.
func (*Client) BatchLookup ¶
BatchLookup fetches geolocation info for multiple IPs, sequentially.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type Domain ¶
type Domain struct{}
Domain is the ipinfo driver.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, hostnames, and binary identity.
type IPInfo ¶
type IPInfo struct {
IP string `kit:"id" json:"ip"`
Hostname string `json:"hostname"`
City string `json:"city"`
Region string `json:"region"`
Country string `json:"country"`
Lat string `json:"lat"` // first part of loc ("lat,lon")
Lon string `json:"lon"` // second part of loc ("lat,lon")
Org string `json:"org"`
Postal string `json:"postal"`
Timezone string `json:"timezone"`
}
IPInfo holds geolocation data for an IP address.