ustfd_simple: Retrieve Fiscal Data API in a single call

View source: R/ustfd.R

ustfd_simpleR Documentation

Retrieve Fiscal Data API in a single call

Description

ustfd_simple() aggregates the workflow for retrieving data from the API into a single call.

Usage

ustfd_simple(
  endpoint,
  filter = NULL,
  fields = NULL,
  sort = NULL,
  page_size = NULL,
  page_number = NULL,
  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

page_number

optional integer for pagination

user_agent

optional string

Value

a list containing the following items

  • meta - the metadata returned by the API

  • data - the payload returned by the API in table form. See ustfd_response_payload()

See Also

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

Examples

## Not run: 
library(ustfd)

exchange_rates <- ustfd_simple(
  '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)

ustfd documentation built on Nov. 8, 2023, 1:07 a.m.