fred-backend: FRED backend

Description Usage Arguments Details Value References

Description

Backend functions for communicating with the FRED API

Usage

1
2
3
4
5
6

Arguments

f

A structure as returned by the fred function.

url

The API URL to get, relative to the base URL contained in f.

options

A character vector of options to be appended to the URL.

processor

A function to be called on the data, or NULL to return the unprocessed response

file_type

Data return format, either xml or json.

res

Text returned by the web service

Details

The get.fred function constructs a URL, gets it, and hands off the response to a processor function. A processor function should take the same arguments as get.fred, which makes it possible for the processor to differentiate its behavior based on url or options. A few processors are provided (and described below), but other functions tailored to a particular purpose can be plugged in. The file_type option determines the format of the response – either xml or json – and of course it only makes sense to use a processor that knows how to handle the specified format. The guess.processor function takes care of that in the default case by choosing a processor based on file type. The basic.json.processor, basic.xml.processor parse JSON/XML into a data.frame. It does simple classification via type.convert, but does not bother with dates or other non-atomic types. The smart.xml.processor extends basic.xml.processor by doing date/time classification and returning observations as a zoo object. The smart.json.processor similarly extends basic.json.processor. Additionally it automatically handles pagination, looking at the request metadata and making additional requests until the total record count is reached. Note that in some cases this may lead to hundreds of thousands of records being retrieved unless a limit is specified explicitly.

Value

The fred function returns a struct containing basic API settings. All other functions rely on the processor element of their first argument; return types are dependent on that function.

References

The official API docs can be found at http://api.stlouisfed.org/docs/fred/. FRED API codes can be obtained from http://api.stlouisfed.org/api_key.html.


johnlaing/rfred documentation built on May 19, 2019, 5:15 p.m.