FMPFMP
Conjuntos de datos
Insights/Platform Essentials/API Access/How To Retrieve Historical Sector And Industry P/E Ratios Using A Free API

How To Retrieve Historical Sector And Industry P/E Ratios Using A Free API

·

·12 min read
Platform Essentials

Sector and industry valuation ratios are easy to misuse when they are treated as market signals. Their value is more practical: they help analysts compare how groups of companies are priced relative to earnings over time.

That makes aggregated valuation data useful as a research layer, not a standalone conclusion. Instead of reviewing one company at a time, analysts can use sector and industry P/E ratios to see how valuation levels differ across business groups, exchanges, and historical periods.

Financial Modeling Prep's Historical Sector PE API and Historical Industry PE API are built for that workflow: retrieving historical price-to-earnings ratios for broader market groups in a structured format.

Key Takeaways

  • The Historical Sector PE API and Historical Industry PE API return group-level P/E data, not a broad set of valuation ratios.
  • Sector and industry P/E ratios provide aggregated valuation context across groups of companies, not a valuation call on any single stock.
  • A free FMP API key is useful for testing endpoint behavior, response fields, sample data, and dashboard structure before scaling.
  • Analysts can use the data to compare valuation differences across sectors and industries while keeping the analysis descriptive, not market-timing driven.

What Aggregated Valuation Ratios Represent

A company-level P/E ratio compares a company's market value to its earnings. At the group level, the concept is similar, but the unit of analysis changes.

This article focuses specifically on P/E as the valuation aggregate returned by the Historical Sector PE API and Historical Industry PE API. It does not cover EV/EBITDA, P/S, P/B, or other valuation ratio types.

A sector P/E ratio summarizes valuation across multiple companies that belong to the same sector. An industry P/E ratio does the same at a more specific industry level. For example, Energy is a sector, while Biotechnology is an industry.

This distinction matters because analysts often need both views. Sector data helps compare broad areas of the market, such as Energy, Technology, or Healthcare. Industry data gives a narrower lens, which is useful when companies inside the same sector have very different business models, margins, growth profiles, or earnings cycles.

The key point is that these are aggregates. A sector or industry P/E ratio is not the P/E ratio of one company. It reflects a group of companies classified under the same sector or industry, then summarized into one valuation metric for a specific date and exchange.

How To Think About Group-Level Valuation Aggregates

When working with sector and industry P/E data, it is useful to think in terms of group-level valuation context rather than a single-company metric.

The endpoint returns a P/E value for a defined sector or industry on a specific date and exchange. That value should be interpreted as an aggregate view of how companies in that group are priced relative to earnings.

Analysts should avoid assuming that every provider calculates group-level P/E in the same way unless the methodology is explicitly documented. Depending on the dataset, aggregates may be affected by company coverage, index membership, exchange filters, earnings availability, outliers, and the treatment of companies with negative or volatile earnings.

The practical takeaway is simple: use the data as a standardized comparison layer. It helps show how a sector or industry is valued over time, but it should be paired with company fundamentals, earnings trends, and peer analysis before drawing conclusions.

The Endpoint To Use For Sector P/E Ratios

To retrieve historical sector valuation ratios from Financial Modeling Prep, use the Historical Sector PE API.

https://financialmodelingprep.com/stable/historical-sector-pe?sector=Energy&apikey=YOUR_API_KEY

This endpoint returns historical P/E ratios for a selected sector. In the Energy example, the response includes records by date, sector, exchange, and P/E ratio.

A sample response looks like this:

[

{

"date": "2024-03-01",

"sector": "Energy",

"exchange": "NASDAQ",

"pe": 5.4165892628211205

},

{

"date": "2024-02-29",

"sector": "Energy",

"exchange": "NASDAQ",

"pe": 5.43205214434462

},

{

"date": "2024-02-28",

"sector": "Energy",

"exchange": "NASDAQ",

"pe": 5.464232888923141

}

]

With a free API key, this is a practical endpoint to test first. Analysts can validate the request format, confirm how the sector parameter works, inspect the response fields, review the exchange field, and see how historical P/E values are structured before building a larger workflow.

