knitr::opts_chunk$set( comment = "#>", collapse = TRUE, warning = FALSE, message = FALSE )
canpaginate
helps you paginate with REST APIs
(p.s. named inspired from Ruby's will_paginate, though this pkgs focus is slightly diff. from that of will_paginate
)
Why? The problems:
devtools::install_github("ropensci/canpaginate")
library(canpaginate)
query parameters
x <- can_paginate( by = "query_params", limit_param = "limit", offset_param = "offset", limit = 5000 ) x$by
link headers
x <- can_paginate( by = "link_headers", limit = 5000 ) x$limit
using options set via cp_init
(alternatively, set options in the call)
x <- can_paginate( by = "query_params", limit_param = "limit", offset_param = "offset", limit = 600 ) library(crul) cli <- crul::HttpClient$new(url = "http://api.gbif.org") res <- x$paginate(cli$get("v1/occurrence/search"))
res res$status() res$content() res$parse() res$as_df()
x$paginate(cli$get("get"), verbose = TRUE)
Determined by what you pass in to paginate
crul
package will be supported, maybe others latercanpaginate
in R doing citation(package = 'canpaginate')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.