Python library to build highly customized reports using REST API
Start Free TrialGroupDocs.Assembly Cloud SDK for Python enables developers to automate the creation of richly formatted documents such as contracts, invoices, shipment reports, sales proposals, inventories and many other business‑critical artifacts. The solution is completely cloud‑based and accessed through a REST API, which means any Python application capable of sending HTTP requests can generate documents on‑demand without installing server‑side software or third‑party tools.
At its core the platform works with document templates that contain special placeholder fields and programming constructs. These placeholders are automatically replaced with values taken from a data source (XML or JSON) using a LINQ‑style expression syntax. This powerful approach allows you to embed images, charts, barcodes, set background colors for HTML output, create dynamic tables and lists from array data, and apply conditional logic to include or exclude sections of the document. Because the SDK supports a wide range of input and output formats, you can generate a PDF from a DOCX template, produce HTML reports, or output OpenDocument files without additional conversion steps.
The typical workflow in Python consists of three straightforward steps:
1️⃣ Create a template – design a Word, Excel, PowerPoint or any supported Office/OpenOffice file and insert placeholder fields and generation rules.
2️⃣ Prepare a data source – provide your data in XML or JSON format, matching the placeholders defined in the template.
3️⃣ Write a few lines of Python code – use the groupdocsassemblycloud
package to upload the template to GroupDocs Cloud Storage, pass the data source together with the desired output format, and invoke the AssembleDocument
operation. The API returns the assembled document directly in the response or stores it in the Cloud for later retrieval.
All interactions are secured with SSL/TLS encryption, and authentication is performed via your personal App SID and App Key. This ensures that your documents and data remain protected while being processed in the cloud. The SDK’s cross‑platform nature lets you integrate document generation into web services, batch jobs, desktop applications, or serverless functions, delivering printable, web‑ready or email‑ready documents instantly and reliably.
This Python example demonstrates how to upload a template, bind a data file and generate an output document using the GroupDocs Assembly Cloud SDK.
Steps
AssemblyApi
with your App SID and App Key.TemplateFileInfo
and AssembleOptions
.assemble_document
to generate the result.import groupdocsassemblycloud
# Initialize API client (replace with your credentials)
assembly_api = groupdocsassemblycloud.AssemblyApi('####################', '####################')
# 1️⃣ Upload the template
file_name = 'Input1.docx'
with open(file_name, 'rb') as request_file_content:
upload_request = groupdocsassemblycloud.models.requests.UploadFileRequest(
file_content=request_file_content,
path=file_name
)
assembly_api.upload_file(upload_request)
# 2️⃣ Load data source (could be XML, JSON or DOCX)
data_file = 'Input2.docx'
with open(data_file, 'rb') as data:
template_info = groupdocsassemblycloud.models.TemplateFileInfo(file_name)
# 3️⃣ Set assemble options (output format: docx)
assemble_options = groupdocsassemblycloud.models.AssembleOptions(
template_info,
"docx",
data
)
# 4️⃣ Assemble the document
request = groupdocsassemblycloud.models.requests.AssembleDocumentRequest(assemble_options)
result = assembly_api.assemble_document(request)
print("Document generated successfully:", result.path)