Fred.Client (Fred v0.4.0)

Copy Markdown View Source

Low-level HTTP client for the FRED API using Req.

Handles request construction, parameter serialization, response parsing, and telemetry instrumentation.

All endpoint modules delegate to this module for actual HTTP calls.

Telemetry

Every request is wrapped in a [:fred, :request] telemetry span. See Fred.Telemetry for event names, measurements, and metadata.

Summary

Functions

Makes a GET request to the provided FRED API endpoint.

Makes a GET request to the provided FRED Maps API endpoint. Used internally by Fred.Maps for the GeoFRED base URL. params should contain the query parameters required for the endpoint.

Makes a GET request to the provided FRED Maps API endpoint. Used internally by Fred.Maps to get shape files versus JSON.

Types

response()

@type response() :: {:ok, map()} | {:error, Fred.Error.t()}

Functions

get_json(endpoint, params \\ [])

@spec get_json(endpoint :: String.t(), params :: keyword()) :: response()

Makes a GET request to the provided FRED API endpoint.

Automatically injects the API key, sets file_type=json, and emits telemetry events around the request. params should contain the query parameters required for the endpoint.

get_map_json(endpoint, params \\ [])

@spec get_map_json(endpoint :: String.t(), params :: keyword()) :: response()

Makes a GET request to the provided FRED Maps API endpoint. Used internally by Fred.Maps for the GeoFRED base URL. params should contain the query parameters required for the endpoint.

get_map_raw(endpoint, params \\ [])

@spec get_map_raw(endpoint :: String.t(), params :: keyword()) :: response()

Makes a GET request to the provided FRED Maps API endpoint. Used internally by Fred.Maps to get shape files versus JSON.