Home / Learn / What Is the P/E Ratio (and How to Get It via API)
Guide

What Is the P/E Ratio (and How to Get It via API)

Updated 2026-10-18

The price-to-earnings (P/E) ratio is the share price divided by earnings per share (EPS). It's a quick gauge of how much the market pays per rupee of a company's earnings — a higher P/E implies higher growth expectations (or a richer price).

How it's calculated

P/E = current price ÷ trailing-twelve-month EPS. BharatStock computes a single canonical current P/E (today's price over TTM EPS) and serves the identical value across the stock page, the /ratios endpoint, and the screener — so the number never disagrees between surfaces.

The gotchas

P/E is only meaningful when EPS is positive — for a loss-making company (negative EPS) the ratio is left empty rather than shown as a misleading negative number. Note too that a company with negative book value can still show a valid positive P/E if a one-off exceptional gain made its earnings positive; that's the as-filed reality, not an error.

Getting it via API

Call GET /v1/stocks/{ticker}/ratios (or read the pe_ratio field on GET /v1/stocks/{ticker}). You also get P/B, ROE, ROCE, and dividend yield in the same response — the same figures shown on each stock page and used by the screener.

Historical vs current P/E

The current P/E uses today's price. Each financials row also exposes a point-in-time P/E for that period (that period's close over that period's EPS) — a distinct, correct-per-period metric, not today's price over an old EPS.

More guides

How to Get NSE Quarterly Results via API

A developer's guide to fetching NSE & BSE quarterly and annual results programmatically — the endpoint, the fields, consolidation basis, and how to read the as-filed numbers correctly.

Read guide →

How to Find Which Mutual Funds Hold a Stock (via API)

Find every mutual-fund scheme that holds a given NSE/BSE stock — quantity, market value, and % of AUM — built from AMFI and 40+ fund houses' own monthly portfolio disclosures, available as a REST API.

Read guide →

How to Get Indian Stock Prices via API (NSE & BSE EOD)

Fetch end-of-day OHLCV price history for any NSE or BSE stock via API — the endpoint, the fields, split/bonus adjustment, and how to build a clean price series.

Read guide →

ROE vs ROCE Explained (and How to Get Them via API)

What return on equity (ROE) and return on capital employed (ROCE) measure, how they differ, and how to fetch both for any Indian stock through a single API call.

Read guide →

How to Build a Stock Screener with an API

Build your own Indian stock screener programmatically — filter the NSE/BSE universe by market cap, P/E, ROE, ROCE and more using a single screener API endpoint.

Read guide →

How to Get a Company's Shareholding Pattern via API

Fetch the promoter, FII, DII, and public shareholding breakdown for any NSE/BSE company via API — straight from the SEBI quarterly disclosures.

Read guide →

How to Track Bulk Deals, Block Deals & Insider Trades via API

Follow the big trades — bulk deals, block deals, and SEBI insider/promoter (PIT) disclosures — for any Indian stock or market-wide, through a REST API.

Read guide →

NSE vs BSE: Which Ticker Should You Use with the API?

How ticker symbols work across NSE and BSE, why the same company can have two listings, and how to resolve names to the right ticker with the search API.

Read guide →

Try it with your own key

A free API key takes under a minute — no card required.

Get a free API key