Skip to contents

Collates output for a given query, where the query must be called multiple times due to pagination in the API. Assumes that there is a parser for the JSON response from the API.

Usage

collate_paginated_output(
  endpoint,
  query_params,
  pagination_size,
  response_parser
)

Arguments

endpoint

Endpoint of the API

query_params

List of parameters to pass to the API, values must be strings

pagination_size

The size of the response returned (the page size). Should be equal to the value in the query_params

response_parser

A callable that parses the response into something that can be concatenated

Examples

if (FALSE) { # \dontrun{
# Construct a query
endpoint <- "measurements"
query_params <- list(
  location = "Melbourne",
  date_from = "2024-05-24",
  date_to = "2024-05-25",
  limit = "100"
)

# Paginate over results
collate_paginated_output(
  endpoint = endpoint,
  query_params = query_params,
  pagination_size = 100,
  response_parser = get_measures
)
} # }