PNG Compressor API

Welcome to PNG Compressor! To plug into the power of PNG Compressor API you need to Sign Up for our API services and obtain your unique API Key (Its Free). You will find your API key in your Account under the API Credentials section. Once you have set-up your Account, you can start using PNG Compressor API in your applications.

We love helping customers get up and running with our system! Should you have any questions about PNG Compressor API simply write us at support@pngcompressor.com

How to use

PNG Compressor supports JPEG, PNG, GIF (including animated GIFs) and SVG images. You can optimize your images in two ways - by providing a URL of the image you want to optimize or by uploading an image file directly to PNG Compressor API.

The first option (image URL) is great for images that are already in Live or available on any other place on the Internet. The second one (direct upload) is good for your development process, build script or the on-the-fly processing of your user's uploads where you don't have the images available online yet.

HTTPS Status codes

Status Code Description
200 OK The request was successfully processed.
202 Accepted The request has been accepted, but not yet processed.
400 Bad Request The request was not understood by the server, generally due to bad syntax or because the Content-Type header was not correctly set to application/json.
401 Unauthorised The necessary authentication credentials are not present in the request or are incorrect.
403 Forbidden Your account has been temporarily suspended.
404 Not Found The requested resource was not found.
406 Not Acceptable Unknown error.
408 Request Timeout The request Processing timeout.
413 Request Entity Too Large File size too large. The maximum file size is:
415 Unsupported Media Type File type not supported.
422 Unprocessable Entity Unprocessable Entity.
500 Internal Server Error Encountered an unexpected error and cannot fulfil your request.

Auth Error

PNG Compressor API uses Authorization mechanism. API Key is very important element of this whole API system usability make sure you are sending API key in all your requests as in HEADER information. You will get the following errors or response if your authorization getting failed or any other errors.

Here is the parameter:

Property Description
Authorization Set HEADER of "Your API Key"

Email Not Verified

If a user does not have a verified email address with PNG Compressor then his API key will not able to work for the application. So we strongly recommend that you must verify your email address in order to start using the API key.

Following will be the response:

{
  "success": false,
  "message": "The necessary authentication credentials are not present in the request or are incorrect",
  "errorMsg": "Please verify your email address"        
}

Account Blocked

For any reason if your account got blocked by PNG Compressor Admin team. Your API keys will be limited on the same time and you will start getting this message.

Following will be the response:

{
  "success": false,
  "message": "The necessary authentication credentials are not present in the request or are incorrect",
  "errorMsg": "User Blocked, Please contact support team"        
}

Key Disabled

If your Key has been disabled by you or your team member. Then you will start getting this error while your application tried to connect with our server to optimize or compress any image.

Following will be the response:

{
  "success": false,
  "message": "The necessary authentication credentials are not present in the request or are incorrect",
  "errorMsg": "API key has been disabled"        
}

Key Deleted

If you registered API key has been deleted by you then where you configured the same API key will not able to process the images and your application will start getting this AUTH response from our server.

Following will be the response:

{
  "success": false,
  "message": "The necessary authentication credentials are not present in the request or are incorrect",
  "errorMsg": "API key has been deleted"        
}

Invalid Key

If your configured API key or a user does not matched to our records, then your application will start getting this error in response:

{
  "success": false,
  "message": "The necessary authentication credentials are not present in the request or are incorrect",
  "errorMsg": "An API key or User does not exist"        
}

Missing Auth Key in Header

If your configuration isn’t sending Auth key in your request header then you will get a response from our server:

{
  "success": false,
  "message": "The necessary authentication credentials are not present in the request or are incorrect",
  "errorMsg": "API key is missing"        
}

Required field

If you are not sending any required field within your request to API server you will get this error:

{
  "success": false,
  "message": "The necessary authentication credentials are not present in the request or are incorrect",
  "errorMsg": "Does not received required fields"        
}

User Register

You can use this API endpoint to create an account on our website. Once you created an account make sure you must have your email verified. We made a pretty simple way to create an account dynamically so make sure you are using correct parameters.

Property Description
email Email Address of the user
your_name Name of the applicant
POST
https://api.pngcompressor.com/v1.0/register

Example request body

{
  "email": "email@yourdomain.com",
  "your_name": "user"
}

Success(200) response

  {
    "success": true,
    "message": "Registration successfully, Please verify email address.",
    "apikey": "{Your API Key}"
  }

Error(202) response

  {
    "success": false,
    "message": "Request has been accepted but not yet processed",
    "errorMsg": "This Email is already registered"
  }

Error(202) response

  {
    "success": false,
    "message": "Request has been accepted but not yet processed",
    "errorMsg": "Email address is not valid. Please enter a valid Email address."
  }

User Details

