๐ Tooly API
Simple REST API to compress images programmatically. Integrate into your app, website, or workflow in minutes.
Base URL: https://tooly.in/api
๐ Authentication
All API requests require an API key passed in the request header.
Header:
x-api-key: your_api_key_here
โ ๏ธ API keys will be available after launch. Currently in development.
POST /compress
Compress an image and return the compressed version as a base64 string.
POST
https://tooly.in/api/compress
๐ค Request Parameters
Send a JSON body with the following fields:
| Parameter |
Type |
Required |
Description |
image |
string |
Required |
Base64 encoded image string |
quality |
number |
Optional |
Compression quality 1โ100. Default: 80 |
format |
string |
Optional |
Output format: webp, jpeg, png. Default: webp |
๐ฅ Response Format
Successful response returns compressed image data:
{
"success": true,
"compressed_image": "data:image/webp;base64,...",
"original_size": "2.4 MB",
"compressed_size": "340 KB",
"saved_percentage": "85.8%",
"format": "webp",
"width": 1920,
"height": 1080
}
โ ๏ธ Error Codes
| Code | Meaning |
400 | Bad request โ missing or invalid parameters |
401 | Unauthorized โ invalid or missing API key |
413 | File too large โ max 10MB allowed |
415 | Unsupported format โ only JPG, PNG, WebP |
429 | Rate limit exceeded |
500 | Server error โ try again |
๐ป Code Examples
const response = await fetch('https://tooly.in/api/compress', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
image: base64ImageString,
quality: 80,
format: 'webp'
})
});
const data = await response.json();
console.log(data.compressed_image);
console.log(`Saved: ${data.saved_percentage}`);
import requests
import base64
with open('image.jpg', 'rb') as f:
img_base64 = base64.b64encode(f.read()).decode()
response = requests.post(
'https://tooly.in/api/compress',
headers={'x-api-key': 'YOUR_API_KEY'},
json={
'image': img_base64,
'quality': 80,
'format': 'webp'
}
)
data = response.json()
print(f"Saved: {data['saved_percentage']}")
curl -X POST https://tooly.in/api/compress \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{
"image": "BASE64_IMAGE_STRING",
"quality": 80,
"format": "webp"
}'
๐งช Live Tester
Test the API directly from this page โ no code needed.