Skip to contents

Constructors describing how limit/offset are sent with a request. Pass the result to the pagination argument of af_api().

Usage

af_paginate_offset(
  where = c("header", "query"),
  limit_param = "limit",
  offset_param = "offset"
)

af_paginate_none()

Arguments

where

Either "header" or "query".

limit_param, offset_param

Parameter names to use.

Value

An apifetch_pagination object.

Details

  • af_paginate_offset(): send limit/offset either as HTTP headers (default, as the Big Data PE API expects) or as URL query parameters.

  • af_paginate_none(): send no pagination parameters.

Non-positive or infinite values are omitted from the request.

Examples

af_paginate_offset("header")
#> $apply
#> function (req, limit, offset) 
#> {
#>     vals <- list()
#>     if (!(is.infinite(limit) || limit <= 0)) 
#>         vals[[limit_param]] <- limit
#>     if (!(is.infinite(offset) || offset <= 0)) 
#>         vals[[offset_param]] <- offset
#>     if (length(vals) == 0) 
#>         return(req)
#>     fn <- if (where == "header") 
#>         httr2::req_headers
#>     else httr2::req_url_query
#>     do.call(fn, c(list(req), vals))
#> }
#> <bytecode: 0x563a4d0857d8>
#> <environment: 0x563a4f5d6838>
#> 
#> attr(,"class")
#> [1] "apifetch_pagination"
af_paginate_offset("query", limit_param = "per_page")
#> $apply
#> function (req, limit, offset) 
#> {
#>     vals <- list()
#>     if (!(is.infinite(limit) || limit <= 0)) 
#>         vals[[limit_param]] <- limit
#>     if (!(is.infinite(offset) || offset <= 0)) 
#>         vals[[offset_param]] <- offset
#>     if (length(vals) == 0) 
#>         return(req)
#>     fn <- if (where == "header") 
#>         httr2::req_headers
#>     else httr2::req_url_query
#>     do.call(fn, c(list(req), vals))
#> }
#> <bytecode: 0x563a4d0857d8>
#> <environment: 0x563a4f5a7328>
#> 
#> attr(,"class")
#> [1] "apifetch_pagination"
af_paginate_none()
#> $apply
#> function (req, limit, offset) 
#> req
#> <bytecode: 0x563a4f56bd88>
#> <environment: 0x563a4f56c060>
#> 
#> attr(,"class")
#> [1] "apifetch_pagination"