# Syncing filings, statements and estimates

A nightly job for SEC filings, financial statements and estimate revisions: overlapping windows, resumable pages and what arrives late.

Filings, statements and estimate revisions have no change feed. A nightly job keeps them by reading a window that overlaps its last run, upserting by each row's key, and following each page to the end. The overlap catches what arrives late; the key makes reading a row twice harmless.

## Filings

```bash
curl "https://api.gloom.sh/v1/filings?symbols=AAPL,MSFT,KO&forms=10-K,10-Q,8-K&from=2026-11-12&limit=50" \
  -H "Authorization: Bearer $GLOOM_DATASETS_KEY"
```

- Read `from` three days before your last run, and upsert by `accessionNumber`. A filing is dated by the day SEC gives it, `filingDate`, and one can reach the list after your run under a day you have read already.
- Follow `meta.next` until it is null. A page with `meta.page.retryAfter` is sent again after that wait, as [paging](https://gloom.sh/datasets/docs/paging) says. Save `meta.page.nextCursor` after each page: a run that stops resumes from it with the same query.
- `meta.dataThrough` is when the company's list was last read whole, the same on every page, and `meta.updatedAt` its newest filing. On a quiet weekend `dataThrough` still moves; one that stays put from one run to the next is a list not brought up to date. Null means it is not known.
- Send each page's `ETag` back as `If-None-Match`: an unchanged page is a free `304`.
- A company that took over another registrant's reporting under a new CIK lists that registrant's filings through the day it took over, each under its own `cik`.
- A receipt and its home line, such as `TM` and `7203.T`, read one filer: `meta.symbols` gives both the same `cik`. Keep one per `cik`, or each is charged for the same filings. A listing with no SEC filer is `empty` and free.

## Statements

`/v1/fundamentals/statements` has no window. Read a company's statements again when the filings sync above brings a 10-K, 10-Q, 20-F, 40-F or an amendment for it, rather than every listing every night:

```bash
curl "https://api.gloom.sh/v1/fundamentals/statements?symbols=AAPL&period=quarterly&limit=12" \
  -H "Authorization: Bearer $GLOOM_DATASETS_KEY"
```

- Replace the periods you hold for that company whole. A filing restates earlier periods and adds lines to them, so a period you hold can change without a new period appearing.
- Without `asOf` a period has every line it has today. With `asOf` it is as the filings by then stood: a line no filing by then reports, another source's line included, is left out and named in `unavailableFields`, even with `asOf` of today. Sync without `asOf`; keep `asOf` for point-in-time work.
- A US share class such as BRK.B is read from market data alone, and a `partial_history` notice says from which period.

## Estimate revisions

```bash
curl "https://api.gloom.sh/v1/analyst-estimates/revisions?symbols=AAPL,KO&from=2026-11-09&limit=1000" \
  -H "Authorization: Bearer $GLOOM_DATASETS_KEY"
```

- Each day's consensus is recorded once a day after the US close, every calendar day, weekends included, and dated `observedOn`. Read `from` seven days before your last run and upsert by symbol, `observedOn` and `period`: a day read again is stored again, with a later `recordedAt`.
- A day with no reading on the day can be filled in later from a later read's look back of 7 to 90 days: `derived` is true, it has an average only, and it is kept only where the period it names that day is proven. Read the last 90 days once a week to pick those up.
- `meta.coverage.observedFrom` is the first day read on the day: the days before are derived. `meta.coverage.unobservedDays` lists the days of your window since then with no reading on the day. Such a day is never made up afterwards; at most a derived row fills it.
- An empty page's `meta.dataThrough` is the newest day the listing's history holds. Older than yesterday means its recording is behind.
- `asOf` leaves out a day recorded after it, so a derived day is never in an `asOf` answer for the days it stands for.

## A run

- Keep, for each dataset, the day of your last complete run and the cursor of each listing's last page. Move the day forward only once every listing reached its last page.
- What changes after the fact: a filing listed under an earlier day, a period restated by a later filing, an estimate day read again or derived later. The three-day window, the statements read on each new filing and the weekly 90-day estimates read cover them.
- To start, or to backfill many listings, an [export](https://gloom.sh/datasets/docs/bulk) reads each listing's first page before any second, within `maxCredits`, and names in `truncated` where each listing stopped. Its quote's `estimate` gives each listing's rows and pages first: a busy filer's history runs to thousands of pages, more than the 5,000 rows one query pages, so split its window with `from` and `to`.

- [Previous Polling catalysts](https://gloom.sh/datasets/docs/catalysts)
- [Next Errors](https://gloom.sh/datasets/docs/errors)