We allows you to programmatically query your account status, enabling you to retrieve details such as the name of the plan you have subscribed to, your total quota, used quota, remaining quota, and the status of your account.

This can be useful for instances where the user needs to be alerted when the quota is about to be reached, enabling him or her to take action, such as upgrading to a larger plan or add more add-on credits to the account.

Property Description
Authorization Set HEADER of "Your API Key"
GET
https://api.pngcompressor.com/v1.0/user-status

Example response

  {
    "success": true,
    "key_active": true,
    "plan_name": "{plan name}",
    "quota_total": "{total credit}",
    "quota_used": "{total used credit}",
    "quota_remaining": "{total remaining credits}"
  }

Image URL

If you want to compress images with URLs then send your image url as in JSON request to our server. Optional parameters are callbackurl and wait if would like to use them.

Property Description
imageurl URL of image to compress
callbackurl Your callback URL (optional)
wait True or false (optional) by default false
Authorization Set HEADER of "Your API Key"
POST
https://api.pngcompressor.com/v1.0/url

Example request body

{
  "imageurl": "http://your-website.com/images/banner.jpg"  
}

Success(200) response

{
  "success": true,
  "file_name": "{file name of image}",
  "original_size": "{image size in bytes}",
  "compress_size": "{image size in bytes}",
  "compress_percentage": "{compress size in %}",
  "compress_path": "{compress file path}",
  "created": "{timestump}"
}

Error(413) response

{
  "success": false,
  "message": "Image size grater than your limit",
  "errorMsg": "File size too large. The maximum file size is {'image size'}  bytes",
  "status": 413
}

Error(404) response

{
  "success": false,
  "message": "File not found",
  "errorMsg": "{error message}",
  "status": 404
}

Error(422) response

{
  "success": false,
  "message": "Unprocessable Entity",
  "errorMsg": "{error message}",
  "status": 422
}

Error(408) response

{
  "success": false,
  "message": "Processing timeout",
  "errorMsg": "{error message}",
  "status": 408
}

Error(406) response

{
  "success": false,
  "message": "Unknown error",
  "errorMsg": "{error message}",
  "status": 406
}

Error(415) response

{
  "success": false,
  "message": "File type not supported {'filetype'}",
  "errorMsg": "{error message}",
  "status": 415
}

Error(412) response

{
  "success": false,
  "message": "compressor failed",
  "errorMsg": "{error message}",
  "status": 412
}

Error(401) response

{
  "success": false,
  "message": "The necessary authentication credentials are not present in the request or are incorrect",
  "errorMsg": "You have exceeded your limit, Please recharge or upgrad to higher plan",
  "status": 401
}

Upload

If you want to compress images with upload then send your image file in request to our server. Optional parameters are callbackurl and wait if would like to use them.

Note: Set HEADER of request "Content-Type" must be "multipart/form-data"

Property Description
image Upload image file path to compress
callbackurl Your callback URL (optional)
wait True or false (optional) by default false
Authorization Set HEADER of "Your API Key"
POST
https://api.pngcompressor.com/v1.0/upload

Example request body

{
  "image": "{file path}"
}

Success(200) response

{
  "success": true,
  "file_name": "{file name of image}",
  "original_size": "{image size in bytes}",
  "compress_size": "{image size in bytes}",
  "compress_percentage": "{compress size in %}",
  "compress_path": "{compress file path}",
  "created": "{timestump}"
}

Error(415) response

{
  "success": false,
  "message": "File type not supported {'filetype'}",
  "errorMsg": "{error message}",
  "status": 415
}

Error(413) response

{
  "success": false,
  "message": "Image size grater than your limit",
  "errorMsg": "File size too large. The maximum file size is {'image size'}  bytes",
  "status": 413
}

Error(412) response

{
  "success": false,
  "message": "compressor failed",
  "errorMsg": "{error message}",
  "status": 412
}

Error(401) response

{
  "success": false,
  "message": "The necessary authentication credentials are not present in the request or are incorrect",
  "errorMsg": "You have exceeded your limit, Please recharge or upgrad to higher plan",
  "status": 401
}

Callback URL and Wait

If you want to compress images with URLs then send your image url as in JSON request to our server. Optional parameters are callbackurl and wait if would like to use them.

Property Description
imageurl URL of image to compress
callbackurl Your callback URL (optional)
wait True or false (optional) by default false
Authorization Set HEADER of "Your API Key"
POST
https://api.pngcompressor.com/v1.0/url
POST
https://api.pngcompressor.com/v1.0/upload

Example request body

{
  "imageurl": "http://your-website.com/images/banner.jpg",
  "callbackurl": "http://your-website.com/get-compressor-images",
  "wait": true  
}

Success(200) response

{
 "success": true,
 "id": "{callback request id}"
}
Show examples in:
PNG Compressor API Doc