Each row is straightforward:

  • date: the date of the valuation record
  • sector: the sector being measured
  • exchange: the exchange associated with the record
  • pe: the aggregated sector price-to-earnings ratio

For analysts, this structure is useful because it turns sector valuation into a time series. You can chart the Energy sector's P/E over time, compare it with another sector, or use it as a contextual layer in a sector dashboard.

The Endpoint To Use For Industry P/E Ratios

To retrieve historical industry valuation ratios, use the Historical Industry PE API.

https://financialmodelingprep.com/stable/historical-industry-pe?industry=Biotechnology&apikey=YOUR_API_KEY

Industry names may need to match accepted FMP industry values. If an industry name includes spaces, use URL encoding through your code or browser request. For example, encodeURIComponent(industry) in JavaScript helps avoid failed calls caused by spaces or special characters.

This endpoint returns historical P/E ratios for a selected industry. In the Biotechnology example, the response includes the date, industry, exchange, and aggregate P/E ratio.

A sample response looks like this:

[

{

"date": "2024-03-01",

"industry": "Biotechnology",

"exchange": "NASDAQ",

"pe": 8.129037884885042

},

{

"date": "2024-02-29",

"industry": "Biotechnology",

"exchange": "NASDAQ",

"pe": 7.582881718230381

},

{

"date": "2024-02-28",

"industry": "Biotechnology",

"exchange": "NASDAQ",

"pe": 0.15404724096420702

}

]

Each row includes:

  • date: the date of the industry valuation record
  • industry: the industry being measured
  • exchange: the exchange associated with the record
  • pe: the aggregated industry price-to-earnings ratio

Industry-level data is useful when a sector view is too broad. Healthcare, for example, can include pharmaceuticals, biotechnology, medical devices, healthcare plans, and providers. Those groups can have very different valuation profiles. Industry P/E data helps analysts narrow the comparison.

How To Fetch Sector And Industry P/E Data

The workflow is simple.

  • First, choose the group you want to analyze. For sector data, choose a sector such as Energy. For industry data, choose an industry such as Biotechnology.
  • Second, call the endpoint with your API key.
  • Third, parse the returned array and sort or filter the records by date, exchange, or P/E ratio.

Before running the example, create an FMP API key and replace YOUR_API_KEY with your own key.

Here is a short JavaScript example that retrieves both datasets:

const apiKey = "YOUR_API_KEY";


const sector = "Energy";

const industry = "Biotechnology";


async function fetchJson(url) {

const response = await fetch(url);


if (!response.ok) {

throw new Error(`HTTP error: ${response.status}`);

}


return response.json();

}


async function getValuationAggregates() {

const sectorUrl = `https://financialmodelingprep.com/stable/historical-sector-pe?sector=${encodeURIComponent(sector)}&apikey=${apiKey}`;


const industryUrl = `https://financialmodelingprep.com/stable/historical-industry-pe?industry=${encodeURIComponent(industry)}&apikey=${apiKey}`;


const [sectorData, industryData] = await Promise.all([

fetchJson(sectorUrl),

fetchJson(industryUrl)

]);


console.log("Sector P/E data:", sectorData);

console.log("Industry P/E data:", industryData);


return {

sectorData,

industryData

};

}


getValuationAggregates().catch(console.error);



This example does two useful things.

  • First, it keeps sector and industry data separate. That matters because the two datasets answer different questions.
  • Second, it returns both datasets in the same workflow. That makes it easier to build dashboards where analysts can compare broad sector valuation with a more specific industry valuation.

What You Can Test With A Free API Key

A free API key is useful for validating the workflow before building a larger valuation dashboard.

At this stage, analysts can test whether the endpoint accepts the sector or industry name, confirm the response structure, inspect the date and exchange fields, and review how the P/E values are returned across historical records.

This is also the right point to test dashboard logic.

For example, you can confirm whether your chart reads the date field correctly, whether the PE field is treated as a number, and whether sector and industry data can be normalized into the same table structure.

