Main Content

category

Retrieve FRED category information

Since R2026a

    Description

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

    example

    d = category(c,s,t) specifies the type of category information, t, to retrieve. For example, data = category(c,s,"children") retrieves the subcategories associated with a given category ID.

    d = category(c,s,t,fredParams) additionally specifies a comma-separated list of FRED REST API parameters. For example, category(c,"125","series","limit","8","order_by","frequency") returns a table with a limit of eight time series sorted by frequency for category 125. For more details about specifying FRED parameters, see the FRED API documentation.

    [d,response] = category(___) 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 information for category 13.

    s = "13";
    [d,response] = category(c,s)
    d =
    
      1×3 table
    
        id                     name                      parent_id
        __    _______________________________________    _________
    
        13    U.S. Trade & International Transactions      32992  
    
    
    response = 
    
      ResponseMessage with properties:
    
        StatusLine: 'HTTP/1.1 200 OK'
        StatusCode: OK
            Header: [1×13 matlab.net.http.HeaderField]
              Body: [1×1 matlab.net.http.MessageBody]
         Completed: 0

    Retrieve the subcategories for category 13.

    t = "children";
    d = category(c,s,t)
    d =
    
      6×3 table
    
         id                      name                     parent_id
        _____    _____________________________________    _________
    
           16    {'Exports'                          }       13    
           17    {'Imports'                          }       13    
         3000    {'Income Payments & Receipts'       }       13    
        33705    {'International Investment Position'}       13    
          125    {'Trade Balance'                    }       13    
          127    {'U.S. International Finance'       }       13

    Input Arguments

    collapse all

    FRED REST connection, specified as a fredrs object.

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

    Example: s = "13"

    Data Types: string | char

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

    • "children" – Get the subcategories for a specified parent category.

    • "related" – Get the related categories for a category.

    • "series" – Get the time series in a category.

    • "tags" – Get the tags for a category.

    • "related_tags" – Get the related tags for a category.

    Data Types: string | char

    FRED REST API arguments, specified as a comma-separated list. For example, category(c,"125","series","order_by","popularity") retrieves the series in category 125 based on how frequently the series is accessed. 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