A Guide to Using the API

The API provides a way to compress and optimize images. Developers can integrate this API into their applications to reduce the burden on image processing and hosting resources. In this guide, we will be exploring the use of the API with JavaScript.

API Requirements

To use the API, you’ll need a valid API key which can be obtained by signing up on the website.

Basic Usage

The API allows for two different types of requests:

  • POST request: allows you to upload an image file.
  • GET request: allows you to enter the URL of the image to be optimized.

Let’s dive into a simple example.

POST Request

To upload an image for compression, the following steps are to be followed:

  1. Create a new FormData object and append the file entry to it.
let formData = new FormData();
formData.append('files', fileObject);
  1. Make an AJAX request to the endpoint with your API key added to the header and the FormData object attached to the payload.
const url = '';
  url: url,
  dataType: 'json',
  processData: false,
  contentType: false,
  headers: {
  type: 'POST',
  data: formData,
  success: function(response) {
  1. The response will contain compressed image information such as image size, URL, etc.

GET Request

To optimize an image using the API by using its URL, the following command can be used.

fetch(`${encodeURI(imageUrl)}`, {
    headers: {
        'Content-Type': 'application/json',
    .then((response) => {
        return response.json();
    .then((data) => {


The API is an excellent tool for reducing image size and optimizing images without degrading quality. Integrating the API into a web-based application allows you to ensure that your images are always optimized while minimizing overall hosting costs. Get started today with these examples, and you’ll be well on your way to bringing your applications to the next level!