# `Fred.Sources`
[🔗](https://github.com/akoutmos/fred/blob/master/lib/fred/sources.ex#L1)

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

  - `list/1` - [`/fred/sources`](https://fred.stlouisfed.org/docs/api/fred/sources.html)
  - `get/2` - [`/fred/source`](https://fred.stlouisfed.org/docs/api/fred/source.html)
  - `releases/2` - [`/fred/source/releases`](https://fred.stlouisfed.org/docs/api/fred/source_releases.html)

# `get`

```elixir
@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`

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

Get all sources of economic data.

## Options

  * `:limit` (`t:pos_integer/0`) - Max results (between 1-1000).

* `:offset` (`t:pos_integer/0`) - Result offset.

* `:order_by` (`t: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` (`t: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`

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

Get the releases for a source.

## Options

  * `:limit` (`t:pos_integer/0`) - Max results (between 1-1000).

* `:offset` (`t:pos_integer/0`) - Result offset.

* `:order_by` (`t: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` (`t: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")

---

*Consult [api-reference.md](api-reference.md) for complete listing*
