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:
Optimize Image
Endpoint: /api/optimize
Method: POST
Payload:
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.
Resize Image
Endpoint: /api/resize
Method: POST
Payload:
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:
This example demonstrates how to make POST requests to the Cortado.js REST API endpoints to optimize and resize images.