Beta Compressor

API Documentation

Integrate image compression in minutes — cURL, JavaScript, Python and more

Base URL

URL
https://api.compressor.baidibek.kz

Authentication

Pass your API key in the X-Api-Key request header. Generate keys in your dashboard after signing up for a free account.

Header
X-Api-Key: YOUR_API_KEY

POST /compress

Compress and optionally resize or convert an image. Send the image as multipart/form-data. Returns the compressed image binary in the response body.

Parameters (multipart/form-data)

ParameterDescription
imageThe image file to compress. Accepted formats: JPEG, PNG, WebP, AVIF, GIF. Required.
qualityOutput quality (1–100). Higher values preserve more detail at larger file size. Default: 80.
widthMaximum output width in pixels. Image is scaled down proportionally if wider. Optional.
heightMaximum output height in pixels. Image is scaled down proportionally if taller. Optional.
formatOutput format: jpeg, png, webp, avif. Default: jpeg.

Response

Returns the compressed image as a binary stream. Inspect the following response headers for metadata:

  • X-Original-Size — original file size in bytes
  • X-Compressed-Size — compressed file size in bytes
  • X-Width / X-Height — output image dimensions in pixels

Examples

cURL
curl -X POST https://api.compressor.baidibek.kz/compress \
  -H "X-Api-Key: YOUR_API_KEY" \
  -F "image=@photo.jpg" \
  -F "quality=80" \
  -F "format=webp" \
  --output compressed.webp
JavaScript
const form = new FormData();
form.append('image', fileInput.files[0]);
form.append('quality', '80');
form.append('format', 'webp');

const res = await fetch('https://api.compressor.baidibek.kz/compress', {
  method: 'POST',
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
  body: form,
});

const blob = await res.blob();
// blob contains the compressed image
Python
import requests

with open('photo.jpg', 'rb') as f:
    res = requests.post(
        'https://api.compressor.baidibek.kz/compress',
        headers={'X-Api-Key': 'YOUR_API_KEY'},
        files={'image': f},
        data={'quality': '80', 'format': 'webp'},
    )

with open('compressed.webp', 'wb') as out:
    out.write(res.content)

Error codes

  • !401 — Missing or invalid API key
  • !429 — Monthly request limit reached
  • !400 — Invalid file, unsupported format or bad parameters

Rate limits

1 000 requests per account per calendar month on the free plan. The limit resets on the first day of each month. Parallel requests are allowed.