API Reference

Overview Authentication Compress Image Request Params Response Format Error Codes Code Examples Live Tester

๐Ÿ”Œ 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:

JSON Response
{ "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

CodeMeaning
400Bad request โ€” missing or invalid parameters
401Unauthorized โ€” invalid or missing API key
413File too large โ€” max 10MB allowed
415Unsupported format โ€” only JPG, PNG, WebP
429Rate limit exceeded
500Server error โ€” try again

๐Ÿ’ป Code Examples

JavaScript
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}`);
Python
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
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.

Try it out