Overview
Python is one of the most popular languages for data analysis and reporting. The pptx.dev API integrates naturally with Python scripts and applications to turn your data into polished PowerPoint files.
Prerequisites
- Python 3.8+
requestslibrary (pip install requests)- A pptx.dev API key (get one free)
Basic Example
Use the Python example in the complete authenticated API recipe. It sends the OPF JSON body, checks the response status, and writes response.content to a file. Keep your API key in PPTX_API_KEY.
Data-Driven Slides from Pandas
Generate chart slides from a Pandas DataFrame:
import pandas as pd
# Fictional example data
df = pd.DataFrame({
"month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
"revenue": [120, 135, 128, 155, 170, 195],
"users": [4200, 4800, 5100, 5600, 6200, 7000],
})
slides = [
{"title": "H1 Performance", "subtitle": "Data-driven report"},
{
"title": "Revenue Trend",
"chart": {
"type": "line-with-markers",
"data": {
"columns": ["Month", "Revenue ($K)"],
"rows": list(zip(df["month"].tolist(), df["revenue"].tolist())),
},
},
},
{
"title": "User Growth",
"chart": {
"type": "column",
"data": {
"columns": ["Month", "Active Users"],
"rows": list(zip(df["month"].tolist(), df["users"].tolist())),
},
},
},
]
document = {"name": "H1 Performance", "slides": slides}
Saving and Scheduling Reports
Pass document as the JSON body in the complete authenticated API recipe. A successful generation returns PowerPoint bytes, not a JSON download URL. Check the HTTP status before writing the file; 401 means authentication failed, 402 means the hosted wallet has insufficient balance, and 422 means the document is invalid.
For a scheduled report, fetch your own data, build the complete document, then run that same request and save or deliver the returned file. The generation API does not schedule jobs or email a download link for you.
Next Steps
- Learn about narrative structures for planning your story arc
- Explore all chart types
- See automation patterns for more ideas