Financial Modeling Prep Integration

In May a market-cap field in my Financial Modeling Prep client read None in production for an unknown number of runs. The response came back 200 and the lookup raised no error. A score that depends on it took its default value until an offline diagnostic run noticed.
Who this is for: anyone about to depend on a market-data vendor's JSON. In each incident below, the damage came from what my client concluded from the answer.
FMP in one screen#
What it is. Financial Modeling Prep (FMP) is a paid REST API for stock prices, financial statements, company profiles and reference data.
What I use it for. Company profiles, ratios and key metrics, the three financial statements, earnings dates, dividend-adjusted daily prices, quotes and the company screener. That data feeds the public market pages on this site (/today and the lab tools) and a private scoring engine.
How it is built. One async client on FMP's /stable surface, a read-through cache with a time to live per endpoint, and a typed result for a fetch that failed.
Plans and coverage. Plans differ in call rate, history depth and coverage. I started on the Starter plan and later moved to Ultimate. Two endpoints I called were not in the Starter plan, which matters below.
When it is the wrong tool. If your research needs companies that no longer trade, check coverage first. In my tests, delisted names were thin and a reused ticker could return a different company's history.
Five answers my client misread#
The table separates what the API said from what my code decided it meant.
| What the API answered | What my client concluded | Repair | Still open |
|---|---|---|---|
| 200, with a field missing under the name I read | The value is None; carry on |
Backfill the old key from the new one at assembly | No test checks field names against a live response |
| 404 on a path I still called | No data: empty price history, "no upcoming earnings", an input set to zero | Moved to the current paths | A 404 is still not treated as its own failure class |
| 200 with an empty list for a dotted share-class symbol | This company has no data | Convert to the hyphen form at the query boundary | One caller still sent the dotted form when the fix merged |
| 200 with about five years of rows when I asked for 260 days | The oldest row is one year ago | Trim to the last N rows client-side; the board now picks its one-year comparison row explicitly and handles short history | None known |
| 402 on an endpoint outside my plan | A transient error; try again | Stopped calling it and took the rate from another source | 402 and 403 are still retried like network errors |
The missing field#
The profile response had marketCap. My code read mktCap. I had moved the client from FMP's older surface to /stable in one day in April and kept the field names I already had.
At the time I wrote the fix up as a vendor rename. The record supports a narrower statement: my client changed surfaces, and the current /stable profile has no mktCap key. I cannot show when, or whether, FMP ever served that key there. The likelier cause is my own migration.
Within two days of that fix, three more fields turned out to be null under their old names. One of them was on a different endpoint.
My endpoint probe did not catch it. It checked status codes and body length, and the endpoint returned 200 with a body.
The failure that hid it#
The missing field sat behind an earlier failure with the same symptom. A Treasury yield quote I requested on every run was not in my plan and answered 402. The rate fell back to a static value, and the same score took its default. Only after I moved that rate to another source did the second cause show.
The 402 also cost calls. My client made three attempts per symbol, one call and two retries, for a request that could not succeed.
The ignored parameter#
The daily price endpoint on /stable documents symbol, from and to. I was sending a row-count parameter it does not document, and it ignored it. A request for 260 days returned about five years.
A public board on this site computed its one-year move from the oldest row returned. It published a multi-year move labelled one-year. I found it in July, when about a fifth of its rows looked absurd enough to notice.
What the client does now#
The diagram covers the fundamentals path: profile, ratios, key metrics and statements for one company.
A typed failure. When attempts run out, the client returns FetchFailed and emits one metric per endpoint. Callers that ask for strict mode get the exception. Older callers still see an empty list, on purpose, so the type only helps code that checks for it.
An integrity gate with limits. If the profile fetch fails, or all three statement fetches fail, the gate after assembly raises and writes nothing. A partial failure still produces a result, marked as degraded and never cached. The gate does not cover a successful response with a missing field.
Field shims. Each shim backfills an old key only when it is None, so the code downstream did not change. The market-cap shim fills the profile's old key from the key-metrics response (comments trimmed):
prof_dict = profile[0] if profile else {}
km_dict = metrics_ttm[0] if metrics_ttm else {}
if prof_dict.get("mktCap") is None and km_dict.get("marketCap") is not None:
prof_dict["mktCap"] = km_dict["marketCap"]
A row window enforced client-side. The shared price fetch sorts ascending and keeps the last N rows (comments trimmed):
ordered = sorted(normalized, key=lambda d: d.get("date") or "")
if days <= 0:
return ordered
return ordered[-days:]
One exporter that needs deep history does it differently: it requests explicit from and to windows and pages by date.
Unit and shape defences. The profile's last dividend is a dollar amount, so it never fills a yield field. The 52-week range string is parsed with an anchored pattern that returns None on any shape it does not expect.
What it does not cover yet#
No test calls the live API in CI. Live checks are a manual probe of about 30 paths, and that probe cannot see a field that changed name.
The retry loop does not read Retry-After, and it treats 402 and 403 like a network error. One cache write, for the screener, is unconditional, so a failed screen could be served from cache for an hour. I found that by reading the code and have not seen it happen.
A requests-per-minute setting exists in config and nothing reads it. The client limits concurrency, not rate.
Every incident here was found by a person or an offline run. The failure metric and the code for its alarm came after May. I have not confirmed the alarm is deployed, and neither one can see a 200 with a missing field.
I did not measure how many runs or public rows each defect touched, or the exact dates each was live in production.
Tests to write#
- Record a live response for each endpoint and assert that every field you require is present, and decide per field whether null is allowed.
- Treat a 404 as a failure. Treat an empty list as a failure when that endpoint and window should have rows.
- Send
fromandto, and bound the window yourself. Do not trust a row-count parameter. - After a confirmed plan or access error, do not retry the unchanged request.
- When you change API surfaces, check every path and field against the current docs and a live response before the switch.
- Never cache a failed fetch. Return a type that says failed, not an empty list.
- Normalize symbol formats at the boundary.
- For research, test for missing delisted companies and reused tickers before trusting history.
Reference#
These are my client's configured defaults, not FMP limits.
| Setting | Value |
|---|---|
| Surface | /stable |
| Key | Environment configuration, else a secret store |
| Timeout | 30 s per request |
| Attempts | 3 per request |
| Wait on 429 | 2 s, 4 s, then 8 s |
| Wait on other errors | 1 s, then 2 s |
| Concurrency | 5 symbols at a time |
| Cache: profile | 7 days |
| Cache: ratios, key metrics | 4 hours |
| Cache: earnings calendar | 6 hours |
| Cache: screener | 1 hour |
| Cache: quote | 15 minutes |
The field-contract test is the one I still have not built, and it is the one that would have caught May.
Sources, as of December 2, 2026: the client, cache and configuration code at their current main revisions; incident details from the pull requests that fixed them, not re-measured; FMP facts from its developer docs, stable profile and daily price pages, pricing plans and changelog, read on December 2, 2026.