PY

Application integration

# Python + Transloadit

Upload and process a local file with pytransloadit, the maintained Python client for the Transloadit REST API.

Executable recipe

## Build the integration

The script reads one file path from the command line, uploads it, resizes the image, waits for completion, and prints the Assembly ID.

1. Create a virtual environment and install pytransloadit.
2. Set TRANSLOADIT\_KEY and TRANSLOADIT\_SECRET in the process environment.
3. Run python process\_image.py path/to/photo.jpg.

### Install

```
python -m venv .venv
source .venv/bin/activate
pip install pytransloadit
```

### process\_image.py

```
import os
import sys

from transloadit import client

transloadit = client.Transloadit(
    os.environ['TRANSLOADIT_KEY'],
    os.environ['TRANSLOADIT_SECRET'],
)

assembly = transloadit.new_assembly()
with open(sys.argv[1], 'rb') as input_file:
    assembly.add_file(input_file)
    assembly.add_step('resize', '/image/resize', {
        'width': 1200,
        'height': 1200,
        'resize_strategy': 'fit',
    })
    response = assembly.create(retries=5, wait=True)

print(response.data['assembly_id'])
```

## Authentication

* Read the Transloadit Auth Key and Auth Secret from server environment variables and pass both to the official Python SDK.
* The SDK signs requests when the secret is supplied; never commit either credential to source control.
* Use a fixed Template when application users choose files, or validate every dynamic Step before creating an Assembly.

## Limitations and operational notes

* wait=True blocks the process until the Assembly finishes. For web workers and long-running media jobs, store the Assembly ID and observe completion asynchronously.
* The maintained SDK supports Python 3.9 and newer; verify your runtime before installing the current release.
* Retries can resubmit work after transport failures. Keep application-level idempotency and record the returned Assembly ID.

## Related Robots

* [/upload/handle](/docs/robots/upload-handle.md)\
  Handle uploads
* [/image/resize](/docs/robots/image-resize.md)\
  Resize images
* [/s3/store](/docs/robots/s3-store.md)\
  Store results in S3

## Documentation

* [Transloadit Python SDK documentation](/docs/sdks/python-sdk.md)
* [Transloadit authentication documentation](/docs/api/authentication.md)
* [Python virtual environment documentation⁠](https://docs.python.org/3/library/venv.html)
* [pytransloadit source and examples⁠](https://github.com/transloadit/python-sdk)
  [Create a Template](/c/templates/new/)

More integrations

## Continue building your stack

NX

### [Next.js](/integrations/nextjs.md)

Signed Uppy uploads for the Next.js App Router.

LV

### [Laravel](/integrations/laravel.md)

Create Assemblies from Laravel with the official PHP SDK.

RB

### [Ruby](/integrations/ruby.md)

Create and monitor signed Assemblies from Ruby.
