From a5d1eca88e954e58c773046d2f03d88dfee4bbc7 Mon Sep 17 00:00:00 2001 From: ip2location Date: Fri, 10 Nov 2023 15:20:48 +0800 Subject: [PATCH] Update README.md --- README.md | 500 +----------------------------------------------------- 1 file changed, 3 insertions(+), 497 deletions(-) diff --git a/README.md b/README.md index 85a1730..c752e82 100644 --- a/README.md +++ b/README.md @@ -22,501 +22,7 @@ The paid databases are available at https://www.ip2location.com under Premium su 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: https://www.ip2location.com/web-service/ip2location +Developer Documentation +===================== -## Installation - -``` -go get github.com/ip2location/ip2location-go/v9 -``` - -## 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.| -|Get_district|Returns the district name.| -|Get_asn|Returns the autonomous system number (ASN).| -|Get_as|Returns the autonomous system (AS).| -|Close|Closes BIN file.| - -## Usage - -```go -package main - -import ( - "fmt" - "github.com/ip2location/ip2location-go/v9" -) - -func main() { - db, err := ip2location.OpenDB("./IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY-DISTRICT-ASN.BIN") - - if err != nil { - fmt.Print(err) - return - } - ip := "8.8.8.8" - results, err := db.Get_all(ip) - - if err != nil { - fmt.Print(err) - return - } - - fmt.Printf("country_short: %s\n", results.Country_short) - fmt.Printf("country_long: %s\n", results.Country_long) - fmt.Printf("region: %s\n", results.Region) - fmt.Printf("city: %s\n", results.City) - fmt.Printf("isp: %s\n", results.Isp) - fmt.Printf("latitude: %f\n", results.Latitude) - fmt.Printf("longitude: %f\n", results.Longitude) - fmt.Printf("domain: %s\n", results.Domain) - fmt.Printf("zipcode: %s\n", results.Zipcode) - fmt.Printf("timezone: %s\n", results.Timezone) - fmt.Printf("netspeed: %s\n", results.Netspeed) - fmt.Printf("iddcode: %s\n", results.Iddcode) - fmt.Printf("areacode: %s\n", results.Areacode) - fmt.Printf("weatherstationcode: %s\n", results.Weatherstationcode) - fmt.Printf("weatherstationname: %s\n", results.Weatherstationname) - fmt.Printf("mcc: %s\n", results.Mcc) - fmt.Printf("mnc: %s\n", results.Mnc) - fmt.Printf("mobilebrand: %s\n", results.Mobilebrand) - fmt.Printf("elevation: %f\n", results.Elevation) - fmt.Printf("usagetype: %s\n", results.Usagetype) - fmt.Printf("addresstype: %s\n", results.Addresstype) - fmt.Printf("category: %s\n", results.Category) - fmt.Printf("district: %s\n", results.District) - fmt.Printf("asn: %s\n", results.Asn) - fmt.Printf("as: %s\n", results.As) - fmt.Printf("api version: %s\n", ip2location.Api_version()) - - db.Close() -} -``` - -## QUERY USING THE IP2LOCATION WEB SERVICE - -## 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.