> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# FRED: how it works

FRED is the St. Louis Fed's economic database, served over a keyed JSON API at `api.stlouisfed.org`. Taji takes two things from it: the dates the headline US releases came out, and each headline series' observations as they stood on chosen past days (ALFRED vintages). The crate `taji-fred` (`plugins/fred/`) is a class-less data source: one HTTP client, one `Source`, no bars, no stream, no orders. The kernel's `economic` join asks it, beside Yahoo's calendar, and computes every figure itself.

## The vendor

**Host.** One production host, `https://api.stlouisfed.org`, version 1 under `/fred/`. There is no sandbox or paper environment: every call reads the real database.

**Auth.** Every request carries `api_key`, "a 32 character lower-cased alpha-numeric string", as a query parameter; "All web service requests require an API key to identify requests" ([API keys](https://fred.stlouisfed.org/docs/api/api_key.html), fetched 2026-12-02). You request a key while signed in to a `fredaccount.stlouisfed.org` account. The key is free, carries no plan or entitlement, and the docs state no expiry. There is no token exchange and nothing to refresh.

**API families Taji calls** (all version 1, `file_type=json`; the default is XML):

| Endpoint | What it answers | Doc (fetched 2026-12-02) |
|---|---|---|
| `fred/releases/dates` | Every release's dates in a real-time span. `limit` 1 to 1000, paged by `offset` against `count`; `realtime_start` defaults to the first day of the current year; `include_release_dates_with_no_data=true` adds dates with no data yet, such as future calendar dates. | [releases/dates](https://fred.stlouisfed.org/docs/api/fred/releases_dates.html) |
| `fred/series/observations` | A series' observations. `output_type=2` answers "observations by vintage date, all observations" for the `vintage_dates` you list. `units` defaults to `lin` (levels). | [series/observations](https://fred.stlouisfed.org/docs/api/fred/series_observations.html) |
| `fred/series` | One series' metadata. Taji sends it as the key check and as the 300 s warm call. | [series](https://fred.stlouisfed.org/docs/api/fred/series.html) |

**Real time and vintages.** "The real-time period marks when facts were true or when information was known until it changed" ([real-time periods](https://fred.stlouisfed.org/docs/api/fred/realtime_period.html), fetched 2026-12-02). A vintage date names one day of that history: asking a series at vintage `2026-10-13` answers what FRED held that day, before a later release revised or added to it. This is ALFRED, and it is what makes a value point-in-time.

**Errors and limits.** The statuses are 400, 404, 423, 429 and 500, and an error body is `{"error_code", "error_message"}`. "Up to 120 requests per minute are allowed before being served a 429 error code. Not complying with the throttling can result in a temporary block" ([errors](https://fred.stlouisfed.org/docs/api/fred/errors.html), fetched 2026-12-02). The observations page bounds `vintage_dates` per call: "any output_type or other series: ... 2000 json" (fewer for `USRECD` and daily series in CSV and XLSX). No page states a concurrency limit.

**Terms.** The [legal page](https://fred.stlouisfed.org/legal/) (fetched 2026-12-02) forbids using the API "in connection with storing, caching, or archiving any portion of the FRED® Services or FRED® Content" (API prohibitions, item (l)) and in AI or machine-learning training (item (k)). The [API terms](https://fred.stlouisfed.org/docs/api/terms_of_use.html) (fetched 2026-12-02) require the notice "This product uses the FRED® API but is not endorsed or certified by the Federal Reserve Bank of St. Louis.", require the owner's permission for third-party series beyond personal use, and let the Fed limit bandwidth or end the license at any time. The measured and quoted terms live in the README's [Terms](https://docs.taji.is/catalog/fred.md#terms).

**What Taji does not use, and why:**

- `units` other than `lin` (`chg`, `pch`, `pc1` and the rest): the kernel computes each transform off levels ([0001](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0001-kernel-computes.md)), and a non-`lin` unit renames the answer's columns (README [API](https://docs.taji.is/catalog/fred.md#api)).
- `output_type` 1, 3 and 4, `frequency` and `aggregation_method`: the join needs only whole vintages of the native series.
- `fred/release/dates`, `fred/series/vintagedates`, `fred/series/release`: not yet built; the kernel picks vintages from release dates.
- Categories, sources, tags, `fred/series/search`, `fred/series/updates`, `fred/release/tables`: not yet built.
- The Maps API (GeoFRED): not yet built.
- [Version 2](https://fred.stlouisfed.org/docs/api/fred/v2/index.html) (fetched 2026-12-02), whose one endpoint `fred/v2/release/observations` returns every series of a release in bulk and takes the key as `Authorization: Bearer` ([v2 keys](https://fred.stlouisfed.org/docs/api/fred/v2/api_key.html), fetched 2026-12-02): not yet built.
- XML, CSV and XLSX answers: JSON is the one format the client parses.
- FRED's own release calendar as the calendar: Yahoo's calendar is the calendar, and FRED dates a headline release only where Yahoo lists none of it (README [API](https://docs.taji.is/catalog/fred.md#api), [Yahoo's economic facts](https://docs.taji.is/catalog/yahoo.md#economic)).

## Code map

| File | What it owns | Read first |
|---|---|---|
| `plugins/fred/taji-plugin.toml` | The manifest: id, the one `[[sources]]`, the `fred` link form with its steps, `risk` and the key field. | `[[link]]` |
| `plugins/fred/src/lib.rs` | `Plugin`; the HTTP `Client` (release dates, vintages, key check, warm); `FredError`; the per-key budget table `BUDGETS` and `rate_limits`; `scrub`, which masks an echoed key. | `Client::get` |
| `plugins/fred/src/source.rs` | `Fred`, the `Source` the hub seats; `FACTS`; `CAP`, the bars-table row that serves no bars; `VALUES`, FRED's release ids and series for each headline event; `read`, which answers the join's words. | `Source::read` |
| `plugins/fred/src/offer.rs` | `OFFER`: what `data/coverage` lists as FRED's offer (class-less `economic`, history only). | `CLASSLESS` |
| `plugins/fred/tests/egress.rs` | The bytes FRED is sent, a redirect left unfollowed, and a refused send to an ungranted host. | `rest` |
| `plugins/fred/tests/egress/rest.txt` | The golden of every request `rest` sends. | — |
| `plugins/fred/tests/live.rs` | The live suite against your key. | `vintages` |
| `plugins/fred/ui/mark.svg` | The mark Connections draws. | — |

## How it plugs into Taji

**Composition.** `taji-open` adds `taji_fred::Plugin` (`engine/crates/taji-open/src/lib.rs`), whose `build` registers `source::Fred` as the hub provider `fred`. Its only Taji dependency is `taji-plugin`, with its `vendor` feature ([0003](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0003-plugin-on-sdk-alone.md)).

**Traits.** `Fred` implements the SDK's `Source` (`engine/crates/taji-plugin/src/vendor/`): `facts`, `seat`, `probe`, `history`, `hosts`, `check`, `read` and `rate_limits`. It implements no `HistoricalData` (`history` refuses `fred serves no bars`), no `LiveStream`, no `VenueReads`, `ExecutionOps` or `ReconcileOps`.

**`FACTS`** (`source.rs`):

- `seat: Seat::Key { anew: false }`: seated on its own data key, sealed under `fred`. The seated login keeps its values after the vault locks, so reads go on.
- `unclassed: [(Economic, History)]`: one class-less product, history only.
- `permits: SOCKETS`: 16 calls at once through the hub's gate, the bound for a vendor that documents no concurrency limit (`engine/crates/taji-plugin/src/vendor/gate.rs`).
- `stores_none: true`: no answer is pulled into the hub's store.
- `bars_cap: Some(&CAP)`: a bars-table row with no classes, cost `Free`, `rate_per_min` 120, so the coverage tables list FRED.
- `releases: Some(VALUES)`: FRED's role in the `economic` join is `Role::Values`. `VALUES` maps each of the kernel's 18 headline releases to FRED's release id (`cpi` 10, `nfp` 50, `fomc` 101, `durable_goods` and `factory_orders` both 95) and each headline event to a series and a `Transform` (`cpi.mom` is `CPIAUCSL` `pch`, `cpi.yoy` is `CPIAUCNS` `pc1`, `nfp.payrolls` is `PAYEMS` `chg`). Its `today` dates FRED's newest vintage on the America/Chicago calendar.
- `offer: Some(&OFFER)`. There is no `VenueFacts`: FRED is no venue.

**Link form.** The manifest's one form, `fred` (`kind = "fields"`), takes one secret field, `key`; its steps are the manifest's ([`taji-plugin.toml`](https://github.com/TajiAI/Taji/blob/main/plugins/fred/taji-plugin.toml)). The form posts to `POST /verb/link/data/link` with `provider: fred`.

**Words.** The join asks through `Source::read` in the words of `engine/crates/taji-plugin/src/vendor/releases.rs`: `release_dates=<first>,<last>`, or `series_id`, `vintage_dates` and `observation_start`. `read` answers `{"rows": [...]}`, built by that module's `dated` and `observed`, which the hub reads back with `dates_of` and `vintages_of`. Any other ask is `NoSource`.

| Taji surface | Vendor call | Made in |
|---|---|---|
| `GET /get/economic`, a headline row's `actual`, `prior`, `prior_revised_from`, `period`, `values` `fred` | `series/observations?output_type=2&vintage_dates=…` | `Client::vintages` (`lib.rs`), asked by `valued` (`engine/crates/taji-trading/src/hub/sources/economic.rs`) |
| `GET /get/economic`, a date-only headline row where Yahoo lists none | `releases/dates?…&limit=1000&offset=N` | `Client::release_dates` (`lib.rs`) |
| `GET /get/economic?provider=fred` | both of the above, Yahoo not asked | `economic.rs` |
| `POST /verb/link/data/link`, the key check before sealing | `series?series_id=GNPCA` | `Source::check` (`source.rs`), within `CHECK_TIMEOUT` (5 s) |
| The connection kept open | `series?series_id=GNPCA` every 300 s | `Client::warm`, started by `Fred::build` through `Cx::keep_warm` |
| `GET /read/link/rate_limits`, scope `requests`, draws `economic`, quota 120 | none | `rate_limits` (`lib.rs`) |
| `GET /read/data/coverage`, its `economic` entry; [coverage page](https://docs.taji.is/reference/coverage/fred.md) | none | `OFFER`, `FACTS` |
| `GET /read/link/forms`, the `fred` form | none | `taji-plugin.toml` |

The route rows that own each answer's full shape are in the `//!` header of `engine/crates/taji/src/wire/mod.rs`.

**One read, wire to vendor and back.** `GET /get/economic?from=2026-10-12&to=2026-10-19&releases=cpi`:

1. `parse_economic` (`engine/crates/taji/src/wire/data.rs`) builds the `Get`; the hub's `economic.rs` asks Yahoo's calendar for the span.
2. `valued` asks FRED `releases::dates_ask(first, last)` for headline releases Yahoo did not list, then, per series, one `vintages_ask` carrying every vintage its rows need (the day before and the day of each release; the day of and the day after for the FOMC decision), from 500 days before the earliest release.
3. `Fred::read` takes the seated client, or answers `NoStoredCredentials` while none is seated, and runs the call through `Cx::call`, the provider's gate.
4. `Client::get` admits one charge against the key's budget, refusing unsent as `RateLimited` when it is short or held. It then builds the GET with `api_key` set to the login's marker, never the key, and sends it through `Login::send` (`substrate/taji-brokerage/src/egress.rs`), which swaps the marker for the key only toward the granted host `api.stlouisfed.org`.
5. The answer maps by status: 429 holds the budget 60 s and is `RateLimited`; 5xx and transport errors are `Unreachable`; another non-2xx is `Refused` with FRED's `error_message`, scrubbed of any 32-character key; 2xx parses, and `observation` turns each `<SERIES>_<YYYYMMDD>` column into a vintage, `"."` into `None`.
6. `read` returns rows; `economic.rs` computes `actual` and `prior` by the event's `Transform` and fills the row with `values` `fred` and Yahoo's `estimate` kept.

FRED takes no orders and sends no messages, so there is no order path.

## Why it is built this way

- **Point-in-time by vintage, not by `realtime` range.** One `output_type=2` call answers a series at every vintage a span's rows need, so a figure is what was knowable on its release day and a revision shows as `prior_revised_from`. A vintage that does not yet hold an observation has no column, which the client keeps as absent, never as zero (README [API](https://docs.taji.is/catalog/fred.md#api)).
- **Yahoo dates, FRED values.** FRED's calendar is its own: no row carries a time, rid 101 is dated every day, and rid 27 and rid 95 carry dates the agencies do not (README [API](https://docs.taji.is/catalog/fred.md#api)). So Yahoo's calendar dates a release where it lists one, FRED's dates fill only what Yahoo leaves out, and the FOMC decision is never dated by FRED. An id two headline releases share (95) dates neither (`economic.rs`).
- **Levels in, figures computed by the kernel.** The client never sends `units`; the kernel applies `Transform` ([0001](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0001-kernel-computes.md)). This also avoids the column renaming non-`lin` units cause.
- **Nothing stored.** The terms forbid storing or caching FRED content, so `stores_none` keeps answers out of the store and each read asks FRED again.
- **The key never leaves the egress table.** The client holds a `Login`, puts its marker in the query, and lets `Login::send` substitute it toward the granted host alone. `send`'s errors carry no URL, the response URL is never read, `Debug` for `Client` prints only the base, and `scrub` masks a key FRED echoes in an error ([0005](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0005-no-key-reaches-a-client.md)).
- **One budget per key, never waiting, never retrying.** FRED counts per key, so every client on one login shares one sliding 120-a-minute budget in `BUDGETS`. A read refused at once beats a read that queues past its deadline; a 429 holds the budget for FRED's minute so no further request risks the "temporary block".
- **500 vintages per call.** The observations page caps JSON at 2,000 ([series/observations](https://fred.stlouisfed.org/docs/api/fred/series_observations.html), fetched 2026-12-02), but FRED's edge refuses a URL past about 8 KB: 600 vintages answered 200 and 700 a 400 (README [API](https://docs.taji.is/catalog/fred.md#api)). More are split into calls and merged.
- **Warm every 300 s.** The host drops an idle connection between 420 and 600 s (README [API](https://docs.taji.is/catalog/fred.md#api)); a warm costs one request of the 120.
- **A fresh client at each seat.** `seat` builds the client anew over the linked key's login, so a relinked key is the one read.
- **Through the hub as `economic`, never a FRED route.** No client sees a FRED shape; a second values source fills the same `Role::Values` ([0004](https://github.com/TajiAI/Taji/blob/main/docs/decisions/0004-capabilities-through-the-hub.md)).

## Constraints and limits

- **Rate.** `queue::admit` charges each GET against the key's `Budget` (120 a minute, sliding). A short or held budget is `FredError::RateLimited` with its retry-after, unsent; `trading` maps it to `TradingError::RateLimited`, which the gate turns into a not-before for later calls. In a joined read FRED's part carries the refusal while Yahoo's rows still answer. The measured numbers are in the README's [API](https://docs.taji.is/catalog/fred.md#api).
- **Concurrency.** The gate holds 16 calls; FRED states no ceiling, an open item in the README's [Open](https://docs.taji.is/catalog/fred.md#open).
- **Dates.** `realtime_start` after FRED's today is a 400 and a future vintage is a 500 (README [API](https://docs.taji.is/catalog/fred.md#api)). `Values::today` keeps every vintage on or before FRED's today in Chicago.
- **Span.** `get/economic` answers at most 31 New York days per read (`MAX_DAYS` in `economic.rs`).
- **Timeout.** Each GET is bounded at 10 s; a key check at 5 s.
- **Symbology.** Series ids and release ids are FRED's own and live only in `VALUES`; no client names them except as a row's `series` and `release_id`.
- **Entitlements.** None: a key grants no class, so `probe` returns an empty `Plan` and `check` a verdict with no plan.
- **Third-party series.** Some series need the owner's permission beyond personal use (README [Terms](https://docs.taji.is/catalog/fred.md#terms)).

## Examples

**What Taji sends.** The egress golden for `rest`: two pages of release dates (`count` 1001), one series at two vintages, then the key check. The key is the test's synthetic `fred-TEST`. From `plugins/fred/tests/egress/rest.txt`, headers trimmed:

```text
http GET /releases/dates?api_key=fred-TEST&file_type=json&realtime_start=2026-10-12&realtime_end=2026-10-19&include_release_dates_with_no_data=true&order_by=release_date&sort_order=asc&limit=1000&offset=0
http GET /releases/dates?api_key=fred-TEST&file_type=json&realtime_start=2026-10-12&realtime_end=2026-10-19&include_release_dates_with_no_data=true&order_by=release_date&sort_order=asc&limit=1000&offset=1000
http GET /series/observations?api_key=fred-TEST&file_type=json&series_id=CPIAUCSL&output_type=2&vintage_dates=2026-10-13%2C2026-10-14&observation_start=2026-06-01
http GET /series?api_key=fred-TEST&file_type=json&series_id=GNPCA
accept: */*
accept-encoding: gzip
```

**A vintage answer.** The body of `vintage_columns_parse_dots_and_absent_columns` in `plugins/fred/src/lib.rs`, shaped as FRED's `output_type=2` answer, its figures made up. September is absent at the 10-13 vintage and present at 10-14; October is `"."`, missing:

```json
{"observations": [
  {"date": "2026-08-01", "CPIAUCSL_20261013": "300.100", "CPIAUCSL_20261014": "300.100"},
  {"date": "2026-09-01", "CPIAUCSL_20261014": "300.200"},
  {"date": "2026-10-01", "CPIAUCSL_20261013": ".", "CPIAUCSL_20261014": "."}
]}
```

**Release dates and a refused key.** The hub's fake FRED, `fred_for` in `engine/crates/taji-trading/src/hub/tests.rs`, answers its key's `releases/dates` and every other key with FRED's 400:

```json
{"count":1,"release_dates":[{"release_id":10,"release_name":"Consumer Price Index","date":"2026-10-14"}]}
```

```json
{"error_code":400,"error_message":"Bad Request.  The value for variable api_key is not registered."}
```

The client maps that 400 to `Refused`, and the link answers 409 `rejected` with FRED's words as `reason`.

**The kernel's answer.** `GET /read/data/coverage`, its `economic` entry, from `engine/crates/taji/tests/fixtures/wire/data-coverage.json` (releases trimmed):

```json
{"as_of": "2026-10-27", "linked": false,
 "offered_data": {"history": ["economic"], "live": [], "realtime": [],
   "note": "the headline releases' dates and each series' observations at each ALFRED vintage, on Yahoo's calendar rows; never stored (FRED's terms)"},
 "provider": "fred", "reads": {"history": ["economic"], "live": [], "realtime": []},
 "releases": ["nfp", "cpi", "ppi", …, "industrial_production", "fomc"],
 "source": "https://fred.stlouisfed.org/docs/api/fred/"}
```

**A `get/economic` row on FRED's values.** No capture yet. `economic_walk.py <port> linked` writes one to `<state dir>/economic-walk-linked-<UTC instant>.txt` on a headless kernel with your key linked. The test `fred_linked_a_headline_row_takes_freds_values_and_yahoos_estimate` (`economic.rs`) asserts the shape offline: for the CPI of 2026-10-14, `cpi.mom` has `values` `fred`, `unit` `percent`, `period` 2026-09-01 and Yahoo's `estimate`; `cpi.yoy` is added with `series` `CPIAUCNS` and `transform` `pc1`.

## Testing

| What | Command | Needs |
|---|---|---|
| Client, mapping and source, offline | `cargo test -p taji-fred` | nothing; runs the `src/` tests and `tests/egress.rs` |
| Re-record the egress golden after a deliberate request change | `EGRESS_RECORD=1 cargo test -p taji-fred --test egress rest` | nothing |
| The join with FRED's role | `cargo test -p taji-trading --lib hub::sources::economic` | nothing; a wiremock FRED |
| Seating, linking and unlinking a FRED key, and the join's FRED cases | `cargo test -p taji-trading --lib fred` | nothing |
| Live suite | `cargo test -p taji-fred --test live -- --ignored --test-threads=1` | `FRED_API_KEY` for `release_dates` and `vintages` (SKIP without it); `check` reaches FRED with a made-up key and needs none |
| Linked over the wire on the shipped binary | `engine/crates/taji-open/scripts/vendor_live.sh fred` | `FRED_API_KEY`; links it on a scratch kernel and reads `/get/economic` asserting `values` `fred` |
| The economic walk | `engine/crates/taji-open/scripts/economic_walk.py <port> unlinked\|linked\|at` | a headless kernel you booted; `linked` and `at` need the key linked, and the script reads `FRED_API_KEY` itself to cross-check values against FRED |

FRED has no paper or sandbox: every live call reads production and spends your key's budget. Nothing here places an order.

## References

- FRED API overview: https://fred.stlouisfed.org/docs/api/fred/ (fetched 2026-12-02)
- `fred/releases/dates`: https://fred.stlouisfed.org/docs/api/fred/releases_dates.html (fetched 2026-12-02)
- `fred/series/observations`: https://fred.stlouisfed.org/docs/api/fred/series_observations.html (fetched 2026-12-02)
- `fred/series`: https://fred.stlouisfed.org/docs/api/fred/series.html (fetched 2026-12-02)
- `fred/series/vintagedates`: https://fred.stlouisfed.org/docs/api/fred/series_vintagedates.html (fetched 2026-12-02)
- Real-time periods: https://fred.stlouisfed.org/docs/api/fred/realtime_period.html (fetched 2026-12-02)
- Errors and rate limit: https://fred.stlouisfed.org/docs/api/fred/errors.html (fetched 2026-12-02)
- API keys: https://fred.stlouisfed.org/docs/api/api_key.html (fetched 2026-12-02)
- Version 2 and its keys: https://fred.stlouisfed.org/docs/api/fred/v2/index.html, https://fred.stlouisfed.org/docs/api/fred/v2/api_key.html (fetched 2026-12-02)
- API terms of use: https://fred.stlouisfed.org/docs/api/terms_of_use.html (fetched 2026-12-02)
- FRED legal: https://fred.stlouisfed.org/legal/ (fetched 2026-12-02)
