Missing Data
Financial datasets are uneven. A valid symbol can have quotes but no options, history but sparse fundamentals, fundamentals but no analyst ratings, or a field that is present for one asset class and absent for another.
Missing Values
Treat missing data as part of the API contract.
| Shape | Meaning |
|---|---|
null | The field is known but no value is available for this symbol or time. |
| Empty array | The collection exists, but no rows matched the request. |
| Missing field | The field is not returned for that response shape. |
404 / endpoint_not_found | The requested route or catalog endpoint is not available. |
400 / bad_request | The request is malformed or missing a required parameter. |
Invalid Symbols
An invalid or unsupported symbol can produce an empty result, a response with missing quote fields, or an error depending on the endpoint. For user-entered input, search first:
curl "https://api.yfin.dev/v1/search?q=appl" \
-H "X-Yfin-Contact: you@example.com"
Then call quote or history with the selected symbol.
Defensive Handling
const quote = await client.quote(["AAPL"]);
const result = quote.data?.quoteResponse?.result?.[0];
if (!result?.regularMarketPrice) {
// Show an unavailable state instead of displaying 0.
}
history = ticker.history(period="1mo", interval="1d")
if history.empty:
print("No historical rows returned for this symbol and interval.")
Practical Rules
- Never convert missing price data to
0. - Keep nullable fields nullable in your own types.
- Display "unavailable" instead of inventing fallback values for financial metrics.
- For optional datasets such as options, analyst ratings, sustainability, and SEC filings, handle empty results as normal behavior.
- Use Errors to distinguish malformed requests, rate limits, and temporary service failures.