Fred.Sources (Fred v0.4.0)

Copy Markdown View Source

Functions for the FRED Sources endpoints.

Sources are the original providers of economic data to FRED (e.g., the Bureau of Labor Statistics, the Bureau of Economic Analysis, the Federal Reserve Board).

Endpoints

Summary

Functions

Get a source of economic data.

Get all sources of economic data.

Get the releases for a source.

Functions

get(source_id, opts \\ [])

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

Get a source of economic data.

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, sources} = Fred.Sources.get(1)
iex> %{"sources" => [_ | _]} = sources

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

list(opts \\ [])

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

Get all sources of economic data.

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:

    • :source_id
    • :name
    • :press_release
    • :realtime_start
    • :realtime_end
  • :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, sources} = Fred.Sources.list(limit: 10, order_by: :name)
iex> %{"sources" => [_ | _]} = sources

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

releases(source_id, opts \\ [])

@spec releases(source_id :: integer(), opts :: keyword()) :: Fred.Client.response()

Get the releases for a source.

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:

    • :release_id
    • :name
    • :press_release
    • :realtime_start
    • :realtime_end
  • :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, releases} = Fred.Sources.releases(1, order_by: :name)
iex> %{"releases" => [_ | _]} = releases

iex> {:error, %Fred.Error{type: :option_error}} =
...>   Fred.Sources.releases(1, realtime_start: "Bad Input")