Free access is best suited for testing, prototyping, and light analysis. If the workflow later requires broader coverage, higher usage, more frequent refreshes, or production-scale dashboards, a paid plan may be more appropriate.

How To Structure The Data For Analysis

Once the data is returned, analysts usually need to organize it before using it in a model or dashboard.

A clean structure might include:

  • date
  • categoryType
  • categoryName
  • exchange
  • pe

For example, sector data can be transformed into this format:

const normalizedSectorRows = sectorData.map(row => ({

date: row.date,

categoryType: "sector",

categoryName: row.sector,

exchange: row.exchange,

pe: row.pe

}));

Industry data can be normalized the same way:

const normalizedIndustryRows = industryData.map(row => ({

date: row.date,

categoryType: "industry",

categoryName: row.industry,

exchange: row.exchange,

pe: row.pe

}));

From there, both datasets can be combined:

const combinedRows = [

...normalizedSectorRows,

...normalizedIndustryRows

];

This makes the data easier to chart, filter, and compare. This structure lets sector and industry rows share the same schema while still keeping the group type separate. Instead of writing separate dashboard logic for sectors and industries, you can use one structure and let categoryType define the grouping level.

A Practical Use Case: Compare Valuation Differences Across Sectors

A practical first use case is comparing valuation differences across sectors.

Suppose an analyst wants to compare Energy, Technology, Healthcare, and Financial Services over the same historical period. The goal is not to decide which sector will outperform next month. The goal is to understand how valuation levels differ and how those differences have changed over time.

That can answer questions such as:

  • Which sectors have consistently traded at higher P/E ratios?
  • Which sectors have seen valuation compression or expansion?
  • Are sector valuation differences stable, or do they change sharply across market cycles?
  • Does a company's individual P/E look high or low relative to its broader sector?

Those are descriptive questions. They help frame the research process without turning the data into a market timing signal.

A beginner can start with a smaller test. For example, chart one sector's P/E ratio over time, then compare that sector with one related industry before expanding the workflow into a larger dashboard.

The same logic applies at the industry level. If the Biotechnology industry has a different P/E profile than the broader Healthcare sector, an analyst may want to understand whether the difference is driven by earnings volatility, growth expectations, company mix, or market sentiment toward that specific group.

Where This Fits In An Analyst Workflow

Sector and industry P/E ratios are most useful when they sit next to company-level data.

For example, an analyst reviewing a single stock might look at its company P/E ratio, its sector P/E ratio, and its industry P/E ratio. That creates a better comparison framework than looking at the company ratio alone.

A company trading above its sector average may still be reasonable if its margins, growth, balance sheet, or earnings quality are stronger than the group. A company trading below its industry average may not be cheap if its earnings are declining or its business model carries higher risk.

That is the right way to use valuation aggregates. They provide context. They do not replace fundamental analysis.

In a research platform, these endpoints can support:

  • sector valuation dashboards
  • industry comparison tools
  • peer-group valuation panels
  • historical P/E charts
  • portfolio exposure reviews
  • screening models with sector context

For analysts, the main benefit is consistency. The same fields are returned across dates, which makes it easier to update dashboards and automate recurring valuation reports.

Best Practices For Working With Aggregated P/E Ratios

  1. The first best practice is to avoid treating the aggregate as a direct trading signal. A higher P/E ratio does not automatically mean a sector is unattractive. A lower P/E ratio does not automatically mean it is attractive.
  2. The second best practice is to compare similar groups. Sector-level comparisons are useful for broad allocation context. Industry-level comparisons are better when the business models inside a sector are too different.
  3. The third best practice is to look at history, not just one date. A single P/E value has limited meaning without context. A time series shows whether the current level is normal, elevated, compressed, or unusually volatile relative to the group's own history.
  4. The fourth best practice is to pair valuation data with fundamentals. Revenue growth, margins, earnings stability, leverage, and cash flow quality can all explain why one group trades at a different multiple than another.
  5. The final best practice is to be careful with earnings-sensitive industries. When earnings are low, negative, or volatile, P/E ratios can move sharply. That does not always mean market prices changed dramatically. Sometimes the denominator changed.

