Skip to main content

Connect FRED

Tasks call FRED (Federal Reserve Economic Data, from the Federal Reserve Bank of St. Louis) through qbash.integrations.fred with an API key you store on the Connectors page. The connector searches FRED's economic time series by keyword or tag and reads their observations, with FRED's transforms such as percent change from a year ago. It also browses FRED's categories and releases and reads the release calendar. Every method is a read.

After you connect FRED, you can add its tools to a qbash MCP server for ChatGPT, Claude and other MCP clients, or call it from a Python task. The FRED MCP server page lists what the connector can do.

This product uses the FRED® API but is not endorsed or certified by the Federal Reserve Bank of St. Louis.

Request an API key​

  1. Sign in at fredaccount.stlouisfed.org, or create a free account there.
  2. Open API Keys and request a key. FRED asks for a short description of the application that will use it.
  3. Copy the key, a 32-character string of lowercase letters and digits.

FRED asks for a separate key for each application, so request one for qbash instead of reusing a key from another tool.

Add the credential in qbash​

  1. Open Connectors, then FRED, and click Connect.
  2. Give the credential a name and paste the API key. qbash checks the key with FRED before saving it.
  3. In the task editor, choose Add connector from the Package + menu and select the credential. See Task resources.

To edit the credential later, leave the key blank to keep the saved one.

Call FRED from a task​

This task reads CPI inflation since 2020, as the percent change from a year earlier, and logs the peak and the latest month.

cpi = qbash.integrations.fred.get_observations(
series_id="CPIAUCSL",
units="pc1",
observation_start="2020-01-01",
sort_order="asc",
)

rows = [row for row in cpi["observations"] if row["value"] is not None]
peak = max(rows, key=lambda row: row["value"])
latest = rows[-1]

qbash.log(f'CPI inflation peaked at {peak["value"]:.1f}% in {peak["date"][:7]}.')
qbash.log(f'The latest reading is {latest["value"]:.1f}% for {latest["date"][:7]}.')

Use search_series to find a series ID, such as UNRATE for the unemployment rate or FEDFUNDS for the federal funds rate. The SDK Reference lists every method with its parameters and return values.

Compare two series​

Pass the same window and frequency to each series, so the dates line up.

window = {"observation_start": "2015-01-01", "frequency": "m", "sort_order": "asc"}

unemployment = qbash.integrations.fred.get_observations(series_id="UNRATE", **window)
fed_funds = qbash.integrations.fred.get_observations(series_id="DFF", aggregation_method="eop", **window)

rates = {row["date"]: row["value"] for row in fed_funds["observations"]}
for row in unemployment["observations"][-12:]:
qbash.log(f'{row["date"][:7]}: unemployment {row["value"]}%, fed funds {rates.get(row["date"])}%')

Read the release calendar​

get_release_dates starts from today by default, so it lists what FRED expects to publish next, soonest first. Pass a release_id from list_releases for one release, such as 10 for the Consumer Price Index.

upcoming = qbash.integrations.fred.get_release_dates(release_id=10)
for entry in upcoming["release_dates"]:
qbash.log(f'CPI release scheduled for {entry["date"]}')

Add test data​

FRED is public data, so a new key reads every series at once and needs no setup. CPIAUCSL (CPI), UNRATE (unemployment rate), GDP and DGS10 (10-year Treasury yield) are useful series to test with.

Details that affect results​

  • get_observations returns the newest 1,000 values first by default. Set sort_order="asc" for the oldest first, and narrow a long daily series with observation_start or a lower frequency instead of a large limit. The limit goes up to 100,000, and chat tools cap it at 1,000.
  • Values come back as numbers. FRED writes a missing value, such as a market holiday, as ., and the connector returns it as None.
  • units transforms the values: pch is the percent change from the previous period, pc1 the percent change from a year ago and pca the compounded annual rate. frequency aggregates to a lower frequency with aggregation_method avg, sum or eop (end of period). FRED returns an error for a frequency higher than the series' own.
  • With frequency set, FRED counts the observations before aggregating, so count can be far higher than the rows a call returns. Page with next_offset until it is None.
  • realtime_start and realtime_end read the values as FRED published them at the time, from ALFRED, the St. Louis Fed's archive of past data vintages.
  • FRED allows 120 requests per minute for each key. The connector retries a rate-limited call once.