A price-to-earnings ratio compares with another period only while its date stays on the value.
The ratios module returns one ticker. Each field is a date mapped to a value. There is no example file, so the amounts below stay placeholders. The date keys are from an annual response.
To access this endpoint, you must obtain an API key: Get your API key
Request annual ratios
GET /v1/markets/stock/modules with module=ratios. timeframe accepts annually, quarterly, or trailing. Omitting it selects annually. Documentation: stock modules.
import requests
url = "https://api.mboum.com/v1/markets/stock/modules"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
params = {"ticker": "AAPL", "module": "ratios", "timeframe": "annually"}
response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
payload = response.json()
pe = payload["body"]["pe"]
for date, value in pe.items():
print(date, value)
Print each price-to-earnings entry with its date
meta.symbol is the ticker. meta.keys holds the description. The values are numbers. roe and currentratio are sibling maps, each with its own dates.
{
"meta": {
"symbol": "AAPL",
"keys": {
"pe": "Price-to-Earnings Ratio (P/E Ratio), the ratio of a company's share price to its earnings per share."
}
},
"body": {
"pe": {
"TTM": "<value>",
"2025-09-27": "<value>",
"2024-09-28": "<value>",
"2023-09-30": "<value>",
"2022-09-24": "<value>",
"2021-09-25": "<value>"
}
}
}
TTM is a key on that map beside the period-end dates.
Learn more or explore other endpoints: stock modules