Python library for automating Google Slides presentations with JSON data
Project description
Google Slides Automation
A Python library for automating Google Slides presentations with JSON data—dynamic table population, slide duplication, and text replacement.
Installation
# From PyPI (when published)
pip install google-slides-automation
# Or install from source
pip install -e .
Quick Start
from google_slides_automation import GoogleSlidesAutomation
# With service account
automation = GoogleSlidesAutomation(credentials_path="path/to/service-account.json")
# Create a presentation from a template
presentation_id = automation.create_presentation_from_template(
template_id="YOUR_TEMPLATE_ID",
json_data={
"title": "Q1 Report",
"subtitle": "Generated from Python",
"images": {
"hero": "https://example.com/hero.jpg",
},
"items": [
{"name": "Item 1", "value": "100", "status": "Active"},
{"name": "Item 2", "value": "200", "status": "Pending"},
],
},
title="My Presentation",
drive_folder_url="https://drive.google.com/drive/folders/FOLDER_ID", # Required for service accounts
)
print(f"Created: https://docs.google.com/presentation/d/{presentation_id}/edit")
With User OAuth Token
from google_slides_automation import GoogleSlidesAutomation
from google.oauth2.credentials import Credentials
# Use a user's OAuth2 access token
user_creds = Credentials(token="user_access_token_here")
automation = GoogleSlidesAutomation(user_credentials=user_creds)
presentation_id = automation.create_presentation_from_template(
template_id="YOUR_TEMPLATE_ID",
json_data={"title": "My Title", "items": [...]},
title="Generated Presentation",
)
Features
- Dynamic Table Population: Automatically populates tables with JSON data
- Slide Duplication: Intelligently duplicates slides for large datasets
- Batch Processing: Optimized batch updates with 10MB payload limits
- Text Replacement: Simple
{{key}}placeholders in templates
Template Requirements
Your Google Slides template should include:
- Placeholders: Use
{{key}}in text for simple replacements (e.g.{{title}},{{date}}) - Array Tables: Use
{{array_key}}in a table cell (e.g.{{items}}) to populate with data - Image Placeholders: Use
[[image:key]]in a text shape. Size the shape to the desired image dimensions. The shape will be replaced with the image from the URL. - Permissions: Share the template with your service account (Viewer) or ensure the user has access
Image placeholders
Add a text box containing [[image:hero]] (or any key), size it like an image placeholder. Pass URLs in json_data["images"]:
json_data = {
"title": "My Report",
"images": {
"hero": "https://example.com/hero.jpg",
"logo": "https://example.com/logo.png",
},
}
Images must be publicly accessible URLs (PNG, JPEG, or GIF; max 50MB, 25 megapixels).
Project Structure
├── src/
│ └── google_slides_automation/
│ ├── __init__.py
│ ├── api_handler.py
│ ├── slides_automation.py
│ └── logger.py
├── pyproject.toml
└── README.md
Configuration
Environment Variables
GOOGLE_CREDENTIALS_PATH: Path to Google service account credentials (default:credentials.json)
Troubleshooting
Common Issues
- Missing Credentials: Ensure
credentials.jsonis present and has correct permissions - Template Access: Verify the service account has edit access to the template
- Large Datasets: The library automatically handles large datasets with slide duplication
- API Limits: Batch processing helps stay within Google Slides API limits
Debug Mode
Enable debug logging:
export LOG_LEVEL=DEBUG
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file google_slides_automation-1.0.0.tar.gz.
File metadata
- Download URL: google_slides_automation-1.0.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf5ac16c053aa2c2e726f6d1c9de1f6b776510c9b31e1632657c30617165de8b
|
|
| MD5 |
571bdff6c386b936c9530df349b86e9d
|
|
| BLAKE2b-256 |
e25a16df169d62ee3525c9e9688e963e4ff64621ff4c7694f723c3682614b045
|
File details
Details for the file google_slides_automation-1.0.0-py3-none-any.whl.
File metadata
- Download URL: google_slides_automation-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebbcb2d7ceaff870dce18009ac1f2746333cd94951200b3062a31d4c32881afc
|
|
| MD5 |
641380b842d23977d9b538bba2f977b9
|
|
| BLAKE2b-256 |
751c60d4bb6d39cedc6c2e17a7c027c535a29a397134810a949da263af8d5946
|