Image optimization API documentation

To start using CheetahO image optimization API you need to sign up for CheetahO API services and obtain your unique API key. 

Calling methodParameters
POST

URL to call: http://app.cheetaho.com/api/v1/media

{“key“: “your api key”,  “lossy“:1, “url“: “http://yourdomain.com/path_to_image/file.jpg”}

JSON Encoded parameters, as follows

  • key – Your API key.
  • url – image URL to optimize.
  • lossy – image compression type.
  • quality – custom image quality

API Parameters

ParameterDescription
key

Your API key, as provided in your CheetahO control panel.

url

The URL where the original image is located. This needs to be a valid URL and urlencoded.

lossy

Controls whether the image compression will use a lossy or lossless algorithm.

0 – Lossless compression. Choose this option when you do not want to loose any of the original image’s details. New image will be identical with the original but smaller in size. 

1 – Lossy compression.  Compressed  image is not 100% identical with the original. If you want to have better compression rate, use this settings.

quality

This works only if lossy = 1  For the JPEG image format, specifying a quality level of 1 will produce the lowest image quality (highest compression level), whereas a quality of 100 will give you the best quality but the least compression.

API Return

FieldMeaning
errorContains the status message for the call. The status itself is an object with two fields:

  • Code – This is a numeric code identifying the outcome of the call. Can be:
    • 200 – No errors, image processed, download URL available.
    • 304 – Not Found. The file is no longer available.
    • 400 – Bad request. Invalid image URL. Please make sure the URL is properly urlencoded or points to a valid image file.
    • 401 – Unauthorized. Invalid API key. Check it in CheetahO panel.
    • 403 – Account has been temporarily suspended. Check your quota. Maybe you’ll need to subscribe to a higher plan to increase your quota.
    • 413 – Requested file size too large. The maximum file size is limited by you plan.
    • 415 – Bad file type.
    • 500 – Encountered an unexpected error and we can not finish your request.
  • Message – A text message explaining what the code stands for.
data
  • destURL – Download URL for optimized image.
  • originalSize – Size of the original image 
  • newSize – Size of compressed image 
  • savedBytes – Size of saved data. 
  • validTill – Timestamp how long the file is valid.

If you have questions, feel free to contact us.