主要内容

series

Retrieve FRED time series information

Since R2026a

    Description

    d = series(c,s) returns a table that contains metadata for a Federal Reserve Economic Data (FRED®) time series, where c is a fredrs connection object and s is the series ID.

    example

    d = series(c,s,t) specifies the type of series information, t, to retrieve. For example, series(c,s,"categories") returns the categories associated with a given series ID.

    d = series(c,s,t,fredParams) additionally specifies a comma-separated list of FRED REST API parameters. For example, series(c,s,"observations","limit","10) returns a table with a limit of 10 observations for a given series. For more information on specifying FRED parameters, see the FRED REST API documentation.

    [d,response] = series(___) 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 and display the metadata for the FRED time series with the GNPCA ID.

    s = "GNPCA";
    d = series(c,s)
    d.seriess
    d =
    
      1×3 table
    
        realtime_start    realtime_end     seriess  
        ______________    ____________    __________
    
         25-Sep-2025      25-Sep-2025     1×1 struct
    
    d.seriess
    
    ans = 
    
      struct with fields:
    
                               id: 'GNPCA'
                   realtime_start: 25-Sep-2025
                     realtime_end: 25-Sep-2025
                            title: 'Real Gross National Product'
                observation_start: 01-Jan-1929
                  observation_end: 01-Jan-2024
                        frequency: 'Annual'
                  frequency_short: 'A'
                            units: 'Billions of Chained 2017 Dollars'
                      units_short: 'Bil. of Chn. 2017 $'
              seasonal_adjustment: 'Not Seasonally Adjusted'
        seasonal_adjustment_short: 'NSA'
                     last_updated: 2025-09-25 07:47:26-05
                       popularity: 15
                            notes: 'BEA Account Code: A001RX↵↵'

    Retrieve and display the categories for the time series with the EXJPUS ID.

    s = "EXJPUS";
    t = "categories";
    d = series(c,s,t)
    d =
    
      table
    
        categories 
        ___________
    
        {2×3 table}
    
    
    ans =
    
      2×3 table
    
        id           name           parent_id
        ___    _________________    _________
    
         95    {'Monthly Rates'}        15   
        275    {'Japan'        }       158   

    Input Arguments

    collapse all

    FRED REST connection, specified as a fredrs object.

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

    Example: s = "GNPCA"

    Data Types: string | char

    Type of series information to retrieve, specified as a string scalar or character vector. For a given series, you can specify any of the following types:

    • "categories" – Get the categories.

    • "observations" – Get the observations.

    • "release" – Get the release.

    • "search" – Get the series that matches a keyword search.

    • "search/tags" – Get the tags for a series search.

    • "search/related_tags" – Get the related tags for a series search.

    • "tags" – Get the tags.

    • "updates" – Get a series sorted by FRED server update time.

    • "vintagedates" – Get the historical dates for series updates or new releases.

    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 category 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