api: API base url and endpoint setup

Description Usage Arguments See Also Examples

View source: R/api.R

Description

API base url and endpoint setup

Usage

1
api(x)

Arguments

x

A URL

See Also

Other dsl: api_body(), api_config(), api_error_handler(), api_path(), api_query(), api_template(), auth

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## 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)

sckott/httsnap documentation built on June 22, 2020, 4:49 a.m.