> For the complete documentation index, see [llms.txt](https://docs.graphite-note.com/graphite-note-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graphite-note.com/graphite-note-documentation/rest-api/prediction-api/request-timeseries/python-example-forecasting-multiple-skus.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
