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
fromthree days before your last run, and upsert byaccessionNumber. 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.nextuntil it is null. A page withmeta.page.retryAfteris sent again after that wait, as paging says. Savemeta.page.nextCursorafter each page: a run that stops resumes from it with the same query. meta.dataThroughis when the company's list was last read whole, the same on every page, andmeta.updatedAtits newest filing. On a quiet weekenddataThroughstill 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
ETagback asIf-None-Match: an unchanged page is a free304. - 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
TMand7203.T, read one filer:meta.symbolsgives both the samecik. Keep one percik, or each is charged for the same filings. A listing with no SEC filer isemptyand 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
asOfa period has every line it has today. WithasOfit is as the filings by then stood: a line no filing by then reports, another source's line included, is left out and named inunavailableFields, even withasOfof today. Sync withoutasOf; keepasOffor point-in-time work. - A US share class such as BRK.B is read from market data alone, and a
partial_historynotice 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. Readfromseven days before your last run and upsert by symbol,observedOnandperiod: a day read again is stored again, with a laterrecordedAt. - 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:
derivedis 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.observedFromis the first day read on the day: the days before are derived.meta.coverage.unobservedDayslists 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.dataThroughis the newest day the listing's history holds. Older than yesterday means its recording is behind. asOfleaves out a day recorded after it, so a derived day is never in anasOfanswer 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 reads each listing's first page before any second, within
maxCredits, and names intruncatedwhere each listing stopped. Its quote'sestimategives 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 withfromandto.