import json
import requests
TEMPLATE_PATH = './title_slide_template.pptx' # where the file lives on disk
TEMPLATE_NAME = 'title_slide_template.pptx' # name used in upload + JSON (must match)
API_TOKEN = 'eyJ...' # your bearer token
payload = {
'jsonData': json.dumps({
"presentation": {
"template": TEMPLATE_NAME,
"export_version": "Pptx2019",
"resultFileName": "quick_start_example",
"slides": [
{
"type": "slide",
"slide_index": 0,
"shapes": [
{"name": "Title 1", "content": "Your generated PowerPoint presentation"},
{"name": "Subtitle 2", "content": "Create, fill and manage PowerPoint documents through simple API requests."},
],
}
],
}
})
}
with open(TEMPLATE_PATH, 'rb') as f:
files = [
('files', (TEMPLATE_NAME, f,
'application/vnd.openxmlformats-officedocument.presentationml.presentation'))
]
response = requests.post(
'https://gen.powerpointgeneratorapi.com/v1.0/generator/create',
data=payload,
files=files,
headers={'Authorization': f'Bearer {API_TOKEN}'},
timeout=360,
)
print(response.status_code, response.headers.get('Content-Type'))
if response.ok:
with open("./generated.pptx", "wb") as out:
out.write(response.content)
print("saved generated.pptx", len(response.content), "bytes")
else:
print(response.text)