REST API Reference

SmartPNG API Documentation

Validate API keys, upload files, and integrate image compression into backends, CMS plugins, and automation workflows.

Base URLhttps://integration.smartpng.com/api

All API endpoints are available under this root URL.

AuthenticationAPI key required

Pass your key in the request body or as a form parameter.

Limits10MB max image size

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 /validate

Request 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 /compress

Content-Type

multipart/form-data

Form Parameters

ParameterTypeRequiredDescription
api_keystringYesYour API key
filefileYesImage 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 CodeDescription
200Success
400Bad Request - invalid parameters
401Unauthorized - invalid API key
413Payload Too Large - image exceeds 10MB
429Too Many Requests - insufficient credits
500Internal 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"