Canva Connect API Python Client
Note: This is an unofficial Python client for the Canva Connect API. It is not officially endorsed or maintained by Canva.
A comprehensive Python client library for the Canva Connect API, enabling developers to integrate Canva's powerful design capabilities into their applications.
🚀 Features
- Complete API Coverage: All Canva Connect API endpoints
- Type Safety: Full type annotations with Pydantic v2
- Modern Python: Supports Python 3.9+
- OAuth 2.0 + PKCE: Secure authentication flow
- Auto-generated: Based on official OpenAPI specification
- Production Ready: Comprehensive error handling and retries
📦 Installation
pip install canva-connect-api
🔧 Quick Start
import openapi_client
from openapi_client.api.design_api import DesignApi
from openapi_client.api.autofill_api import AutofillApi
# Configure API client
configuration = openapi_client.Configuration(
host="https://api.canva.com/rest",
access_token="your_access_token_here"
)
# Create API instances
with openapi_client.ApiClient(configuration) as api_client:
design_api = DesignApi(api_client)
autofill_api = AutofillApi(api_client)
# List user's designs
designs = design_api.list_designs()
print(f"Found {len(designs.items)} designs")
🔑 Authentication
Before using the API, you need to set up OAuth 2.0 authentication:
- Create a Canva App in the Canva Developer Portal
- Configure OAuth settings and scopes
- Implement OAuth flow in your application
from openapi_client.api.oauth_api import OauthApi
# Step 1: Direct user to authorization URL
auth_url = "https://www.canva.com/api/oauth/authorize"
params = {
"code_challenge": "your_code_challenge",
"code_challenge_method": "S256",
"scope": "design:read design:write asset:read",
"response_type": "code",
"client_id": "your_client_id"
}
# Step 2: Exchange code for tokens
oauth_api = OauthApi(api_client)
token_response = oauth_api.exchange_access_token(
# ... token exchange parameters
)
🎆 Examples
Autofill Templates
from openapi_client.api.autofill_api import AutofillApi
from openapi_client.models.create_design_autofill_job_request import CreateDesignAutofillJobRequest
# Autofill a brand template with data
autofill_request = CreateDesignAutofillJobRequest(
brand_template_id="your_template_id",
data=DataTable(
rows=[DataTableRow(
cells=[
StringDataTableCell(value="Hello World"),
StringDataTableCell(value="Welcome Message"),
DatasetImageValue(url="https://example.com/image.jpg")
]
)]
)
)
autofill_job = autofill_api.create_design_autofill_job(autofill_request)
print(f"Job created: {autofill_job.job.id}")
Upload and Manage Assets
from openapi_client.api.asset_api import AssetApi
# Upload an asset
asset_api = AssetApi(api_client)
upload_job = asset_api.create_asset_upload_job(
# ... upload parameters
)
# List user's assets
assets = asset_api.list_assets()
for asset in assets.items:
print(f"Asset: {asset.name} - {asset.id}")
Export Designs
from openapi_client.api.export_api import ExportApi
from openapi_client.models.create_design_export_job_request import CreateDesignExportJobRequest
# Export design as PNG
export_api = ExportApi(api_client)
export_request = CreateDesignExportJobRequest(
design_id="your_design_id",
format=ExportFormat(
type="png",
quality="high"
)
)
export_job = export_api.create_design_export_job(export_request)
print(f"Export job: {export_job.job.id}")
📋 Available APIs
All URIs are relative to https://api.canva.com/rest
| API | Description |
|---|---|
| AppApi | Manage Canva apps |
| AssetApi | Upload and manage user assets |
| AutofillApi | Automated template data population |
| BrandTemplateApi | Access brand templates |
| CommentApi | Comments and collaboration |
| ConnectApi | API connectivity features |
| DesignApi | Create and manage designs |
| DesignImportApi | Import designs from files |
| ExportApi | Export designs to various formats |
| FolderApi | Organize designs and assets |
| OauthApi | OAuth authentication |
| ResizeApi | Resize existing designs |
| UserApi | User profile and capabilities |
🏗️ Requirements
- Python 3.9+
- urllib3 (>=2.1.0,<3.0.0)
- python-dateutil (>=2.8.2)
- pydantic (>=2)
- typing-extensions (>=4.7.1)
- lazy-imports (>=1,<2)
📚 Documentation
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
⚠️ Disclaimer
This package is an unofficial Python client for the Canva Connect API. It is not officially endorsed or maintained by Canva. Canva® is a trademark of Canva Pty Ltd.
The official Canva Connect API documentation can be found at: https://www.canva.dev/docs/connect/
🆘 Support
📈 Changelog
See CHANGELOG.md for a list of changes and version history.
Generated from OpenAPI specification v2024-06-18 using OpenAPI Generator v7.15.0
Metadata
Release files for canva-connect-api 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| canva_connect_api-1.0.0.tar.gz | 214.7 kB | Without provenance | Details for canva_connect_api-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| canva_connect_api-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for canva_connect_api-1.0.0-py3-none-any.whl |
Total release size: 568.3 kB
Release files / canva_connect_api-1.0.0.tar.gz
| Download URL | canva_connect_api-1.0.0.tar.gz |
|---|---|
| Size | 214.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8735e3af3c2c65f6a631e39f161b9111be994c7eff52a4a1e2a78d40050d033f
|
|
BLAKE2b-256 checksum How to use checksums |
a76c2b5fec91b2fa483bee3777fe3711c0e441caa2362592849bedaca4da3680
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / canva_connect_api-1.0.0-py3-none-any.whl
| Download URL | canva_connect_api-1.0.0-py3-none-any.whl |
|---|---|
| Size | 353.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc9c848c0225ba4e23cc239894947933f27a2bf837da0d286b9ded9979bbefad
|
|
BLAKE2b-256 checksum How to use checksums |
4a69b6bb2e9c7853e5ab9dddb7235833c2ac323c1a8afe5aea90ff4bf6fce659
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for canva-connect-api 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.