Compare financial peers and group medians
curl --request GET \
--url https://api.darvas.app/v1/financials/peer-comparison \
--header 'X-API-KEY: <api-key>'import requests
url = "https://api.darvas.app/v1/financials/peer-comparison"
headers = {"X-API-KEY": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-KEY': '<api-key>'}};
fetch('https://api.darvas.app/v1/financials/peer-comparison', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"tickers": [
"AAPL",
"MSFT"
],
"peers": [
{
"ticker": "AAPL",
"status": "ok",
"price": 235.12,
"day_change_percent": 0.85,
"market_cap": 3560000000000,
"price_to_earnings_ratio": 31.4,
"gross_margin": 0.462,
"operating_margin": 0.318,
"return_on_equity": 1.45
}
],
"medians": {
"market_cap": 3300000000000,
"price_to_earnings_ratio": 31.4
}
}{
"error": "VALIDATION_ERROR",
"message": "Send ticker or cik"
}{
"error": "UNAUTHORIZED",
"message": "The API key is not valid"
}{
"error": "PLAN_REQUIRED",
"message": "The account of this key has no active data API plan"
}{
"error": "NOT_FOUND",
"message": "No company has this ticker or CIK"
}{
"error": "RATE_LIMITED",
"message": "Too many requests"
}{
"error": "INTERNAL_ERROR",
"message": "Something went wrong"
}{
"error": "UNAVAILABLE",
"message": "The data service is unavailable"
}Valuation & Peers
Stock Peer Comparison & Valuation Comps API
Compare 2 to 20 US stocks side by side with 12 peer group medians across valuation multiples, growth, margins and returns, from one request by tickers.
Compare financial peers and group medians
curl --request GET \
--url https://api.darvas.app/v1/financials/peer-comparison \
--header 'X-API-KEY: <api-key>'import requests
url = "https://api.darvas.app/v1/financials/peer-comparison"
headers = {"X-API-KEY": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-KEY': '<api-key>'}};
fetch('https://api.darvas.app/v1/financials/peer-comparison', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"tickers": [
"AAPL",
"MSFT"
],
"peers": [
{
"ticker": "AAPL",
"status": "ok",
"price": 235.12,
"day_change_percent": 0.85,
"market_cap": 3560000000000,
"price_to_earnings_ratio": 31.4,
"gross_margin": 0.462,
"operating_margin": 0.318,
"return_on_equity": 1.45
}
],
"medians": {
"market_cap": 3300000000000,
"price_to_earnings_ratio": 31.4
}
}{
"error": "VALIDATION_ERROR",
"message": "Send ticker or cik"
}{
"error": "UNAUTHORIZED",
"message": "The API key is not valid"
}{
"error": "PLAN_REQUIRED",
"message": "The account of this key has no active data API plan"
}{
"error": "NOT_FOUND",
"message": "No company has this ticker or CIK"
}{
"error": "RATE_LIMITED",
"message": "Too many requests"
}{
"error": "INTERNAL_ERROR",
"message": "Something went wrong"
}{
"error": "UNAVAILABLE",
"message": "The data service is unavailable"
}Overview
This endpoint lines up the latest price and the newest trailing twelve month (TTM) financial ratios of 2 to 20 US stocks, one entry per ticker, and adds the peer group median of the main valuation, profitability, growth and leverage metrics. Use it for comparable company analysis, relative valuation screens and questions such as “is MSFT expensive against its peers?”.| Coverage | Details |
|---|---|
| Companies | US stocks with stored financial metrics or a stored price |
| Tickers | 2 to 20 unique tickers in tickers, comma-separated; duplicates are dropped |
| Per peer | price, day_change_percent and every field of the financial metrics snapshot |
| Medians | 12 metrics across peers with status: "ok", nulls ignored |
| MCP tool | compare_financial_peers on the data API MCP server |
Parameters and response
tickers is the only parameter, such as tickers=AAPL,MSFT,GOOGL. Fewer than 2 or more than 20 unique tickers return 400, and the answer is 404 only when none of them has stored metrics or a price.
| Field | Description |
|---|---|
tickers | The unique tickers, uppercased, in the order sent |
peers | One entry per ticker in the same order. status is ok or not_found; an ok entry adds price, day_change_percent, report_period, currency, market_cap, enterprise_value, the valuation ratios, margins, returns, turnover, liquidity, leverage, growth and per share fields |
medians | market_cap, enterprise_value, price_to_earnings_ratio, price_to_book_ratio, price_to_sales_ratio, enterprise_value_to_ebitda_ratio, gross_margin, operating_margin, net_margin, return_on_equity, revenue_growth and debt_to_equity |
0.318 is 31.8%. A median of an even number of peers is the mean of the two middle values; a metric no peer has is null. A peer that sends not_found carries only ticker and status, so check status before reading its fields.
Related endpoints
For one company’s full ratio history, see Financial Ratios. To find the peers themselves by ratio thresholds, use the Stock Screener. For one company with its insider, 13F and 8-K activity, use the Company Dossier.Examples
import os
import requests
headers = {"X-API-KEY": os.environ["DARVAS_API_KEY"]}
answer = requests.get(
"https://api.darvas.app/v1/financials/peer-comparison",
headers=headers,
params={"tickers": "AAPL,MSFT,GOOGL,AMZN,META"},
).json()
medians = answer["medians"]
print("Peer median P/E:", medians["price_to_earnings_ratio"], "EV/EBITDA:", medians["enterprise_value_to_ebitda_ratio"])
for peer in answer["peers"]:
if peer["status"] != "ok":
print(peer["ticker"], "not found")
continue
pe = peer.get("price_to_earnings_ratio")
premium = None
if pe is not None and medians["price_to_earnings_ratio"]:
premium = round((pe / medians["price_to_earnings_ratio"] - 1) * 100, 1)
print(peer["ticker"], peer["price"], "P/E:", pe, "vs median %:", premium, "Net margin:", peer.get("net_margin"))
curl -H "X-API-KEY: $DARVAS_API_KEY" \
"https://api.darvas.app/v1/financials/peer-comparison?tickers=NVDA,AMD,INTC,AVGO"
Authorizations
apiKeybearerKey
Query Parameters
Response
Compare financial peers and group medians: one page.
The answer of GET /financials/peer-comparison.
Latest valuation, margins, and price snapshot per peer ticker.
Maximum array length:
20Example:
[
{
"ticker": "AAPL",
"status": "ok",
"price": 235.12,
"day_change_percent": 0.85,
"market_cap": 3560000000000,
"price_to_earnings_ratio": 31.4,
"gross_margin": 0.462,
"operating_margin": 0.318,
"return_on_equity": 1.45
}
]