Overview
Deflato API lets you compress images programmatically. Send an image, get a compressed version back. Simple.
Base URL: https://deflato.com/api/v1
Authentication: Authorization: Bearer YOUR_API_KEY
API access requires a Pro plan. Generate keys in your account.
POST/api/v1/compress
Compress a single image. Returns the compressed file as binary.
| Parameter | Type | Default | Description |
file | file | required | Image file (JPEG, PNG, WEBP, HEIC, TIFF, BMP, RAW) |
quality | int | 80 | Output quality 1-100 |
max_dimension | int | 0 | Max width/height in px (0 = no resize) |
output_format | string | JPEG | JPEG, PNG, WEBP, or AVIF |
strip_exif | bool | true | Remove EXIF metadata |
Example: cURL
curl -X POST https://deflato.com/api/v1/compress \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@photo.jpg" \
-F "quality=75" \
-F "output_format=WEBP" \
-F "max_dimension=1920" \
--output compressed.webp
Example: Python
import requests
resp = requests.post(
"https://deflato.com/api/v1/compress",
headers={"Authorization": "Bearer YOUR_API_KEY"},
files={"file": open("photo.jpg", "rb")},
data={"quality": "75", "output_format": "WEBP"},
)
with open("compressed.webp", "wb") as f:
f.write(resp.content)
Example: JavaScript (Node.js)
const FormData = require('form-data');
const fs = require('fs');
const fetch = require('node-fetch');
const form = new FormData();
form.append('file', fs.createReadStream('photo.jpg'));
form.append('quality', '75');
form.append('output_format', 'WEBP');
const resp = await fetch('https://deflato.com/api/v1/compress', {
method: 'POST',
headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
body: form,
});
fs.writeFileSync('compressed.webp', Buffer.from(await resp.arrayBuffer()));
POST/api/v1/info
Get compression info without downloading. Returns JSON with sizes, dimensions, savings.
Same parameters as /compress.
{
"success": true,
"input_size": 2456789,
"output_size": 345678,
"input_dimensions": [4032, 3024],
"output_dimensions": [1920, 1440],
"savings_percent": 86,
"output_format": "WEBP"
}
Rate Limits
| Plan | Requests/day | Max file size | Formats |
| Pro | 500 | 500 MB | JPEG, PNG, WEBP, HEIC, TIFF, BMP, RAW, AVIF |
Supported Output Formats
| Format | Extension | Best for |
| JPEG | .jpg | Photos, best compatibility |
| WEBP | .webp | Web — 25-30% smaller than JPEG |
| AVIF | .avif | Modern web — 40-50% smaller than JPEG |
| PNG | .png | Transparency, screenshots |
Error Codes
| Code | Meaning |
401 | Invalid or missing API key |
403 | Pro plan required |
429 | Rate limit exceeded |
400 | No file provided or invalid parameters |
500 | Processing error |
SDKs & Integrations
Python SDK
pip install deflato
from deflato import Deflato
client = Deflato("YOUR_API_KEY")
result = client.compress("photo.jpg", format="WEBP", quality=75)
print(f"Saved {result.savings_percent}%")
Node.js SDK
npm install deflato
const Deflato = require('deflato');
const client = new Deflato('YOUR_API_KEY');
const result = await client.compress('photo.jpg', {
format: 'WEBP', quality: 75
});
console.log(`Saved ${result.savingsPercent}%`);
MCP Server (AI Assistants)
Published on npm. One command setup:
claude mcp add deflato npx mcp-server-deflato -e DEFLATO_API_KEY=your-key
{
"mcpServers": {
"deflato": {
"command": "npx",
"args": ["mcp-server-deflato"],
"env": { "DEFLATO_API_KEY": "your-key" }
}
}
}
Then ask your AI: "Compress all images in ./assets to WEBP"
npm: npmjs.com/package/mcp-server-deflato