fred
Connect to FRED data servers
Description
The fred
function creates a fred
object. The fred
object represents a FRED® connection.
After you create a fred
object, you can use the object functions to
retrieve economic data for a FRED series. You can also retrieve data for a specific date or date
range.
Creation
Syntax
Description
Input Arguments
url
— URL of FRED data server
character vector | string scalar
URL of the FRED data server, specified as a character vector or string scalar.
Example: 'https://fred.stlouisfed.org/'
Data Types: char
| string
Properties
URL
— URL of FRED data server
character vector
URL of the FRED data server, specified as a character vector.
The fred
function sets this property using the
url
input argument.
Example: 'https://fred.stlouisfed.org/'
Data Types: char
IP
— IP address
[]
(default) | character vector
IP address of the proxy server, specified as a character vector.
Data Types: char
Port
— Port number
[]
(default) | numeric scalar
Port number of the proxy server, specified as a numeric scalar.
Data Types: double
DataReturnFormat
— Data return format
[]
(default) | 'table'
| 'timetable'
Data return format, specified as one of these values, which determine the data type of the returned data.
Value | Data Type of Returned Data |
---|---|
| structure |
'table' | table |
'timetable' | timetable |
You can specify these values using a character vector or
string (for example, "table"
).
When you create a fred
object, the
fred
function leaves this property unset.
Set this property value manually at the command line or in a script using
dot notation, for example:
c.DataReturnFormat = 'table';
After setting the DataReturnFormat
property, use the
fetch
function to retrieve
data.
DatetimeType
— Date and time data type
[]
(default) | 'datetime'
Date and time data type, specified as one of these values.
Value | Data Type of Returned Data |
---|---|
[] (default) | MATLAB® date numbers |
'datetime' | datetime array |
You can specify these values using a character vector or string (for
example, "datetime"
).
When you create a fred
object, the
fred
function leaves this property unset.
Set this property value manually at the command line or in a script using
dot notation, for example:
c.DatetimeType = 'datetime';
After setting the DatetimeType
property, use the
fetch
function to retrieve
data.
Object Functions
fetch | Request data from FRED data servers |
isconnection | Determine if connections to FRED data servers are valid |
close | Close connections to FRED data servers |
Examples
Connect to FRED
Connect to the FRED® data server, and then retrieve historical data for a series.
Connect to the FRED data server.
c = fred
c
is a FRED connection with these properties:
URL for the FRED data server
IP address of the proxy server
Port number of the proxy server
Date and time data type for returned data
Data return format for returned data
Retrieve the ip
property of the FRED connection c
.
c.IP
Retrieve the port
property of the FRED connection c
.
c.Port
Adjust the display data format for currency.
format bank
Retrieve all historical data for the US / Euro Foreign Exchange Rate series. d
contains the series description.
series = 'DEXUSEU';
d = fetch(c,series);
Close the FRED connection.
close(c)
Connect to FRED with URL
Connect to the FRED® data server using a URL, and then retrieve historical data for a series.
Connect to the FRED data server using the URL 'https://fred.stlouisfed.org/'
.
url = 'https://fred.stlouisfed.org/';
c = fred(url)
c
is a FRED connection with these properties:
URL for the FRED data server
IP address of the proxy server
Port number of the proxy server
Date and time data type for returned data
Data return format for returned data
Retrieve the ip
property of the FRED connection c
.
c.IP
Retrieve the port
property of the FRED connection c
.
c.Port
Adjust the display data format for currency.
format bank
Retrieve all historical data for the US / Euro Foreign Exchange Rate series. d
contains the series description.
series = 'DEXUSEU';
d = fetch(c,series);
Close the FRED connection.
close(c)
Version History
Introduced in R2006b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)