Skip to content

API returns empty array for invalid ticker symbols #142

Description

@scott-david-walker

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

Activity

  1. self-assigned this
    on Feb 12, 2025
  2. Matthiee commented on Feb 12, 2025

    @Matthiee
    Member

    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.

  3. scott-david-walker commented on Feb 12, 2025

    @scott-david-walker
    ContributorAuthor

    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?

  4. Matthiee commented on Feb 13, 2025

    @Matthiee
    Member

    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.

  5. Matthiee commented on Dec 29, 2025

    @Matthiee
    Member

    They didn't implement my suggestion in the new stable API of FMP. It still returns 200 OK for 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.

  6. changed the title [-]Strange behaviour on Financial Modelling Prep returning empty array.[/-] [+]API returns empty array for invalid ticker symbols[/+] on Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is neededquestionFurther information is requested

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions