All API endpoints are available under this root URL.
REST API Reference
SmartPNG API Documentation
Validate API keys, upload files, and integrate image compression into backends, CMS plugins, and automation workflows.
Pass your key in the request body or as a form parameter.
Supported formats are PNG, JPEG, and WebP.
Authentication
All API requests require an API key. Include your API key in the request body or as a form parameter.
Get your API key from the Dashboard.
1. Validate API Key
Check whether an API key is valid and return the remaining balance available for compression.
Endpoint
POST /validateRequest Body
{
"api_key": "your_api_key_here"
}Response
{
"valid": true,
"user_id": "user_id",
"credits_remaining": 1000,
"can_compress": true,
"max_image_size": 10485760
}2. Compress Image
Upload an image for immediate compression. This flow works well for small to medium files.
Endpoint
POST /compressContent-Type
multipart/form-dataForm Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
api_key | string | Yes | Your API key |
file | file | Yes | Image file in PNG, JPEG, or WebP format |
Response
{
"success": true,
"job_id": "unique_job_id",
"status": "completed",
"message": "Image compressed successfully",
"compressed_data": "base64_encoded_image",
"original_size": 1048576,
"compressed_size": 524288,
"compression_ratio": 50.0
}Error Codes
| Status Code | Description |
|---|---|
200 | Success |
400 | Bad Request - invalid parameters |
401 | Unauthorized - invalid API key |
413 | Payload Too Large - image exceeds 10MB |
429 | Too Many Requests - insufficient credits |
500 | Internal Server Error |
Limits
- Maximum file size: 10MB
- Supported formats: PNG, JPEG, WebP
- Credit cost: 1 credit per compression
Example cURL Request
curl -X POST https://integration.smartpng.com/api/compress \
-F "api_key=your_api_key_here" \
-F "file=@/path/to/image.png"