Help us shape the future of Go! Take the 2026 Go Developer Survey

ipapi

package module
v0.0.0-...-069faf8 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 3 Imported by: 0

README

Wrapper ip-api.com

GoDoc Go Report Card

Golang wrapper for ip-api.com service

Install

Install the package with:

go get github.com/oashnic/ip-api-wrapper

Import it with:

import "github.com/oashnic/ip-api-wrapper"

and use ipapi as the package name inside the code.

Example

package main

import (
	"fmt"
	"gitlab.com/oashnic/ip-api-wrapper"
)

func main() {
	geo, err := GetLocation("8.8.8.8", LOCAL_ENGLISH)
    
	if err != nil {
		panic(err)
    }

	fmt.Println("AS: " + geo.AS)
}

Documentation

Index

Constants

View Source
const (
	LocalEnglish   string = "en"    // English localization
	LocalGerman    string = "de"    // German localization
	LocalSpanish   string = "es"    // Spanish localization
	LocalArgentina string = "pt-BR" // Argentina spanish localization
	LocalFrench    string = "fr"    // French localization
	LocalJapanese  string = "ja"    // Japanese localization
	LocalChinese   string = "zh-CN" // Chinese localization
	LocalRussia    string = "ru"    // Russia localization
)

All localization

Variables

This section is empty.

Functions

This section is empty.

Types

type DNS

type DNS struct {
	DNS struct {
		IP  string `json:"ip"`
		Geo string `json:"geo"`
	} `json:"dns"`
	Edns struct {
		IP  string `json:"ip"`
		Geo string `json:"geo"`
	} `json:"edns"`
}

DNS response struct

func GetDNS

func GetDNS() (DNS, error)

GetDNS get current dns servers

type Geolocation

type Geolocation struct {
	Query         string  `json:"query"`
	Status        string  `json:"status"`
	Continent     string  `json:"continent"`
	ContinentCode string  `json:"continentCode"`
	Country       string  `json:"country"`
	CountryCode   string  `json:"countryCode"`
	Region        string  `json:"region"`
	RegionName    string  `json:"regionName"`
	City          string  `json:"city"`
	District      string  `json:"district"`
	Zip           string  `json:"zip"`
	Lat           float64 `json:"lat"`
	Lon           float64 `json:"lon"`
	Timezone      string  `json:"timezone"`
	Currency      string  `json:"currency"`
	Isp           string  `json:"isp"`
	Org           string  `json:"org"`
	AS            string  `json:"as"`
	ASname        string  `json:"asname"`
	Reverse       string  `json:"reverse"`
	Mobile        bool    `json:"mobile"`
	Proxy         bool    `json:"proxy"`
}

Geolocation response struct

func GetLocation

func GetLocation(ip string, localization string) (Geolocation, error)

GetLocation get geolocation by IP in localization

Jump to

Keyboard shortcuts

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