REST API

Overview

Cortado.js provides a RESTful API that allows you to interact with its image optimization and resizing services programmatically. This API enables you to integrate Cortado.js seamlessly into your backend services or frontend applications that communicate with REST endpoints.

Usage

To interact with Cortado.js via REST API, you can make HTTP requests to the appropriate endpoints. Here's how you can use the REST API to optimize and resize images:


  1. Optimize Image

Endpoint: /api/optimize

Method: POST

Payload:


{
  "imageUrl": "URL_OF_YOUR_IMAGE"
}

Send a POST request to this endpoint with the URL of the image you want to optimize. Cortado.js will optimize the image and return the optimized image URL in the response.


  1. Resize Image

Endpoint: /api/resize

Method: POST

Payload:


{
  "imageUrl": "URL_OF_YOUR_IMAGE",
  "width": 300,
  "height": 200
}

Send a POST request to this endpoint with the URL of the image you want to resize, along with the desired width and height. Cortado.js will resize the image and return the resized image URL in the response.

Example

Using Axios:


import axios from 'axios';

// Optimize Image
axios.post('/api/optimize', { imageUrl: 'URL_OF_YOUR_IMAGE' })
  .then(response => {
    const optimizedImageUrl = response.data.imageUrl;
    // Use the optimized image URL
  })
  .catch(error => {
    console.error('Error optimizing image:', error);
  });

// Resize Image
axios.post('/api/resize', { 
    imageUrl: 'URL_OF_YOUR_IMAGE',
    width: 300,
    height: 200
  })
  .then(response => {
    const resizedImageUrl = response.data.imageUrl;
    // Use the resized image URL
  })
  .catch(error => {
    console.error('Error resizing image:', error);
  });

This example demonstrates how to make POST requests to the Cortado.js REST API endpoints to optimize and resize images.

© 2024 Cortado. All rights reserved.

Designed by Ditych. Powered by Framer.

© 2024 Cortado. All rights reserved.

Designed by Ditych. Powered by Framer.