Paginator {crul}R Documentation

Paginator client

Description

A client to help you paginate

Arguments

client

an object of class HttpClient, from a call to HttpClient

by

(character) how to paginate. Only 'query_params' supported for now. In the future will support 'link_headers' and 'cursor'. See Details.

limit_param

(character) the name of the limit parameter. Default: limit

offset_param

(character) the name of the offset parameter. Default: offset

limit

(numeric/integer) the maximum records wanted

limit_chunk

(numeric/integer) the number by which to chunk requests, e.g., 10 would be be each request gets 10 records

Details

Methods

get(path, query, ...)

make a paginated GET request

post(path, query, body, encode, ...)

make a paginated POST request

put(path, query, body, encode, ...)

make a paginated PUT request

patch(path, query, body, encode, ...)

make a paginated PATCH request

delete(path, query, body, encode, ...)

make a paginated DELETE request

head(path, ...)

make a paginated HEAD request - not sure if this makes any sense or not yet

responses()

list responses - returns: a list of HttpResponse objects, empty list before requests made

parse(encoding = "UTF-8")

parse content - returns: character vector, empty character vector before requests made

status_code()

(integer) HTTP status codes - returns: numeric vector, empty numeric vector before requests made

status()

(list) HTTP status objects - returns: a list of http_code objects, empty list before requests made

content()

raw content - returns: raw list, empty list before requests made

times()

curl request times - returns: list of named numeric vectors, empty list before requests made

See HttpClient() for information on parameters.

Value

a list, with objects of class HttpResponse(). Responses are returned in the order they are passed in.

Methods to paginate

Supported now:

Supported later:

Examples

## Not run: 
(cli <- HttpClient$new(url = "http://api.crossref.org"))
cc <- Paginator$new(client = cli, limit_param = "rows",
   offset_param = "offset", limit = 50, limit_chunk = 10)
cc
cc$get('works')
cc
cc$responses()
cc$status()
cc$status_code()
cc$times()
cc$content()
cc$parse()
lapply(cc$parse(), jsonlite::fromJSON)

## End(Not run)

[Package crul version 0.5.2 Index]