主要内容

source

Retrieve FRED source information

Since R2026a

    Description

    d = source(c) returns a table that contains metadata for all available Federal Reserve Economic Data (FRED®) sources, where c is a fredrs connection object.

    example

    d = source(c,s) returns a table of metadata for a given source ID, s.

    d = source(c,s,"releases") returns a table of information about all releases associated with a given source ID.

    d = source(c,s,"releases",fredParams) additionally specifies a comma-separated list of FRED REST API parameters. For example, source(c,s,"releases","limit","20") returns a table with a limit of twenty releases for a given source ID, while source(c,[],"releases","limit","20") returns a table with a limit of twenty sources. For more information on specifying FRED parameters, see the FRED REST API documentation.

    [d,response] = source(___) also returns a response message for any of the previous syntaxes.

    Examples

    collapse all

    This example assumes that you have obtained your API user token from the Federal Reserve Bank of St. Louis website and you stored it in the MATLAB® vault by using the setSecret function.

    Use the getSecret function to retrieve your API user token from the MATLAB vault. Then, create a connection to the FRED server by using the fredrs function.

    APIkey = getSecret("MyAPIkeyFREDRS");
    c = fredrs(APIkey);

    Retrieve the metadata for all available FRED sources.

    d = source(c)
    d =
    
      1×8 table
    
        realtime_start    realtime_end      order_by       sort_order    count    offset    limit      sources   
        ______________    ____________    _____________    __________    _____    ______    _____    ____________
    
         15-Oct-2025      15-Oct-2025     {'source_id'}     {'asc'}       118       0       1000     {118×1 cell}

    Retrieve a limited amount of metadata from source ID 1.

    s = "1";
    d = source(c,s,"releases","limit","20")
    d =
    
      1×8 table
    
        realtime_start    realtime_end       order_by       sort_order    count    offset    limit     releases  
        ______________    ____________    ______________    __________    _____    ______    _____    ___________
    
         15-Oct-2025      15-Oct-2025     {'release_id'}     {'asc'}       35        0        20      {20×1 cell}

    Input Arguments

    collapse all

    FRED REST connection, specified as a fredrs object.

    Source ID, specified as a string scalar or character vector.

    Example: s = "1"

    Data Types: string | char

    FRED REST API arguments, specified as a comma-separated list. For more information about specifying FRED parameters, see the FRED REST API documentation.

    Output Arguments

    collapse all

    FRED source information, returned as a table.

    HTTP request response, returned as a ResponseMessage object. For details, see matlab.net.http.ResponseMessage.

    Version History

    Introduced in R2026a