ustfd_all_pages {ustfd}R Documentation

Retrieve multiple pages of Fiscal Data API in a single call

Description

ustfd_all_pages() is similar to ustfd_simple() with the difference that, for requests that generate multiple pages of results, it will request all pages and merge them into a single result.

While care has been taken to optimize ustfd_all_pages(), for requests spanning more than 10 pages you should consider breaking up the call further if memory use is a concern, especially if you are writing the results to disk or a database with atomic transactions.

Usage

ustfd_all_pages(
  endpoint,
  filter = NULL,
  fields = NULL,
  sort = NULL,
  page_size = 10000L,
  slowly = FALSE,
  pause = 0.25,
  quiet = TRUE,
  user_agent = "http://github.com/groditi/ustfd"
)

Arguments

endpoint

required string representing an API endpoint

filter

optional list used to subset the data. See filter-syntax for more information.

fields

optional character vector of the fields to be retrieved

sort

optional string or character vector. Ordering defaults to ascending, to specify descending order precede the field name with '-'

page_size

optional integer for pagination

slowly

pause between http requests when set to TRUE

pause

length, in seconds, to pause

quiet

when set to FALSE updates will be output via a message

user_agent

string, optional

Value

a list containing the following items

See Also

Other ustfd_user: endpoint_exists(), ustfd_datasets(), ustfd_query(), ustfd_simple(), ustfd_table_columns(), ustfd_tables()

Examples

## Not run: 
library(ustfd)

exchange_rates <- ustfd_all_pages(
  'v1/accounting/od/rates_of_exchange',
   fields = c(
    'country_currency_desc', 'exchange_rate','record_date','effective_date'
   ),
   filter = list(
     record_date = c('>=' = '2020-01-01'),
     country_currency_desc = list('in' = c('Canada-Dollar','Mexico-Peso'))
   )
)

## End(Not run)

[Package ustfd version 0.4.4 Index]