# Agent recipes: ten questions, one call each

Every call below is REST with `X-API-Key`; the MCP tool of the same name takes the same arguments
(hosted / local adapter names in brackets). Ask for `shape=compact` (the MCP default): the same values
as the verbose shape at a fraction of the tokens (measured medians over the 100-question agent
evaluation: about 180 tokens for one value, about 780 for a company snapshot, about 2,000 for a
15-line income statement over 8 quarters; `docs/reports/2026-11-14-compact-responses.md`). Values are
exact decimal strings; an empty cell is never zero and always carries `empty` and `code`.

**1. Latest annual revenue** (`list_financial_statements` / `get_financial_statements`)

<!-- example: run -->
```bash
curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/AAPL/statements?statement=income&period_type=annual&periods=1&fields=revenue&shape=compact"
```

<!-- example: response 200 -->
```json
{ "data": { "columns": [{ "p": ["annual", "2025-09-28", "2026-09-26", 2026, "FY"], "s": "s1" }],
  "rows": { "revenue": ["478834000000"] },
  "sources": { "s1": "0000320193-26-000026 10-K 2026-11-03 COMPANYFACTS_CONTEXT_LIMITED" } } }
```

**2. Eight quarters of a statement** (same tool): `period_type=quarterly&periods=8`. A fourth quarter
the issuer reports only inside its 10-K is not a quarterly column; drop `fields` for every line.

<!-- example: run -->
```bash
curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/AAPL/statements?statement=income&period_type=quarterly&periods=8&fields=revenue,net_income&shape=compact"
```

**3. Trailing twelve months** (`list_trailing_twelve_months` / `get_trailing_twelve_months`). Annual +
current year to date − prior year to date, all from the latest 10-Q's own filing; the three input facts
come with the value. When no 10-Q anchor qualifies the answer is empty with a warning code (for example
`TTM_ANCHOR_UNAVAILABLE`), never a substitute.

<!-- example: run -->
```bash
curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/AAPL/trailing-twelve-months?metrics=revenue&shape=compact"
```

**4. Compare two companies**: one call per issuer with the same `fields` and `period_type`, then compare
by period dates (`columns[i].p`), not by fiscal-year labels: Apple's fiscal 2025 ends in September,
Microsoft's in June.

<!-- example: run -->
```bash
for t in AAPL MSFT; do curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/$t/statements?statement=income&period_type=annual&periods=1&fields=revenue,net_income&shape=compact"; echo; done
```

**5. Was this figure restated?** (`list_facts` / `get_financial_facts` with `view=as_reported`): read
every filing's value for that one period. The as-reported view lists one fact per filing that reports
it, each with its accession number, so two different values for one period are a restatement.

<!-- example: run -->
```bash
curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/AAPL/facts?metrics=revenue&view=as_reported&period_type=annual&period_end=2024-09-28"
```

**6. Is this value reported or calculated?** Read `st` on the cell, else `defaults.status`: `reported`
(the issuer filed it) or `calculated` (stocks.team computed it, with formula and every input in `in` and
`inputs`). Derived metrics are always calculated:

<!-- example: run -->
```bash
curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/AAPL/metrics?metrics=gross_margin&period_type=annual&periods=1&shape=compact"
```

<!-- example: response 200 -->
```json
{ "data": { "defaults": { "quality": "review_required", "status": "calculated" },
  "rows": { "gross_margin": [{ "v": "0.487855916664", "in": { "gross_profit": "f1", "revenue": "f2" } }] },
  "inputs": { "facts": { "f1": { "v": "233602000000" }, "f2": { "v": "478834000000" } } } } }
```

**7. The same answer again** (any financial tool, `read_at`): every financial read returns `readAt`, the
publication fence it read. Send it back as `read_at` and a related read (the next page, another statement)
reads the same published state, until the next publication of that issuer. After it, a request with that
`read_at`, or with a facts cursor (which carries the fence), is answered `403 AS_OF_READS_CLOSED` with
`details.reason` `read_fence_superseded`, `details.currentReadAt` and no values: start again without
`read_at` and `cursor`, and use the new `readAt`. Reads as known on a past date (`as_of`) are not offered
yet: a request that names `as_of` is answered `403 AS_OF_READS_CLOSED` with no values and no
`details.reason`, because a value for a past date is shown only once it can be proven for that date. Omit
`as_of` to read the current values.

<!-- example: run -->
```bash
read_at=$(curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/AAPL/statements?statement=income&period_type=annual&periods=1&fields=revenue" | sed -n 's/.*"readAt":"\([^"]*\)".*/\1/p')
curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/AAPL/statements?statement=income&period_type=annual&periods=1&fields=revenue&read_at=$read_at&shape=compact"
```

**8. Why is this cell empty?** (`describe_codes`) Pass the codes you saw:

<!-- example: run -->
```bash
curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/codes?codes=NOT_APPLICABLE_ENTITY_TYPE,review_required"
```

<!-- example: response 200 -->
```json
{ "data": { "codes": {
  "quality": { "review_required": "Served from the SEC Company Facts aggregate or with a caveat; not matched to the original filing. Read the value's warning codes." },
  "empty": { "NOT_APPLICABLE_ENTITY_TYPE": "The applicability table marks this metric not applicable for the issuer's entity type." } } } }
```

**9. How is this company doing?** (`get_company_snapshot`): identity, latest annual and fiscal-quarter
columns, TTM and growth for the chosen figures, with quality and sources, in one call.

<!-- example: run -->
```bash
curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/AAPL/snapshot?figures=revenue,net_income"
```

**10. The full evidence for one cell**: the same read with `shape=verbose`, one line item and one
`period_end` (statements: add `empty_cells=explain`). It adds the document hash, XBRL path, concept,
snapshot and selection rule. Reuse the earlier `readAt` as `read_at` to read the same publication.

<!-- example: run -->
```bash
curl -sS -H "X-API-Key: $STOCKS_TEAM_API_KEY" "https://stocks.team/api/v1/entities/AAPL/statements?statement=income&period_type=annual&periods=1&fields=revenue&period_end=2025-09-27&empty_cells=explain&shape=verbose"
```

Quality tiers, in order of strength: `verified` (matched to the issuer's original Inline XBRL filing),
`validated` (passes every deterministic check and has independent corroboration), `review_required`
(served with its evidence, not yet matched or corroborated). Method:
https://stocks.team/data-quality.
