reSmush

reSmush

  • Category: Development

A Guide to Using the Resmush.it API

The Resmush.it 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 Resmush.it API with JavaScript.

API Requirements

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

Basic Usage

The Resmush.it 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 = 'https://api.resmush.it/ws.php?';
$.ajax({
  url: url,
  dataType: 'json',
  processData: false,
  contentType: false,
  headers: {
    'X-API-KEY': 'YOUR_API_KEY_HERE'
  },
  type: 'POST',
  data: formData,
  success: function(response) {
    console.log(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(`http://api.resmush.it/ws.php?img=${encodeURI(imageUrl)}`, {
  headers: {
    'Content-Type': 'application/json',
    'X-API-KEY': 'YOUR_API_KEY_HERE'
  },
}).then((response) => {
  return response.json();
}).then((data) => {
  console.log(data);
});

Conclusion

The Resmush.it 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!

Visit to reSmush website

Similar APIs of Development

Screenshot One

Screenshot One

Development

Render websites and HTML as images. Block cookie banners and ads. The API uses the latest Google Chrome for rendering and Google Cloud Platform for performance and scalability.

screenshotscreenshotrender

API2Cart

API2Cart

Development

API2Cart provides a unified shopping cart API for interaction between the eCommerce software and 30+ shopping carts including Magento, Shopify, WooCommerce, BigCommerce, OpenCart, PrestaShop and others.

shopifycommercepresta

Qrcode monkey API

Qrcode monkey API

Development

This is the official QRCode Monkey API for professional usage. Integrate custom and unique looking QR codes into your system or workflow. This API is perfect for creating thousands of high quality QR codes in png or svg vector format.

qrcodegeneratesvg

Product Hunt API

Product Hunt API

Development

Product Hunt now (finally) has its own api. Through this api you can access posts of the day, tech posts, filtered with a category, add a post etc. You can fetch list of users. Fetch comments, threads, notifications and even upvote your favorite products. The api lets you provide complete product hunt experience at one place. Use the api to get a taste !

productfeaturevote

Apptigent PowerTools

Apptigent PowerTools

Development

Essential utilities for string translation, text to speech, currency conversion, stock quotes, QR code generation, image processing, email validation, data transformation, scientific calculations and more!

translateredactconvert

Base API

Base API

Development

Base offers APIs for image and file storage, user authentication,email sending and more ...all in a single service!

authenticationemail

Dummy API

Dummy API

Development

Simple API that includes a common data for most of the applications. Like user info, some posts, comments, etc. This data is free to use for presentations, demos, learning tutorials. It is created especially for your education. Designed and deployed especially for your experiments API service ready to respond to your Client Application with close to real data.

educationtestingskill

Screencast O Matic API

Screencast O Matic API

Development

Screencast-O-Matic provides an E2E screen recording solution for developers. Solution Builder can be used for a simple integration into an existing workflow or for application providers who require full functionality with tight integration.

Screenrecorderapi

PhantAuth

PhantAuth

Development

Random User Generator + OpenID Connect Provider. Like Lorem Ipsum, but for user accounts and authentication. The OpenID Connect Provider of PhantAuth supports the flows listed in the OpenID Connect specifications (Hybrid, Implicit, Authorization Code), as well as the Resource Owner Password grant type, specified in the OAuth 2.0 specifications. PhantAuth as an OpenID Connect Provider can be integrated with a variety of web applications, mobil applications, and backend applications. The integration can be either direct, as in the case of the OpenID Connect Provider, or through an authentication integration service, as in the case of Auth0, Okta or Azure Active Directory B2C. To learn more, please go to chapter Integration.

openidauth0okta

Noun Project API

Noun Project API

Development

Use the Noun Project Icon API to tell visual stories, create real-time infographics, build interactive games, or whatever crazy idea you have.

iconapi