Repository navigation
API returns empty array for invalid ticker symbols #142
Description
Activity
- addedhelp wantedExtra attention is neededExtra attention is neededquestionFurther information is requestedFurther information is requested
on Feb 12, 2025 Hi @scott-david-walker, you are correct I did this intentionally. The FMP API almost always returns
200 OK, even if the input is 100% wrong.Example: https://financialmodelingprep.com/api/v3/income-statement/DOESNOTEXIST?period=incorrect returns
[]and200 OK.I will create a support ticket to see if they plan on dealing with this in a better way.
I do like the idea of making this behavior configurable.
You can also consider calling
api.CompanyValuation.GetSymbolsWithFinancialStatementsAsync();first to verify if the symbol will return valid data.scott-david-walker commented
on Feb 12, 2025 ContributorAuthorMore actionsAhh that is quite a poor API design from FMP point of view.
For the work around that you suggested, is there something similar for every other set of endpoints? For example with the "quote" endpoints is here also a "validation" call?
It not, I'll happily implement the configuration change if you agree with my suggestion?
Ahh that is quite a poor API design from FMP point of view.
I am still waiting for a reply from FMP support.
For the work around that you suggested, is there something similar for every other set of endpoints? For example with the "quote" endpoints is here also a "validation" call?
I think the
api.CompanyValuation.GetTradableSymbolsListAsync();should do the trick. At leastTEST.Vdoesn't show up in that list.They didn't implement my suggestion in the new stable API of FMP. It still returns
200 OKfor a non-existing symbol.We will have to live with the empty array for now.
Still open to suggestions on how to improve it for users of this library.
- changed the title
[-]Strange behaviour on Financial Modelling Prep returning empty array.[/-][+]API returns empty array for invalid ticker symbols[/+]on Dec 29, 2025
Calling
client.CompanyValuation.GetIncomeStatementAsync("TEST.V", Period.Annual, 10);is classed as an error when there is no data available. I find this behaviour odd as the request is successful and Financial Modelling Prep has returned the empty array.The behaviour is clearly intentional as it is done with this code snippet:
My question is whether this package should be classing this as an error as FinancialModellingPrep doesn't seem to? An empty array is a perfectly valid response if there is no data.
If you want this behaviour to remain, then what would be the best way to work around it? We can't check on the error string as "Invalid Parameters" is very generic and doesn't help us determine if the error is a FMP error or this specific handling of empty arrays.
Maybe we could have a variable when configuring the ApiClient? Something like "TreatEmptyArrayAsError"? If we set the default to true then we won't introduce breaking changes.
Interested to know your thoughts!
Cheers
Scott