get_api_data: Get data from given API URL(s)

Description Usage Arguments Value Author(s) Examples

Description

Get data from given API URL(s)

Usage

1
2
3
4
get_api_data(api_urls, use_curl = TRUE, parse_json = TRUE, time = 0,
  encoding = NULL, messaging = FALSE, name_out = vapply(api_urls,
  attr, which = "name_out", FUN.VALUE = character(1L)), drop = FALSE,
  ...)

Arguments

api_urls

character list comprising of API URL lists that are of 'url' class. If a vector is given, the function will wrap it into a list.

use_curl

logical, whether use curl. Default TRUE. You can use check_curl() to check if curl is available for the api_urls before you begin to read data.

parse_json

logical, whether parse the output JSON character to R data. If TRUE, fromJSON() will be called to parse the character. Default TRUE.

time

numeric, the time interval to access the api_urls, in seconds. It is used to avoid overuse of the APIs. Default 0.

encoding

character, the encoding of the API. Default NULL, indicating that the function will automatically select an encoding for specific APIs. The accepted 'encoding' is consistent with that in readLines(). You can set it to 'unknown', while in some cases, you need to assign a valid encoding value, e.g., 'UTF-8'.

messaging

logical, whether print messages when processing. Default FALSE.

name_out

character vector, the names of the output list. Default is set to api_url's 'name_out' attribute. If NULL, the output will have no names.

drop

logical, whether unlist the result when there is only one list returned. Default FALSE, which indicates that you will need to extract the result first. Note that if you set drop = TRUE, then the result will be unclassed.

...

other arguments to pass to the function.

Value

a list comprising of 'api_data' objects. The 'api_data' class includes several useful subclasses, e.g. 'google_geocode', 'google_revgeocode', 'baidu_geocode', 'baidu_revgeocode', 'gaode_geocode', 'gaode_revgeocode', and 'ipify_geohost', 'ipinfo_geohost', 'ipstack_geohost', ... in asesgeo.

Author(s)

Yiying Wang, wangy@aetna.com

Examples

1
2
3
4
5
## Not run: 
api_urls <- c('<API 1>', '<API 2>', ...)
get_api_data(api_urls)

## End(Not run)

madlogos/aseskit documentation built on June 26, 2019, 12:17 a.m.