주요 콘텐츠

tags

Retrieve FRED tag information

Since R2026a

    Description

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

    example

    d = tags(c,s) returns FRED tag information for a given tag ID, s.

    d = tags(c,s,"series") returns the time series associated with a given tag ID.

    d = tags(c,s,"series",fredParams) additionally specifies a comma-separated list of FRED REST API parameters. For example, tags(c,"nsa","series","limit","20") returns a table with a limit of twenty time series associated with the nsa tag ID, while tags(c,[],"series","limit","20") returns a table with a limit of twenty tags. For more information on specifying FRED parameters, see the FRED REST API documentation.

    [d,response] = tags(___) 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 tags.

    d = tags(c)
    d =
    
      1×8 table
    
        realtime_start     realtime_end         order_by        sort_order    count    offset    limit         tags     
        ______________    ______________    ________________    __________    _____    ______    _____    ______________
    
        {'2025-10-15'}    {'2025-10-15'}    {'series_count'}     {'desc'}     5995       0       1000     {1000×6 table}

    Retrieve the time series that match the nsa ID.

    s = "nsa";
    [d,response] = tags(c,s,"series")
    d =
    
      1×8 table
    
        realtime_start     realtime_end       order_by       sort_order      count       offset    limit        seriess    
        ______________    ______________    _____________    __________    __________    ______    _____    _______________
    
        {'2025-10-15'}    {'2025-10-15'}    {'series_id'}     {'asc'}      7.4689e+05      0       1000     {1000×16 table}
    
    
    response = 
    
      ResponseMessage with properties:
    
        StatusLine: 'HTTP/1.1 200 OK'
        StatusCode: OK
            Header: [1×14 matlab.net.http.HeaderField]
              Body: [1×1 matlab.net.http.MessageBody]
         Completed: 0
    

    Input Arguments

    collapse all

    FRED REST connection, specified as a fredrs object.

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

    Example: s = "nsa"

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