Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	UserAgent string
	APIKey    string
	// contains filtered or unexported fields
}

Client represent the wrapper for ipdata.co

func NewClient

func NewClient(httpClient *http.Client) (*Client, error)

NewClient generates a new Client. If nil is passed, http.DefaultClient will be used.

func (*Client) GetIPData

func (c *Client) GetIPData(ip string) (*Data, error)

GetIPData retrieves information about the ip from ipdata.co and returns a valid Data if no error occurs.

func (*Client) GetMyIPData

func (c *Client) GetMyIPData() (*Data, error)

GetMyIPData retrieves information about your public IP address.

type Data

type Data struct {
	IP             string  `json:"ip"`
	City           string  `json:"city"`
	Region         string  `json:"region"`
	CountryName    string  `json:"country_name"`
	CountryCode    string  `json:"country_code"`
	ContinentName  string  `json:"continent_name"`
	ContinentCode  string  `json:"continent_code"`
	Latitude       float32 `json:"latitude"`
	Longitude      float32 `json:"longitude"`
	ASN            string  `json:"asn"`
	Organisation   string  `json:"organisation"`
	Postal         string  `json:"postal"`
	Currency       string  `json:"currency"`
	CurrencySymbol string  `json:"currency_symbol"`
	CallingCode    string  `json:"calling_code"`
	Flag           string  `json:"flag"`
	TimeZone       string  `json:"time_zone"`
	JSON           *string
}

Data represent the information retrieved from ipdata.com

Source Files