Fred.Categories (Fred v0.4.0)

Copy Markdown View Source

Functions for the FRED Categories endpoints.

Categories organize FRED series into a hierarchical tree structure. The root category has category_id 0.

Endpoints

Below is a listing of the functions that this module contains along with what endpoints they map to in the FRED API. Click on the endpoint to go to the FRED documentation for that particular endpoint:

Summary

Functions

Get the child categories for a specified parent category.

Get the related categories for a given category.

Get the related FRED tags for a category.

Get the series in a category.

Get the FRED tags for a category.

Functions

children(category_id, opts \\ [])

@spec children(category_id :: integer(), opts :: keyword()) :: Fred.Client.response()

Get the child categories for a specified parent category.

Options

  • :realtime_end (struct of type Date) - End of the real-time period.

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

Examples

iex> {:ok, children} = Fred.Categories.children(0)
iex> %{"categories" => [_ | _]} = children

iex> {:error, %Fred.Error{type: :option_error}} =
...>   Fred.Categories.children(0, realtime_start: "Bad Input")

get(category_id, opts \\ [])

@spec get(category_id :: integer(), opts :: keyword()) :: Fred.Client.response()

Get a category.

Options

  • :realtime_end (struct of type Date) - End of the real-time period.

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

Examples

iex> {:ok, category} = Fred.Categories.get(125)
iex> %{
...>   "categories" => [
...>     %{"id" => 125, "name" => "Trade Balance", "parent_id" => 13}
...>   ]
...> } = category

iex> {:error, %Fred.Error{type: :option_error}} =
...>   Fred.Categories.get(125, realtime_start: "Bad Input")

related(category_id, opts \\ [])

@spec related(category :: integer(), opts :: keyword()) :: Fred.Client.response()

Get the related categories for a given category.

A related category is a one-way relation between two categories that is not part of the parent-child tree structure.

Options

  • :realtime_end (struct of type Date) - End of the real-time period.

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

Examples

iex> {:ok, categories} = Fred.Categories.related(32073)
iex> %{"categories" => [_ | _]} = categories

iex> {:error, %Fred.Error{type: :option_error}} =
...>   Fred.Categories.related(32073, realtime_start: "Bad Input")

series(category_id, opts \\ [])

@spec series(category :: integer(), opts :: keyword()) :: Fred.Client.response()

Get the series in a category.

Options

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

  • :filter_value (String.t/0) - The value of the filter_variable attribute to filter results by. This requires that the :filter_variable is also provided.

  • :filter_variable (atom/0) - The attribute to filter results by. Supported values are:

    • :frequency
    • :units
    • :seasonal_adjustment
  • :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
  • :tag_names (list of String.t/0) - List of tag names to match.

Examples

iex> {:ok, series} = Fred.Categories.series(125, limit: 10, order_by: :popularity, sort_order: :desc)
iex> %{"seriess" => [_ | _]} = series

tags(category_id, opts \\ [])

@spec tags(category :: integer(), opts :: keyword()) :: Fred.Client.response()

Get the FRED tags for a category.

Options

  • :filter_value (String.t/0) - The value of the filter_variable attribute to filter results by. This requires that the :filter_variable is also provided.

  • :filter_variable (atom/0) - The attribute to filter results by. Supported values are:

    • :frequency
    • :units
    • :seasonal_adjustment
  • :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.Categories.tags(125, tag_group_id: :freq)
iex> %{"tags" => [_ | _]} = tags