FinancialModelingPrep.NET icon indicating copy to clipboard operation
FinancialModelingPrep.NET copied to clipboard

Strange behaviour on Financial Modelling Prep returning empty array.

Open scott-david-walker opened this issue 11 months ago • 3 comments

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:


if (response.Data.Equals(EmptyArrayResponse, StringComparison.OrdinalIgnoreCase) || 
                    response.Data.Equals(EmptyArrayResponse2, StringComparison.OrdinalIgnoreCase))
{
    return ApiResponse.FromError<string>("Invalid parameters");
}

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

scott-david-walker avatar Feb 11 '25 22:02 scott-david-walker

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 [] and 200 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.

Matthiee avatar Feb 12 '25 14:02 Matthiee

Ahh 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?

scott-david-walker avatar Feb 12 '25 15:02 scott-david-walker

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 least TEST.V doesn't show up in that list.

Matthiee avatar Feb 13 '25 13:02 Matthiee