Skip to content
Go library for IPInfo API
Go
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Initial commit Jun 4, 2019
ipinfo
LICENSE
README.md

README.md

IPinfo IPinfo Go Client Library

License GoDoc

This is the official Go client library for the IPinfo.io IP address API, allowing you to lookup your own IP address, or get any of the following details for an IP:

  • IP geolocation (city, region, country, postal code, latitude and longitude)
  • ASN details (ISP or network operator, associated domain name, and type, such as business, hosting or company)
  • Company details (the name and domain of the business that uses the IP address)
  • Carrier details (the name of the mobile carrier and MNC and MCC for that carrier if the IP is used exclusively for mobile traffic)

Getting Started

You'll need an IPinfo API access token, which you can get by singing up for a free account at https://ipinfo.io/signup.

The free plan is limited to 50,000 requests per month, and doesn't include some of the data fields such as IP type and company data. To enable all the data fields and additional request volumes see https://ipinfo.io/pricing

Installation

go get github.com/ipinfo/go-ipinfo/ipinfo

Quick Start

package main

import (
	"fmt"
	"log"
	"net"

	"github.com/ipinfo/go-ipinfo/ipinfo"
)

func main() {
	// Get access token by signing up a free account at https://ipinfo.io/signup
	authTransport := ipinfo.AuthTransport{Token: "MY_TOKEN"}
	httpClient := authTransport.Client()
	client := ipinfo.NewClient(httpClient)
	info, err := client.GetInfo(net.ParseIP("8.8.8.8"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(info)
	// &{{8.8.8.8 Mountain View California US 37.3860,-122.0840 650 94035} google-public-dns-a.google.com }
}

Other Libraries

There are official IPinfo client libraries available for many languages including PHP, Python, Go, Java, Ruby, and many popular frameworks such as Django, Rails and Laravel. There are also many third party libraries and integrations available for our API.

https://ipinfo.io/developers/libraries

About IPinfo

Founded in 2013, IPinfo prides itself on being the most reliable, accurate, and in-depth source of IP address data available anywhere. We process terabytes of data to produce our custom IP geolocation, company, carrier and IP type data sets. Our API handles over 12 billion requests a month for 100,000 businesses and developers.

image

You can’t perform that action at this time.