Get free API key

Learn

Choosing a financial data API: key items, statement hierarchy and XBRL facts

When you fetch financial data from ZENITH Code, start by deciding what you want to build. A revenue trend chart, a line-item breakdown table and an investigation of XBRL elements each need data in a different shape.

What you will learn

  • check_circleTrend charts, breakdown tables and element investigations need different data shapes.
  • check_circleCheck the parameters, fiscal period, missing values and result limits.
  • check_circleKeep each value with the conditions and source that explain it.

Decide the purpose, and the data you need narrows down

This page explains the differences between three entry points and what to check in one example request. Even with structured data, you still need to check the period, scope and missing values.

Rather than fetching everything available and deciding later, write the one row you want to display first. That makes it easier to choose the right API.

What you want to buildEntry point to choose firstShape you get
A chart of revenue and profit by yearincome-statementStandardized key items
Financial statements with headings and breakdownsfinancial-statement-fullLine-item parent–child relations and order
Investigating specific tags and contexts in a reportfinancial-factsValues per element and context

Choose the API entry point from the screen you want to build

  • Trend chart

    Standardized key items

    income-statement

  • Table with headings and breakdowns

    Line-item hierarchy and order

    financial-statement-full

  • Investigating report elements

    Values per tag and condition

    financial-facts

The three are options by purpose. Whichever you use, check the period, scope, unit and missing values.

Figure: this is not a ranking of capabilities. It is a guide to choosing by the result you need.

1. For key items over time: the income statement API

To compare revenue, operating income and similar items by year, start with the income statement API. Use key items such as revenue and operatingIncome.

Fetch annual data first and check fiscalPeriod, period and accountingStandard in the response. Do not assume the first element of the array is the year you intended; sort the rows explicitly in the order you display them.

CheckWhy
A parameter such as period=annualTo avoid mixing annual and quarterly data
fiscalPeriod and periodTo confirm the fiscal period and type actually returned
accountingStandardTo check how to interpret numbers under different standards
Whether a value is nullSo that missing values are not drawn as zero
Display unitTo make clear where yen is converted to larger units for display

Items lined up under the same name do not mean the company and year conditions are the same. Using standardized items and judging whether a comparison is valid are separate.

2. For breakdowns and order: the financial statement hierarchy

To display table headings and line-item breakdowns, see the full financial statements API. Fields such as depth, parent_key and sort let you handle hierarchy and order.

For example, to show “Current assets” under “Assets”, and individual items under that, an array of amounts alone does not tell you the parent–child relations. Keep the parent and the order first, then decide on indentation and other display details.

InformationHow it is used in a table
DepthSets the indentation of headings and breakdowns
ParentTracks which item a line belongs under
OrderKeeps the sequence under the same parent
Original tag and labelConfirms which line item it is
Context and similarConfirms the conditions of the value

The presentation hierarchy is not necessarily an addition formula. If you compare a parent's number with the sum of its children, also check signs, aggregation scope, heading rows and so on.

In this API, the parameter for the full year is quarter=FY. Do not copy period=annual from the income statement as is. Even for similar uses, check the parameter names and formats for each endpoint.

3. To investigate tags and contexts: XBRL facts

The XBRL facts API for annual securities reports is the entry point for values per element and context. You can filter with category for the classification and tag for a partial match on the element name.

Here, a fact means one reported value. The same element with a different period or scope is a different candidate. Do not adopt a returned row unconditionally as the company's current figure.

Keep your first request small

The example below requests up to 20 rows from the balance sheet classification for Toyota Motor (7203) for the fiscal year ended March 2026. It does not mean that 20 rows cover every item.

ParameterValueMeaning
symbol7203The company's securities code
fiscalPeriod2026-03Fixes the target fiscal period
categoryBalance_SheetThe balance sheet classification
limit20Maximum number of rows returned

Real requests need an account and an API key. Replace YOUR_API_KEY below with your own key. Do not paste your key into articles or public repositories. Requests count against your quota, so check your current plan and usage in the docs and the dashboard.

curl --fail-with-body --get \
  'https://api.zenithcode.net/stable/financial-facts' \
  --header 'x-api-key: YOUR_API_KEY' \
  --data-urlencode 'symbol=7203' \
  --data-urlencode 'fiscalPeriod=2026-03' \
  --data-urlencode 'category=Balance_Sheet' \
  --data-urlencode 'limit=20'

