Learn R Programming

request (version 0.1.0)

api: API base url and endpoint setup

Description

API base url and endpoint setup

Usage

api(x)
api_path(.data, ..., .dots)
api_path_(.data, ..., .dots)
api_template(.data, template, data)

Arguments

x
A URL
.data
Result of a call to api
...
Comma separated list of unquoted variable names
.dots
Used to work around non-standard evaluation
template
Template to contstruct API route
data
Data to pass to the template parameter

See Also

Other dsl: api_body, api_config, api_error_handler, api_query, auth

Examples

Run this code
## Not run: 
# # Set base url
# ## works with full or partial URLs
# api('https://api.github.com/')
# api('http://api.gbif.org/v1')
# api('api.gbif.org/v1')
# 
# ## works with ports, full or partial
# api('http://localhost:9200')
# api('localhost:9200')
# api(':9200')
# api('9200')
# api('9200/stuff')
# 
# # set paths
# ## NSE
# api('https://api.github.com/') %>%
#   api_path(repos, ropensci, rgbif, issues)
# ## SE
# api('https://api.github.com/') %>%
#   api_path_('repos', 'ropensci', 'rgbif', 'issues')
# 
# # template
# repo_info <- list(username = 'craigcitro', repo = 'r-travis')
# api('https://api.github.com/') %>%
#   api_template(template = 'repos/{{username}}/{{repo}}/issues', data = repo_info)
# ## End(Not run)

Run the code above in your browser using DataLab