> ## Documentation Index
> Fetch the complete documentation index at: https://data.ornn.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Pull price history into pandas

> Load a GPU price series into a pandas DataFrame and plot it.

This guide loads an H100 SXM price history into a pandas DataFrame, ready for analysis or plotting.

## Prerequisites

* An [API key](/docs/manage-api-keys).
* `pip install requests pandas`

## Fetch and load

The [`/history-simple`](/docs/api-reference/historical-prices/get-a-clean-dailyhourly-series) endpoint returns a clean `timestamp` / `index_value` series, ideal for a DataFrame.

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

API_KEY = "YOUR_API_KEY"
BASE = "https://api.ornnai.com"

resp = requests.get(
    f"{BASE}/api/gpu/H100 SXM/history-simple",
    params={
        "startDate": "2026-05-01",
        "endDate": "2026-05-31",
        "granularity": "daily",  # one point per day
        "limit": 500,            # default is 100, raise it for long ranges
    },
    headers={"Authorization": f"Bearer {API_KEY}"},
)
resp.raise_for_status()

df = pd.DataFrame(resp.json()["data"])
df["timestamp"] = pd.to_datetime(df["timestamp"])
df = df.sort_values("timestamp").set_index("timestamp")

print(df.head())
```

```text Output theme={null}
                           index_value
timestamp
2026-01-01 00:00:00+00:00         2.00
2026-01-02 00:00:00+00:00         2.00
2026-01-03 00:00:00+00:00         2.00
2026-01-04 00:00:00+00:00         2.00
2026-01-05 00:00:00+00:00         2.00
```

<Tip>
  The API returns points most-recent-first. Sorting by `timestamp` (as above) puts them in chronological order before any rolling calculations or plotting.
</Tip>

## Plot it

```python theme={null}
import matplotlib.pyplot as plt

df["index_value"].plot(title="H100 SXM price index (USD/hr)")
plt.ylabel("USD per hour")
plt.show()
```

<Frame caption="H100 SXM daily price index, May 2026">
  <img className="block dark:hidden" src="https://mintcdn.com/ornn-data/XYIc8NRHBiyV90g7/images/h100-price-chart-light.png?fit=max&auto=format&n=XYIc8NRHBiyV90g7&q=85&s=cb32bafe8e026ec84a6956d3709a7a9e" alt="H100 SXM price index line chart for May 2026" width="1600" height="720" data-path="images/h100-price-chart-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ornn-data/XYIc8NRHBiyV90g7/images/h100-price-chart-dark.png?fit=max&auto=format&n=XYIc8NRHBiyV90g7&q=85&s=8d0ab82f617fe1dbe163fefb29d244c2" alt="H100 SXM price index line chart for May 2026" width="1600" height="720" data-path="images/h100-price-chart-dark.png" />
</Frame>

## Compare multiple GPUs

```python theme={null}
gpus = ["H100 SXM", "H200", "B200"]
frames = []

for gpu in gpus:
    r = requests.get(
        f"{BASE}/api/gpu/{gpu}/history-simple",
        params={"startDate": "2026-05-01", "endDate": "2026-05-31",
                "granularity": "daily", "limit": 500},
        headers={"Authorization": f"Bearer {API_KEY}"},
    )
    s = pd.DataFrame(r.json()["data"])
    s["timestamp"] = pd.to_datetime(s["timestamp"])
    frames.append(s.set_index("timestamp")["index_value"].rename(gpu))

prices = pd.concat(frames, axis=1).sort_index()
prices.plot(title="GPU price index comparison")
```

<Frame caption="H100 SXM, H200, and B200 daily price index, May 2026">
  <img className="block dark:hidden" src="https://mintcdn.com/ornn-data/XYIc8NRHBiyV90g7/images/gpu-comparison-light.png?fit=max&auto=format&n=XYIc8NRHBiyV90g7&q=85&s=6a1fd2b5ab9b7bfe4dba0f132a5dd2ab" alt="GPU price index comparison line chart" width="1600" height="720" data-path="images/gpu-comparison-light.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ornn-data/XYIc8NRHBiyV90g7/images/gpu-comparison-dark.png?fit=max&auto=format&n=XYIc8NRHBiyV90g7&q=85&s=9c45e62b7e7b4b8c7a969da9e2dbb510" alt="GPU price index comparison line chart" width="1600" height="720" data-path="images/gpu-comparison-dark.png" />
</Frame>