Python can make the request with the standard library alone. This example prints only the document information and the number of rows returned. The code itself does not interpret each row's conditions to pick the right number.

import json
from urllib.parse import urlencode
from urllib.request import Request, urlopen

query = urlencode({
    "symbol": "7203", "fiscalPeriod": "2026-03",
    "category": "Balance_Sheet", "limit": "20",
})
request = Request(
    "https://api.zenithcode.net/stable/financial-facts?" + query,
    headers={"x-api-key": "YOUR_API_KEY"},
)
with urlopen(request, timeout=30) as response:
    reports = json.load(response)
for report in reports:
    print(report["symbol"], report["fiscalPeriod"], report["docId"])
    print("rows returned:", len(report["facts"]))
    print("cut off by limit:", report["truncated"])

The JavaScript example runs on Node.js with fetch available. Do not embed a secret API key in code for a public browser page.

const query = new URLSearchParams({
  symbol: '7203', fiscalPeriod: '2026-03',
  category: 'Balance_Sheet', limit: '20',
});
const response = await fetch(
  `https://api.zenithcode.net/stable/financial-facts?${query}`,
  { headers: { 'x-api-key': 'YOUR_API_KEY' } },
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const reports = await response.json();
for (const report of reports) {
  console.log(report.symbol, report.fiscalPeriod, report.docId);
  console.log('rows returned:', report.facts.length);
  console.log('cut off by limit:', report.truncated);
}

Check truncated before deciding you have everything

truncated=true means the results were cut off at the row limit. Do not conclude that a line item does not exist just because it is not among the 20 rows you received.

Narrow the classification or tag condition, or adjust the limit within what the specification allows. tag is a partial match on the element name, so even after narrowing, check the tags and contexts returned. The same row can appear in more than one request, so do not simply add up results and treat them as complete.

SituationWhat to check next
Too many candidatesNarrow the classification and element-name conditions
truncated=trueThe limit and search conditions; reassess completeness
No candidatesThe document, fiscal period, classification and tag you specified
Value is nullWhat the response means: not retrieved, not applicable, held as text, and so on
Prior-year values are also returnedContext and period; pick only the year you want

truncated=false does not mean you have every piece of information in the original report. It tells you that, within your conditions and the API's coverage, nothing was cut off by the limit.

After fetching, build a row you can explain

Storing values alone makes it hard to check comparison conditions later. At minimum, keep the company, document, item, period, scope, unit and retrieval time.

For a chart, decide the fiscal year on the x-axis, the unit on the y-axis, how actuals and forecasts are distinguished, and how missing values are shown. If you drop the original period and keep only a year label, you may mix a full year and a six-month cumulative figure under the same label.

If you want to choose conditions yourself and build tables or charts, ZENITH Code is the place to start. If you want a ready-made company analysis screen, StockClub, also run by Crabgrass, is another option. ZENITH Code also provides organized data, so the difference is not “raw data vs processed data”.

Read next

We at Crabgrass, Inc. build and operate the financial data API ZENITH Code. This is a technical article; it does not recommend buying or selling any financial product.

FAQ

For investors and developers

If standardized key items exist, do I still need the original tags?
For comparing key items only, standardized items may be enough. To investigate company-specific line items or the basis of a breakdown, move on to the original tags and the table hierarchy. Choose how deep to check based on what you are analyzing.
Does this request example give me a finished financial chart?
No. Fetching and displaying are separate steps. From the returned candidates, choose the values that meet your conditions, convert units and decide how to show missing values. The code in this article covers only the request and checking what was returned.

For AI builders and researchers

When passing data to an AI, should I fetch all the facts at once?
First narrow the question and choose the document, items and period you need. Many unneeded candidates make it easier to mix values from different periods or scopes. Include the conditions and sources used in the AI's answer so it can be checked.
gavel

Disclaimer

This guide explains how the data works and how to use the API. It does not recommend buying or selling any security and is not investment advice. Example values reflect responses at the time of writing and may change with later filings or corrections. Investment decisions are your own responsibility.