geohost: IP address lookup

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/geohost.R

Description

geocodes an IP address using either ipify.org (https://www.ipify.org), ipstack.com (https://ipstack.com) or ipinfo.io (http://ipinfo.io/developers) IP lookup API.

Usage

1
2
3
geohost(ip = "", api = c("ipinfo", "ipify", "ipstack"),
  output = c("country", "region", "city", "all", "raw"),
  use_curl = FALSE, time = 0, key = NULL)

Arguments

ip

a character vector specifying IPs (IPv4 or IPv6) (e.g., "12.215.42.19"). The default value is no IP is specified and the host IP is used.

api

use 'ipify' (ipify.org), 'ipstack' (ipstack.com) or 'ipinfo'(ipinfo.io) lookup API. By default 'ipinfo' is used.

output

character, 'country', 'region', 'city', 'all' or 'raw'. It decides which columns to return in the output data.frame.

  • 'country': ip and country

  • 'region': ip, region and country

  • 'city': ip, city, region and country

  • 'all': all the info

  • 'raw': the raw JSON list. You can then apply parse_geohosts to process the list for structured data.

use_curl

logical, whether use curl to access the APIs. Default FALSE.

time

numeric, time interval to lookup the IP address, by seconds. It is used to avoid overuse of the APIs. Default 0.

key

character, the api key for ipinfo or ipstack. Default NULL, which indicates that the function will try to find it in cache. When no match is found, a GUI wizard will be launched for you to enter the key. If the API does not call for a key, set it to NA.

Details

note that ipstack.com API is allowed up to 10,000 queries per month by default, ipinfo API is limited to 1,000 requests per day, and ipify.org API is limited to 1,000 requests per month.

Value

a data.frame.

Author(s)

Jun Cai (cai-j12@mails.tsinghua.edu.cn), PhD student from Center for Earth System Science, Tsinghua University
Yiying Wang (wangy@aetna.com)

References

See Also

geocode, revgeocode, parse_geohosts.

synthesize_ipinfo_api(), synthesize_ipify_api(), synthesize_ipstack_api()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
# geocode host IP
geohost()
geohost(api = "ipinfo")

# specify an IP for geocoding
geohost(ip = "12.215.42.19")
geohost(ip = "12.215.42.19", api = "ipinfo")

# 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")

## End(Not run)

madlogos/asesgeo documentation built on Aug. 9, 2019, 9:53 a.m.