Free API Access And When To Upgrade

The free API workflow is useful for testing, prototyping, and building the first version of a valuation dashboard.

For example, an analyst can use the free API to test how the Historical Sector PE API and Historical Industry PE API work, confirm the response fields, build charts, and validate the structure of the data pipeline.

As the workflow expands, coverage and usage needs may increase. A small dashboard covering a few sectors or industries is different from a production platform that refreshes multiple datasets across exchanges and historical periods. At that point, users may need a higher plan depending on the scale of the application.

The practical approach is simple: use the free API to validate the workflow, then scale coverage as the research process becomes more demanding.

Why These Endpoints Matter

Valuation aggregates give analysts a cleaner way to move from company-level analysis to market structure.

Instead of asking whether one stock looks expensive or cheap in isolation, analysts can compare that company against its sector, its industry, and the history of both groups. That creates a more disciplined research framework.

The Historical Sector PE API provides the broad view. The Historical Industry PE API provides the more specific view. Used together, they help analysts understand valuation context across multiple levels of the market.

The point is not to predict the next move. The point is to make valuation comparison more structured, repeatable, and easier to communicate.

Explore More Free Ways To Use And Test Our APIs

If you are building a broader research workflow, these related free API guides can help you test additional datasets:

FAQ

What Does The Historical Sector PE API Return?

The Historical Sector PE API returns historical price-to-earnings ratios for a selected sector. Each record includes the date, sector, exchange, and aggregated P/E ratio.

What Does The Historical Industry PE API Return?

The Historical Industry PE API returns historical price-to-earnings ratios for a selected industry. Each record includes the date, industry, exchange, and aggregated P/E ratio.

Can I Test Sector And Industry P/E Ratios With A Free API Key?

Yes. A free FMP API key is useful for testing the request format, response fields, sample data, sector or industry parameters, and basic dashboard structure before scaling the workflow.

Are These Endpoints Returning Multiple Valuation Ratios?

No. This walkthrough focuses on historical sector P/E and historical industry P/E data. These endpoints return P/E values, not EV/EBITDA, P/S, P/B, or a full valuation-ratio set.

Are These Ratios Based On One Company Or Multiple Companies?

They are group-level valuation metrics based on companies within the selected sector or industry. They should be interpreted as aggregated context, not as the P/E ratio of a single company.

What Should I Do If A Sector Or Industry Name Does Not Return Data?

Check whether the sector or industry name matches accepted FMP values. You can also test available sector and industry lists, confirm spelling, and make sure names with spaces are properly URL encoded.

How Are Sector And Industry P/E Ratios Different?

A sector P/E ratio summarizes a broad market group, such as Energy or Healthcare. An industry P/E ratio is more specific, such as Biotechnology or Financial Services. Analysts often use sector data for broad comparison and industry data for more targeted peer-group context.

Can Analysts Use These APIs For Market Timing?

These APIs are better suited for descriptive analysis than market timing. They help analysts compare valuation levels across sectors, industries, exchanges, and historical periods, but they should not be used as standalone buy or sell signals.

What Is A Good First Use Case For These Endpoints?

A good first use case is a simple historical P/E chart for one sector or one industry. After that, analysts can compare one sector with one industry, then expand the workflow into a broader valuation comparison dashboard.

About the Author

Sanzhi Kobzhan
Sanzhi Kobzhan

Treasury, trading, liquidity, and equity analysis for investors

Sanzhi writes for FMP with a focus on equity analysis, valuation, market data, and practical investment decision-making. He has worked across financial institutions in treasury, trading, and liquidity roles, bringing hands-on experience in investment analysis, market execution, risk, and strategy. His work focuses on helping readers interpret financial data with clarity, discipline, and an institutional market perspective.

Related

Financial data for every need

Real-time quotes and 30+ years of historical data, including prices, fundamentals, and insider transactions — all accessible via API.