Investigate
The first thing I did was not write code. It was to find out whether the numbers already in use were true, and they weren't.
Two findings, both from reading the vendor's API documentation end to end and then testing it against production rather than trusting either one alone.
Finding one The extract had been reading one page of nine
The existing production script fetched page one and reported success. It had been doing that quietly for long enough that nobody questioned the totals.
The cause is easy to miss and impossible to see in the output: this API paginates with
an RFC 5988 Link header, not the ?page=2
convention almost every other API uses. If your code doesn't parse that header you
receive the first hundred records, a 200 OK, and no indication whatever
that more exist.
Measured against the fault-reports endpoint:
801 records across nine pages. A page-one-only read sees 100 of them: 12.5%.
Nothing errors. Nothing warns. The report renders, and it is wrong by a factor of eight.
Finding two The key data cannot come from the API
The pre-start records (the safety checks, with the odometer and hour readings inside
them) are write-only. You can push a pre-start into the system;
there is no endpoint that returns one. I verified this across the entire vendor
documentation repository, then proved it against production: GET on that
endpoint returns 404.
That matters more than it sounds. It means the obvious architecture (one API, one pipeline, one table) was never available. Any register combining asset details with pre-start readings has to join two sources of different kinds: an API, and a spreadsheet export from the vendor's web reporting.
An hour of reading the documentation properly changed the design more than any amount of coding would have. The build I would have shipped on day one would have been confidently wrong.