Fred.Tags (Fred v0.4.0)

Copy Markdown View Source

Functions for the FRED Tags endpoints.

FRED tags are attributes assigned to series. Tags provide an alternative way to find and filter series beyond categories.

Endpoints

Summary

Functions

Get FRED tags, optionally filtered by tag name, group, or search text.

Get the related FRED tags for one or more tags.

Get the series matching all tags in the :tag_names parameter.

Functions

list(opts \\ [])

@spec list(opts :: keyword()) :: Fred.Client.response()

Get FRED tags, optionally filtered by tag name, group, or search text.

Options

  • :limit (pos_integer/0) - Max results (between 1-1000).

  • :offset (pos_integer/0) - Result offset.

  • :order_by (atom/0) - Order the results by the provided field. Supported values are:

    • :series_count
    • :popularity
    • :created
    • :name
    • :group_id
  • :realtime_end (struct of type Date) - End of the real-time period.

  • :realtime_start (struct of type Date) - Start of the real-time period.

  • :search_text (String.t/0) - Text to search tag names.

  • :sort_order (atom/0) - The sort order of the results. Supported values are:

    • :asc
    • :desc
  • :tag_group_id (atom/0) - Tag group filter. Supported values are:

    • :freq - Frequency
    • :gen - General or Concept
    • :geo - Geography
    • :geot - Geography Type
    • :rls - Release
    • :seas - Seasonal Adjustment
    • :src - Source
  • :tag_names (list of String.t/0) - List of tag names to match.

Examples

iex> {:ok, tags} = Fred.Tags.list(order_by: :popularity, sort_order: :desc, limit: 10)
iex> %{"tags" => [_ | _]} = tags

iex> {:ok, tags} = Fred.Tags.list(order_by: :name, limit: 10)
iex> %{"tags" => [_ | _]} = tags

iex> {:ok, tags} = Fred.Tags.list(search_text: "inflation")
iex> %{"tags" => [_ | _]} = tags

iex> {:error, %Fred.Error{type: :option_error}} =
...>   Fred.Tags.list(limit: 20, realtime_start: "Bad Input")

related(tag_names, opts \\ [])

@spec related(tag_names :: String.t(), opts :: keyword()) :: Fred.Client.response()

Get the related FRED tags for one or more tags.

Related tags are tags assigned to series that match all tags in the :tag_names parameter, excluding the tags themselves.

Options

  • :exclude_tag_names (list of String.t/0) - List of tag names to exclude.

  • :limit (pos_integer/0) - Max results (between 1-1000).

  • :offset (pos_integer/0) - Result offset.

  • :order_by (atom/0) - Order the results by the provided field. Supported values are:

    • :series_count
    • :popularity
    • :created
    • :name
    • :group_id
  • :realtime_end (struct of type Date) - End of the real-time period.

  • :realtime_start (struct of type Date) - Start of the real-time period.

  • :search_text (String.t/0) - Text to search tag names.

  • :sort_order (atom/0) - The sort order of the results. Supported values are:

    • :asc
    • :desc
  • :tag_group_id (atom/0) - Tag group filter. Supported values are:

    • :freq - Frequency
    • :gen - General or Concept
    • :geo - Geography
    • :geot - Geography Type
    • :rls - Release
    • :seas - Seasonal Adjustment
    • :src - Source

Examples

iex> {:ok, tags} = Fred.Tags.related(["monetary aggregates", "m1"])
iex> %{"tags" => [_ | _]} = tags

iex> {:error, %Fred.Error{type: :option_error}} =
...>   Fred.Tags.related(["monetary aggregates", "m1"], limit: 20, realtime_start: "Bad Input")

series(tag_names, opts \\ [])

@spec series(tag_names :: [String.t(), ...], opts :: keyword()) ::
  Fred.Client.response()

Get the series matching all tags in the :tag_names parameter.

Options

  • :exclude_tag_names (list of String.t/0) - List of tag names to exclude.

  • :limit (pos_integer/0) - Max results (between 1-1000).

  • :offset (pos_integer/0) - Result offset.

  • :order_by (atom/0) - Order the results by the provided field. Supported values are:

    • :series_id
    • :title
    • :units
    • :frequency
    • :seasonal_adjustment
    • :realtime_start
    • :realtime_end
    • :last_updated
    • :observation_start
    • :observation_end
    • :popularity
    • :group_popularity
  • :realtime_end (struct of type Date) - End of the real-time period.

  • :realtime_start (struct of type Date) - Start of the real-time period.

  • :sort_order (atom/0) - The sort order of the results. Supported values are:

    • :asc
    • :desc

Examples

iex> {:ok, series} = Fred.Tags.series(["slovenia", "food", "oecd"], limit: 10)
iex> %{"seriess" => [_ | _]} = series

iex> {:error, %Fred.Error{type: :option_error}} =
...>   Fred.Tags.series(["slovenia", "food", "oecd"], limit: 20, realtime_start: "Bad Input")