...

Python SDK

Powerful Server-Side File Management with Python

Build robust file processing pipelines, automated workflows, and scalable backend services with our comprehensive Python SDK for popular web frameworks and applications.

Basic Python Upload
# Simple file upload and transformation
from filestack import Client

client = Client('YOUR_API_KEY')

# Upload a file
filelink = client.upload(filepath='/path/to/image.jpg')
print(f'Uploaded: {filelink.url}')

# Apply transformations
transformed = filelink.resize(
    width=300,
    height=300,
    fit='crop'
)
print(f'Transformed: {transformed.url}')

Built for Python Developers

Our Python SDK integrates seamlessly with your existing Python stack, providing Pythonic APIs and comprehensive framework support.

Trusted by innovative companies worldwide

Perfect for Server-Side Workflows

From simple file uploads to complex media processing pipelines, our Python SDK handles your most demanding server-side file management needs.

🚀 File Uploads
Upload local files, file-like objects, or external URLs using the Filestack Client.

⚙️ Filelink Operations
Download, overwrite, delete, retrieve metadata, and access uploaded files through Filelink objects.

🔄 URL-Based Transformations
Create transformation URLs by chaining resize, crop, rotate, format conversion, quality, and other transformation tasks.

🤖 Intelligent Ingestion
Enable Intelligent Ingestion for multipart uploads that adapt to network conditions.

🔒 Security and Webhooks
Sign Filestack requests with Security objects and verify incoming webhook signatures.

Django Integration Example
# Django integration example
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from filestack import Client

client = Client('YOUR_API_KEY')

@csrf_exempt
def upload_and_transform(request):
    if request.method != 'POST':
        return JsonResponse({'error': 'Method not allowed'}, status=405)

    uploaded_file = request.FILES['file']

    # Upload to Filestack
    filelink = client.upload(file_obj=uploaded_file)

    # Apply transformations
    transformed = filelink.resize(
        width=800,
        height=600,
        fit='crop'
    ).filetype_conversion(
        format='webp',
        quality=85
    )

    return JsonResponse({
        'original': filelink.url,
        'transformed': transformed.url,
        'handle': filelink.handle
    })

Quick Installation & Setup

Get started with our Python SDK using pip or your preferred package manager. Compatible with Python 3.7+ and all major frameworks.

Install Package

pip install filestack-python
poetry add filestack-python

Basic Usage

Import and initialize the client:

from filestack import Client
client = Client('YOUR_API_KEY')
filelink = client.upload(filepath='/path/to/file.jpg')
Complete Python Implementation
# Complete working example
import os
from filestack import Client, Filelink

# Initialize client
client = Client(os.environ['FILESTACK_API_KEY'])

# Upload a file
def upload(file_path):
    try:
        filelink = client.upload(filepath=file_path)
        print(f'Upload successful: {filelink.url}')
        return filelink
    except Exception as error:
        print(f'Upload failed: {error}')
        return None

# Transform an image
def create_thumbnail(handle):
    filelink = Filelink(handle)
    transformed = filelink.resize(
        width=200,
        height=200,
        fit='crop'
    ).filetype_conversion(
        format='webp',
        quality=80
    )
    return transformed.url

# Batch processing
def process_images(image_paths):
    results = []
    for path in image_paths:
        filelink = upload(path)
        if filelink is None:
            continue
        results.append({
            'original': filelink.url,
            'thumbnail': create_thumbnail(filelink.handle),
            'filename': os.path.basename(path)
        })
    return results

Start Building with Python

Join thousands of Python developers who trust Filestack for their server-side file management needs. From startups to enterprise, our Python SDK scales with your applications.