> ## Documentation Index
> Fetch the complete documentation index at: https://doc.prometheus.services/llms.txt
> Use this file to discover all available pages before exploring further.

# Guide: analyze financials in Python

> Pull standardized statements into pandas and compare companies in 20 lines.

```python theme={null}
import os
import requests
import pandas as pd

BASE = "https://www.prometheus.services/api/v1"
HEADERS = {"X-API-KEY": os.environ["PROMETHEUS_API_KEY"]}

def financials(ticker: str, period_type: str = "quarterly", limit: int = 12) -> pd.DataFrame:
    r = requests.get(
        f"{BASE}/companies/{ticker}/financials",
        params={"period_type": period_type, "limit": limit},
        headers=HEADERS,
        timeout=30,
    )
    r.raise_for_status()
    rows = r.json()["income_statement"]
    return pd.DataFrame(rows).set_index("end_date")

nvda = financials("NVDA")
amd = financials("AMD")

# Revenue growth, quarter over quarter
growth = pd.DataFrame({
    "NVDA": nvda["revenue"].pct_change(),
    "AMD": amd["revenue"].pct_change(),
})
print(growth.tail(6))
```

<Note>
  Field names in the response are the standardized line keys — the same vocabulary
  `fact-source` accepts, so any cell in your DataFrame can be traced to its filing.
  Inspect the actual payload shape for your companies first; run the request once and
  look, rather than assuming this snippet's fields.
</Note>

## Handle limits like a good citizen

```python theme={null}
import time

def get(url, **kwargs):
    while True:
        r = requests.get(url, headers=HEADERS, timeout=30, **kwargs)
        if r.status_code == 429:
            wait = int(r.headers.get("Retry-After", "5"))
            time.sleep(wait)
            continue
        r.raise_for_status()
        return r.json()
```

Watch `X-Quota-Remaining` on quota-carrying plans, and remember: one `/financials`
call returns whole statements — never page line by line.

## As originally reported

Backtesting against what the market knew at the time? Add
`reporting_basis=as_reported` to get the originally filed vintage, and use the macro
endpoints' point-in-time semantics the same way. No look-ahead, by construction.
