API Documentation

Integrate powerful image compression into your applications

Getting Started

Our API allows you to compress and convert images programmatically. No API key required for basic usage.

Base URL:

https://compressorimage.com/api

POST /api/compress

Compress and convert a single image.

Parameters

ParameterTypeRequiredDescription
fileFileYesImage file (max 10MB)
formatStringNojpeg, png, webp, avif (default: webp)
qualityNumberNo1-100 (default: 85)
widthNumberNoTarget width in pixels
heightNumberNoTarget height in pixels

Example Request

curl -X POST https://compressorimage.com/api/compress \
  -F "file=@image.jpg" \
  -F "format=webp" \
  -F "quality=85" \
  -o compressed.webp

POST /api/batch-compress

Compress multiple images at once. Returns a ZIP file containing all compressed images.

Parameters

ParameterTypeDescription
filesFile[]Array of images (max 20)
formatStringOutput format for all images
qualityNumberQuality setting for all images

Example Request

curl -X POST https://compressorimage.com/api/batch-compress \
  -F "files=@image1.jpg" \
  -F "files=@image2.png" \
  -F "format=webp" \
  -F "quality=85" \
  -o compressed.zip

Rate Limits

To ensure fair usage, we implement the following rate limits:

  • Free tier: 100 requests per hour per IP address
  • File size limit: 10MB per image
  • Batch limit: 20 images per request

Need higher limits? Contact us about our premium API plans.

Code Examples

JavaScript / Node.js

const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('format', 'webp');
formData.append('quality', '85');

const response = await fetch('/api/compress', {
  method: 'POST',
  body: formData
});

const blob = await response.blob();
const url = URL.createObjectURL(blob);

Python

import requests

files = {'file': open('image.jpg', 'rb')}
data = {'format': 'webp', 'quality': '85'}

response = requests.post(
    'https://compressorimage.com/api/compress',
    files=files,
    data=data
)

with open('compressed.webp', 'wb') as f:
    f.write(response.content)