Batch Convert Images with the KoalaPic API
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
- Get your API key and try a batch conversion
- Set up webhooks to get notified when jobs complete
- Read the full API documentation for all available endpoints