Tutorials

Batch Convert Images with the KoalaPic API

· 2 min read · Tutorials

Converting images one at a time works fine for a handful of files. But when you’re processing product photos, user uploads, or an entire asset library, you need automation. The KoalaPic API’s batch endpoint converts up to 50 images in a single request.

Prerequisites

You’ll need an API key. Create one here — it takes 10 seconds.

Step 1: Upload Your Images

Send a POST request with multiple files to the batch endpoint:

curl -X POST https://koalapic.com/api/v1/convert/batch \
  -H "Authorization: Bearer kp_your_api_key" \
  -F "files=@photo1.png" \
  -F "files=@photo2.png" \
  -F "files=@photo3.png" \
  -F "output_format=webp" \
  -F "quality=85"

The response includes a job_id for tracking progress:

{
  "job_id": "abc123-def456",
  "status": "processing",
  "total_files": 3
}

Step 2: Poll for Completion

Check the job status until all files are converted:

import requests
import time

API_KEY = "kp_your_api_key"
JOB_ID = "abc123-def456"

while True:
    response = requests.get(
        f"https://koalapic.com/api/v1/jobs/{JOB_ID}",
        headers={"Authorization": f"Bearer {API_KEY}"},
    )
    data = response.json()

    if data["status"] == "completed":
        print(f"All {data['total_files']} files converted!")
        break
    elif data["status"] == "failed":
        print(f"Job failed: {data.get('error')}")
        break

    print(f"Progress: {data['completed_files']}/{data['total_files']}")
    time.sleep(2)

Step 3: Download Results

Each completed conversion includes a download URL. You can download files individually or grab everything as a ZIP:

# Download individual files
for item in data["items"]:
    file_response = requests.get(
        item["download_url"],
        headers={"Authorization": f"Bearer {API_KEY}"},
    )
    with open(item["filename"], "wb") as f:
        f.write(file_response.content)

Supported Parameters

The batch endpoint accepts the same parameters as single conversion:

Parameter Values Default
output_format jpg, png, webp, avif, gif, ico, bmp, tiff, pdf, heic, svg jpg
quality 1–100 85
smart_quality low, medium, high —
width / height pixels original
optimize_for 20 platform presets —

Rate Limits

Batch requests count as one API call regardless of file count, but each file counts toward your daily conversion quota. The API documentation has full rate limit details.

URL-Based Batch Conversion

Don’t have files locally? Use the URL batch endpoint to convert images from URLs:

curl -X POST https://koalapic.com/api/v1/convert/url/batch \
  -H "Authorization: Bearer kp_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://example.com/img1.png", "https://example.com/img2.png"], "output_format": "webp"}'

Next Steps

Enjoyed this article? Share it.

Related Posts

Enviar Comentarios

¡Gracias! Te responderemos pronto.

Instalar KoalaPic

Agrégalo a tu pantalla de inicio para acceso rápido

Preferencias de Cookies y Almacenamiento

Usamos cookies y almacenamiento local para mejorar tu experiencia. El almacenamiento esencial siempre está activo para el funcionamiento básico. Más información

Esencial

Protección CSRF, modo oscuro, seguimiento de errores. Siempre activo.

Funcional

Presets de conversión, preferencias de interfaz, estado de instalación de la PWA.

Análisis

Estadísticas de uso anónimas para mejorar el servicio.