Learn R Programming

geoChina (version 1.3.0)

geohost: IP address lookup

Description

geocodes an IP address using either freegeoip.net http://freegeoip.net or ipinfo.io http://ipinfo.io/developers IP lookup API.

Usage

geohost(ip = "", api = c("freegeoip.net", "ipinfo.io"))

Arguments

ip
a character vector specifying an IP (e.g., "12.215.42.19"). The default value is no IP is specified and the host IP is used.
api
use freegeoip.net or ipinfo.io IP lookup API. By default freegeoip.net is used.

Value

a vector with information of ip, country_code, country_name, region_code, city, zip_code, time_zone, latitude, longitude and metro_code for freegeoip.net API, of ip, hostname, city, region, country, loc, org, postal and phone for ipinfo.io IP lookup API. If numerous IPs are input, a data.frame is returned.

Details

note that freegeoip.net API is allowed up to 10,000 queries per hour by default, ipinfo API is limited to 1,000 requests per day.

See Also

geocode, revgeocode. freegeoip.net IP lookup API at http://freegeoip.net ipinfo.io IP lookup API at http://ipinfo.io/developers

Examples

Run this code
## Not run: ------------------------------------
# # geocode host IP
# geohost()
# geohost(api = "ipinfo.io")
# # specify an IP for geocoding
# geohost(ip = "12.215.42.19")
# geohost(ip = "12.215.42.19", api = "ipinfo.io")
# # geocode multiple IPs
# geohost(ip = c("61.135.169.81", "12.215.42.19"))
# geohost(ip = c("61.135.169.81", "12.215.42.19"), api = "ipinfo.io")
## ---------------------------------------------

Run the code above in your browser using DataLab