FRED Query — Federal Reserve Economic Data on the command line.
fredq brings the FRED (Federal Reserve Economic Data) HTTP endpoints to the command line. It is built for scripts, agents, and quick terminal work that needs the JSON returned by the FRED API.
The project stays deliberately close to the source. It does not reshape FRED responses, define economic domain models, or add a discovery API beyond CLI help.
- Raw FRED JSON on stdout, with no pretty-printing or interpretation.
- Endpoint-specific commands for every public FRED API endpoint.
- Generated help that includes examples, parameters, and known value sets.
- Typed Parquet output for
series-observationswhen a long time series is more useful as a columnar table than as JSON. - ALFRED point-in-time support (
--realtime-start,--realtime-end,series-vintagedates). - GeoFRED / Maps regional data (
geofredsubcommands): regional time series, all-region snapshots, series-group metadata, and GeoJSON shape files.
fredq is a Python 3.10+ project. Install it as a tool with uv or with pip:
uv tool install fredq
# or
pip install fredqFor Parquet output, include the parquet extra:
uv tool install "fredq[parquet]"
# or
pip install "fredq[parquet]"Then run:
fredq --helpTo run from a local checkout (development):
uv sync --all-groups
uv run fredq --helpOr install the checkout as a tool:
uv tool install .
fredq --helpThe FRED API requires a free API key. Request one at https://fred.stlouisfed.org/docs/api/api_key.html.
fredq reads the key from, in order:
- The
FRED_API_KEYenvironment variable. - The first non-empty line of
~/.fredq/api_key. - The
--api-keyflag (visible in process listings; prefer the env var).
On POSIX systems, restrict the key file so only your user can read it:
chmod 600 ~/.fredq/api_keyfredq emits a warning if the file is readable by group or world. To disable
the file fallback entirely (for hermetic runs), set FREDQ_DISABLE_KEY_FILE=1
or pass --no-key-file.
fredq never prints, logs, or echoes the API key. The key is also redacted
from URLs in error messages and from any httpx debug logs emitted under
--verbose.
Show metadata for a series:
uv run fredq series --series-id GNPCAFetch a series' observations:
uv run fredq series-observations --series-id CPIAUCSLApply a unit transformation and frequency aggregation:
uv run fredq series-observations --series-id CPIAUCSL --units pch --frequency mSearch for a series by keyword:
uv run fredq series-search --search-text "10-year treasury" --limit 10Browse the FRED category tree from the root:
uv run fredq category-children --category-id 0List recent economic releases:
uv run fredq releases --limit 10List recent release publication dates across all releases:
uv run fredq releases-dates --limit 20Show metadata for a specific release (53 = GDP):
uv run fredq release --release-id 53Find all series tagged with a set of FRED tags:
uv run fredq tags-series --tag-names "usa;monthly;cpi" --limit 25ALFRED point-in-time: see what GDP looked like on a past date:
uv run fredq series-vintagedates --series-id GNPCA
uv run fredq series-observations --series-id GNPCA --realtime-start 2024-09-25Fetch GeoFRED regional data — per-capita income by state for one year:
uv run fredq geofred series-group --series-id WIPCPI
uv run fredq geofred series-data --series-id WIPCPI --start-date 2022-01-01series-observations can write a typed Parquet table instead of raw JSON.
Install with the parquet extra to pull in pyarrow:
uv sync --extra parquetThen pass --format parquet --out PATH:
uv run fredq series-observations --series-id CPIAUCSL --units pch --frequency m \
--format parquet --out cpi_yoy.parquetOn success a single JSON descriptor line goes to stdout (the file format, out
path, row count, byte size). The Parquet schema is date (date32), value
(float64), realtime_start (date32), realtime_end (date32). FRED's
missing-value sentinel . is written as NaN. The full response envelope
(count, offset, limit, observation range, units, sort order) and the request
context (units, frequency, realtime range) are stored as schema key-value
metadata so the table is self-describing.
Parquet writes are scoped to series-observations only; every other command
stays JSON-only, and rejects --format parquet with a usage error. Parquet
output assumes FRED's default observation layout (one row per observation);
fredq does not expose FRED's alternative output_type modes.
Most commands take an ID (--series-id, --category-id, --release-id,
--source-id). If you don't know one yet, start with the commands that need no
ID, then chain:
# Find a series ID by keyword
uv run fredq series-search --search-text "unemployment rate" --limit 10
# List the catalogs
uv run fredq releases --limit 1000 # release IDs
uv run fredq sources # source IDs
uv run fredq tags --limit 50 # tag names
# Walk the category tree from the root (0 = root)
uv run fredq category-children --category-id 0Then use the ID with the matching command:
uv run fredq series-observations --series-id DGS10
uv run fredq category-series --category-id 106
uv run fredq release-series --release-id 10Use root help to see the command list:
uv run fredq --helpCurrent commands, grouped by how often they're reached for:
Daily-driver fetches
| Command | FRED data |
|---|---|
series |
Show metadata for one FRED series (title, units, frequency, observation range). |
series-observations |
Fetch the observation values for one FRED series. |
Series discovery
| Command | FRED data |
|---|---|
series-search |
Search FRED series by keyword. |
series-search-tags |
List tags for a series full-text search. |
series-search-related-tags |
List tags related to a search and existing tag filter. |
tags-series |
List series matching a set of FRED tags. |
tags |
List all FRED tags. |
related-tags |
List tags related to an existing tag filter. |
Series-bound analysis
| Command | FRED data |
|---|---|
series-vintagedates |
List vintage dates (revision dates) for one FRED series. |
series-categories |
List categories that contain a given series. |
series-tags |
List tags assigned to a FRED series. |
series-release |
Show the release that a FRED series belongs to. |
series-updates |
List recently updated FRED series. |
Category browse
| Command | FRED data |
|---|---|
category |
Show metadata for one FRED category. |
category-children |
List child categories of a FRED category. |
category-related |
List categories related to a given FRED category. |
category-series |
List series belonging to one FRED category. |
category-tags |
List tags for series in one FRED category. |
category-related-tags |
List tags related to a category and existing tag filter. |
Releases and calendar
| Command | FRED data |
|---|---|
releases |
List all FRED economic data releases. |
releases-dates |
List release dates across all FRED releases. |
release |
Show metadata for one FRED release. |
release-dates |
List publication dates for one FRED release. |
release-series |
List series belonging to one FRED release. |
release-sources |
List sources for one FRED release. |
release-tags |
List tags for one FRED release. |
release-related-tags |
List tags related to a release and existing tag filter. |
release-tables |
Fetch the hierarchical data table for one FRED release. |
Sources
| Command | FRED data |
|---|---|
sources |
List all FRED data sources. |
source |
Show metadata for one FRED source. |
source-releases |
List releases published by one FRED source. |
GeoFRED / Maps (geofred subcommands)
| Command | FRED data |
|---|---|
geofred series-group |
Show GeoFRED series-group metadata (region type, season, frequency, units). |
geofred series-data |
Fetch the regional time series for one FRED series. |
geofred regional-data |
Fetch a regional snapshot — all regions for a single date. |
geofred shapes |
Download a GeoJSON shape file for a region type, to --out. |
The GeoFRED endpoints use a different base URL and return regional data keyed by
FIPS code. geofred shapes returns Highcharts-format GeoJSON whose coordinates
are in a Lambert Conformal Conic projection (not WGS84); reproject before mixing
with lat/lon basemaps. See fredq geofred --help for the full subcommand list.
Each endpoint has its own adaptive help:
uv run fredq series --help
uv run fredq series-observations --help
uv run fredq series-search --help
uv run fredq releases-dates --helpEndpoint help is the primary documentation surface. It shows the FRED target endpoint, accepted parameters, allowed value sets, defaults, and examples.
Date parameters accept:
YYYY-MM-DDcalendar dates.- ISO 8601 datetimes (the time component is dropped; UTC assumed for naive values).
- Unix timestamps in seconds (≥10 digits).
Boolean parameters accept common true and false forms such as true, false,
1, 0, yes, and no.
Tag lists (--tag-names, --exclude-tag-names) use semicolons as
separators, matching FRED's wire format:
uv run fredq tags-series --tag-names "usa;annual"Most endpoints accept --realtime-start and --realtime-end to view data
as of a historical date (the ALFRED
archival API). Combined with series-vintagedates, this lets you replay
what an analyst would have seen on a specific past date — useful for
backtests and for distinguishing data revisions from real-time signals.
# When were GNP revisions published?
uv run fredq series-vintagedates --series-id GNPCA
# What did GNP look like on 2024-09-25?
uv run fredq series-observations --series-id GNPCA \
--realtime-start 2024-09-25 --realtime-end 2024-09-25fredq writes the FRED response body to stdout exactly as returned. This makes it easy to pipe into tools that expect JSON:
uv run fredq series --series-id GNPCA | jq .
uv run fredq releases --limit 25 | jq '.releases[].name'Diagnostics, warnings, and errors are written to stderr. The exit code is
0 on success, 1 on a FRED request failure, and 2 on a usage or
configuration error.
Install development dependencies:
uv sync --all-groupsRun the test suite:
uv run pytestRun checks locally:
uv run black --check .
uv run ruff format --check --diff .
uv run ruff check .
uv run pyright
uv run pytest -n autoRun the full project check, including Python checks across supported versions and spelling:
uv run toxWhen adding or changing command metadata, update validation, adaptive help, and tests together. Then verify the relevant command against FRED with its help, minimal required parameters, and representative optional parameters.
fredq is released under the MIT License. See LICENSE.