series

suspend fun series(seriesId: String, startDate: LocalDate? = null, endDate: LocalDate? = null, frequency: DataFrequency? = null): FredSeries(source)

Retrieves economic data series from the Federal Reserve Economic Data (FRED) API.

This method provides access to thousands of economic time series including GDP, unemployment rates, inflation, interest rates, and various economic indicators.

Requires a FRED API key to be configured during client creation. API keys are free and can be obtained from https://fred.stlouisfed.org/docs/api/api_key.html

Return

Economic data series observations

Parameters

seriesId

The FRED series ID (e.g., "GDP", "UNRATE", "CPIAUCSL")

startDate

Optional start date for the data range (default: null, returns all available data)

endDate

Optional end date for the data range (default: null, returns up to latest available)

frequency

Optional data frequency aggregation (e.g., DAILY, WEEKLY, MONTHLY, QUARTERLY, ANNUAL)

Throws

with ErrorCode.CONFIGURATION_ERROR if FRED API key is not configured, or if the series ID is invalid or the request fails

Samples