Back to documentation

Python

From an endpoint to a reproducible DataFrame.

Provisional requests and pandas example. The observation schema already matches the planned production contract.

Python
import requests
import pandas as pd

BASE_URL = "https://boliviadb.com/api"
series_id = "reserves"

response = requests.get(
    f"{BASE_URL}/series/{series_id}/observations",
    params={"from": "2024-01-01"},
    timeout=30,
)
response.raise_for_status()

payload = response.json()
df = pd.DataFrame(payload["data"])
df["period"] = pd.to_datetime(df["period"])
df = df.set_index("period").sort_index()
print(df.tail())

In production, the API key will be sent through a header and should never be stored directly in source code.