diff --git a/README.md b/README.md index 20c51a9..14a6094 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/ip2location/ip2location-go)](https://goreportcard.com/report/github.com/ip2location/ip2location-go) -IP2Location Go Package -====================== +# IP2Location Go Package This Go package provides a fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, usage type, address type and IAB category from IP address by using IP2Location database. This package uses a file based database available at IP2Location.com. This database simply contains IP blocks as keys, and other information such as country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, usage type, address type and IAB category as values. It supports both IP address in IPv4 and IPv6. @@ -20,16 +19,65 @@ The database will be updated in monthly basis for the greater accuracy. Free LIT The paid databases are available at https://www.ip2location.com under Premium subscription package. +As an alternative, this package can also call the IP2Location Web Service. This requires an API key. If you don't have an existing API key, you can subscribe for one at the below: -Installation -======= +https://www.ip2location.com/web-service/ip2location + +## Installation ``` go get github.com/ip2location/ip2location-go/v9 ``` -Example -======= +## QUERY USING THE BIN FILE + +## Dependencies + +This package requires IP2Location BIN data file to function. You may download the BIN data file at +* IP2Location LITE BIN Data (Free): https://lite.ip2location.com +* IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com + + +## IPv4 BIN vs IPv6 BIN + +Use the IPv4 BIN file if you just need to query IPv4 addresses. + +Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses. + + +## Methods + +Below are the methods supported in this package. + +|Method Name|Description| +|---|---| +|OpenDB|Initialize the package with the BIN file.| +|Get_all|Returns the geolocation information in an object.| +|Get_country_short|Returns the country code.| +|Get_country_long|Returns the country name.| +|Get_region|Returns the region name.| +|Get_city|Returns the city name.| +|Get_isp|Returns the ISP name.| +|Get_latitude|Returns the latitude.| +|Get_longitude|Returns the longitude.| +|Get_domain|Returns the domain name.| +|Get_zipcode|Returns the ZIP code.| +|Get_timezone|Returns the time zone.| +|Get_netspeed|Returns the net speed.| +|Get_iddcode|Returns the IDD code.| +|Get_areacode|Returns the area code.| +|Get_weatherstationcode|Returns the weather station code.| +|Get_weatherstationname|Returns the weather station name.| +|Get_mcc|Returns the mobile country code.| +|Get_mnc|Returns the mobile network code.| +|Get_mobilebrand|Returns the mobile brand.| +|Get_elevation|Returns the elevation in meters.| +|Get_usagetype|Returns the usage type.| +|Get_addresstype|Returns the address type.| +|Get_category|Returns the IAB category.| +|Close|Closes BIN file.| + +## Usage ```go package main @@ -82,20 +130,135 @@ func main() { } ``` -Dependencies -============ +## QUERY USING THE IP2LOCATION WEB SERVICE -The complete database is available at https://www.ip2location.com under subscription package. +## Methods +Below are the methods supported in this package. +|Method Name|Description| +|---|---| +|OpenWS| 3 input parameters:
  1. IP2Location API Key.
  2. Package (WS1 - WS25)
  3. Use HTTPS or HTTP
| +|LookUp|Query IP address. This method returns an object containing the geolocation info.