Skip to content

transloadit/python-sdk

Folders and files

NameName
Last commit message
Last commit date
Nov 29, 2024
Mar 24, 2023
May 5, 2023
Dec 3, 2024
Dec 3, 2024
Jul 16, 2024
Nov 29, 2024
Dec 3, 2024
May 24, 2017
Apr 9, 2024
Nov 17, 2017
Nov 28, 2024
May 18, 2023
Jan 13, 2025
Dec 3, 2024
Jan 18, 2022

Repository files navigation

Build status Coverage

Transloadit python-sdk

A Python Integration for Transloadit's file uploading and encoding service.

Intro

Transloadit is a service that helps you handle file uploads, resize, crop and watermark your images, make GIFs, transcode your videos, extract thumbnails, generate audio waveforms, and so much more. In short, Transloadit is the Swiss Army Knife for your files.

This is a Python SDK to make it easy to talk to the Transloadit REST API.

Only Python 3.9+ versions are supported.

Install

pip install pytransloadit

Usage

from transloadit import client

tl = client.Transloadit('TRANSLOADIT_KEY', 'TRANSLOADIT_SECRET')
assembly = tl.new_assembly()
assembly.add_file(open('PATH/TO/FILE.jpg', 'rb'))
assembly.add_step('resize', '/image/resize', {'width': 70, 'height': 70})
assembly_response = assembly.create(retries=5, wait=True)

print(assembly_response.data.get('assembly_id'))

# or
print(assembly_response.data['assembly_id'])

Example

For fully working examples, take a look at examples/.

Documentation

See readthedocs for full API documentation.

Contributing

Running tests

If you have a global installation of poetry, you can run the tests with:

poetry run pytest --cov=transloadit tests

If you can't use a global installation of poetry, e.g. when using Nix Home Manager, you can create a Python virtual environment and install Poetry there:

python -m venv .venv && source .venv/bin/activate && pip install poetry && poetry install

Then to run the tests:

source .venv/bin/activate && poetry run pytest --cov=transloadit tests

Generate a coverage report with:

poetry run pytest --cov=transloadit --cov-report=html tests

Then view the coverage report locally by opening htmlcov/index.html in your browser.