Main Content

fred

Connect toFREDdata servers

Description

Thefredfunction creates afredobject. Thefredobject represents a FRED®connection.

After you create afredobject, 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

Description

example

c= fred弗雷德弗雷德返回一个连接到数据服务器using the default URL“https://fred.stlouisfed.org/'.

example

c= fred(url)returns a FRED connection using the specified URL.

Input Arguments

expand all

URL of the FRED data server, specified as a character vector or string scalar.

Example:“https://fred.stlouisfed.org/'

Data Types:char|string

Properties

expand all

URL of the FRED data server, specified as a character vector.

Thefredfunction sets this property using theurlinput argument.

Example:“https://fred.stlouisfed.org/'

Data Types:char

IP address of the proxy server, specified as a character vector.

Data Types:char

Port number of the proxy server, specified as a numeric scalar.

Data Types:double

Data return format, specified as one of these values, which determine the data type of the returned data.

价值 Data Type of Returned Data

[](default)

structure
'table' table
'timetable' timetable

You can specify these values using a character vector or string (for example,"table").

When you create afredobject, thefredfunction 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 theDataReturnFormatproperty, use thefetchfunction to retrieve data.

Date and time data type, specified as one of these values.

价值 Data Type of Returned Data
[](default) MATLAB®date numbers
'datetime' datetimearray

You can specify these values using a character vector or string (for example,"datetime").

When you create afredobject, thefredfunction 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 theDatetimeTypeproperty, use thefetchfunction to retrieve data.

Object Functions

fetch Request data fromFREDdata servers
isconnection Determine if connections toFREDdata servers are valid
close Close connections toFREDdata servers

Examples

collapse all

Connect to the FRED® data server, and then retrieve historical data for a series.

Connect to the FRED data server.

c = fred

cis 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 theipproperty of the FRED connectionc.

c.IP

Retrieve theportproperty of the FRED connectionc.

c.Port

Adjust the display data format for currency.

formatbank

Retrieve all historical data for the US / Euro Foreign Exchange Rate series.dcontains the series description.

series ='DEXUSEU'; d = fetch(c,series);

Close the FRED connection.

close(c)

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)

cis 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 theipproperty of the FRED connectionc.

c.IP

Retrieve theportproperty of the FRED connectionc.

c.Port

Adjust the display data format for currency.

formatbank

Retrieve all historical data for the US / Euro Foreign Exchange Rate series.dcontains the series description.

series ='DEXUSEU'; d = fetch(c,series);

Close the FRED connection.

close(c)
Introduced in R2006b