API Documentation

Everything you need to integrate the Compresto Image Compression API.

Authentication

All API requests require an API key. Include your key in the X-API-Key header:

curl -H "X-API-Key: ck_your_api_key" https://api.compresto.app/v1/compress

Base URL

https://api.compresto.app

Endpoints

POST/v1/compress

Compress an image file.

Request (Multipart)

curl -X POST https://api.compresto.app/v1/compress \
  -H "X-API-Key: ck_your_api_key" \
  -F "image=@photo.jpg" \
  -F "quality=80" \
  -F "format=webp" \
  -F "maxWidth=1920" \
  -o compressed.webp

Request (JSON/URL)

curl -X POST https://api.compresto.app/v1/compress \
  -H "X-API-Key: ck_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/image.jpg",
    "quality": 80,
    "format": "webp"
  }'

Request (JSON/Base64)

curl -X POST https://api.compresto.app/v1/compress \
  -H "X-API-Key: ck_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "data:image/png;base64,iVBORw0KGgo...",
    "quality": 80,
    "format": "webp"
  }'

Parameters

ParameterTypeDefaultDescription
imagefile/string*Image file (multipart) or base64 string
urlstring*Public image URL (http/https)
qualitynumber801-100, compression quality
formatstring"auto""jpeg", "png", "webp", or "auto"
maxWidthnumbernullMax width (preserves aspect ratio)
maxHeightnumbernullMax height (preserves aspect ratio)

* One of image (file/base64) or url is required. Priority: file upload > url > base64.

Response

Returns compressed image binary with stats in headers:

HTTP/1.1 200 OK
Content-Type: image/webp
X-Original-Size: 2048576
X-Compressed-Size: 512000
X-Savings-Percent: 75
X-Output-Format: webp

<binary image data>

GET/v1/usage

Get current usage statistics.

curl https://api.compresto.app/v1/usage \
  -H "X-API-Key: ck_your_api_key"

Response

{
  "plan": "free",
  "usage": {
    "current": 47,
    "limit": 100,
    "resetAt": "2025-02-01T00:00:00Z"
  },
  "totals": {
    "bytesIn": 52428800,
    "bytesOut": 15728640,
    "savedBytes": 36700160,
    "savedPercent": 70
  }
}

GET/health

Check API status (no authentication required).

curl https://api.compresto.app/health

Error Codes

CodeMeaning
400Bad request (invalid parameters, blocked URL, invalid URL format)
401Unauthorized (missing or invalid API key)
413File too large (>10MB for free tier)
415Unsupported image format
429Rate limit exceeded (per-minute) or monthly quota exceeded
500Internal server error
502Failed to fetch image from URL
504URL fetch timed out

Rate Limits

The API enforces per-user rate limits based on your subscription tier:

PlanRate LimitMonthly Quota
Free60 req/min500 requests
Pro60 req/min5,000 requests
Business200 req/min50,000 requests
  • Rate limits are enforced per API key
  • Monthly quotas reset on the 1st of each month
  • Check your current usage via the /v1/usage endpoint

Support

Questions? Email us at support@compresto.app

Ready to get started?

Create a free account and get your API key.