Documentation: Getting started

Getting started

To start using the CheetahO service you need to sign up for the CheetahO service and obtain API Key. You will find it in the API Credentials section. Once you have set-up your account, you can start using CheetahO API in your applications.

If you will get in trouble to create your account we will be happy to help you. 

How to use

CheetahO right now supports JPEG, PNG, GIF image optimization. Images can be optimized in two ways:

  • By providing the URL: this type is perfect if you want to optimize any image from the Internet or you are in production.
  • By uploading images: this type is perfect for on-the-fly processing of your user’s uploads or for development (processing images on local env).

Authentication

The CheetahO API accepts HTTPS POST/GET requests only. Our API can be accessed through SSL secured connections. This means you have to use the HTTPS protocol in your requests.

Every request body must include a well-formed JSON object with a mandatory header parameter key

API Responses

Depending on image optimization way (Wait or Callback URL) in the response body you will find either the optimization queue ID or optimization results in JSON format with all the information about the optimized image and the URL to download it:

HTTP/1.1 200 OK
{
    "data": {
        "items": [
            {
                "original_size": 50464,
                "optimized_size": 40208,
                "saved_bytes": 10256,
                "saved_percent": 20.32,
                "url": "https://example.com/image_path.jpg",
                "optimization_status": "success",
                "web_p_url": null,
                "valid_till": "2021-01-08T18:13:10.945773Z",
                "message": null,
                "width": 1024,
                "height": 435
            }
        ],
        "transaction_id": "d679b-6c89-467d-872e-cf0175f"
    }
}

If image optimization goes wrong  you will get an error message in the response body:

{
    "error": {
        "type": "ValidationException",
        "message": [
            {
                "attribute": "files",
                "text": "The files field is required."
            }
        ]
    },

Image download

Please remember do not to use optimized image URL on your website. You have to download them first, and then replace them in your websites or applications. Optimized images are available on our servers for the time which is defined in optimized image response valid_till.