# Python Example — Forecasting Multiple SKUs

The following script shows how to loop through a list of SKU codes, call the Graphite Note Time Series Forecasting API for each, and save all daily predictions into a single CSV file. This example requests forecasts for October 2025 and assumes the model does not use regressors.

```python
import requests
import pandas as pd

# --- CONFIGURATION ---
API_URL = "https://app.graphite-note.com/api/v1/prediction/model/[model-code]"
API_TOKEN = "Bearer YOUR_TOKEN_HERE"

# Example SKUs
sku_list = [f"SKU{i:03d}" for i in range(1, 11)]

# Prediction window
START_DATE = "2025-10-01"
END_DATE   = "2025-10-31"

# --- STORAGE ---
all_results = []

# --- LOOP THROUGH SKUs ---
for sku in sku_list:
    payload = {
        "data": {
            "predict_values": {
                "startDate": START_DATE,
                "endDate": END_DATE,
                "sequenceID": sku
            }
        }
    }

    headers = {
        "Authorization": API_TOKEN,
        "Content-Type": "application/json"
    }

    response = requests.post(API_URL, json=payload, headers=headers)
    response.raise_for_status()

    data = response.json().get("data", [])

    for row in data:
        if "date" in row:  # skip the trailing { "sequenceID": ... }
            all_results.append({
                "SKU": sku,
                "Date": row["date"].split("T")[0],
                "Predicted": row["predicted"],
                "Predicted_Lower": row["predicted_lower"],
                "Predicted_Upper": row["predicted_upper"]
            })

# --- EXPORT TO CSV ---
df = pd.DataFrame(all_results)
df.to_csv("october_2025_forecasts.csv", index=False)

print("Saved results to october_2025_forecasts.csv")

```

This script:

1. Iterates through ten SKUs.
2. Sends a POST request for each SKU with the requested date range.
3. Collects all daily predictions, including lower and upper bounds.
4. Saves the results into a CSV file for further analysis.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.graphite-note.com/graphite-note-documentation/rest-api/prediction-api/request-timeseries/python-example-forecasting-multiple-skus.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
