Python
Get started with Pogodoc using Python - from installation to your first document render
Python Quickstart
Welcome! This guide will help you get started with Pogodoc using Python. You'll learn how to install the SDK, authenticate, and generate your first document in minutes.
Prerequisites
Before you begin, make sure you have:
Python 3.7+
Download from python.org
Pogodoc Account
Sign up at app.pogodoc.com
API Token
Generate from your dashboard
Quick Start Guide
Initialize the Client
Create a Pogodoc client with your API token. You can get your token from the API tokens page.
from pogodoc import PogodocClient
pogodoc = PogodocClient(token='<YOUR_API_TOKEN>')Using Environment Variables
For better security, store your API token in an environment variable:
POGODOC_API_TOKEN=your_token_hereThe SDK will automatically read the POGODOC_API_TOKEN environment variable if no token is provided:
pogodoc = PogodocClient()Generate Your First Document
Now you're ready to generate a document! Here's a simple example using an EJS template:
from pogodoc import PogodocClient, RenderConfig
from datetime import datetime
pogodoc = PogodocClient()
template = '''
<!DOCTYPE html>
<html>
<head>
<title>Invoice</title>
<style>
body { font-family: Arial, sans-serif; }
h1 { color: #333; }
</style>
</head>
<body>
<h1>Invoice for <%= customerName %></h1>
<p>Amount: $<%= amount %></p>
<p>Date: <%= date %></p>
</body>
</html>
'''
data = {
'customerName': 'John Doe',
'amount': 1299.99,
'date': datetime.now().strftime('%m/%d/%Y'),
}
response = pogodoc.generate_document(
template=template,
data=data,
render_config=RenderConfig(
type='ejs',
target='pdf',
)
)
# Get the URL to your generated PDF
print(f"Document URL: {response.output.data.url}")Success!
Your document is now generated and available at the returned URL. The URL is publicly accessible and can be shared or downloaded.
Next Steps
Now that you've generated your first document, explore the detailed SDK documentation: