📜  css minifier api - CSS (1)

📅  最后修改于: 2023-12-03 14:40:17.220000             🧑  作者: Mango

CSS Minifier API

CSS Minifier API is a web service that helps developers efficiently minify their CSS code. This API provides a simple and easy-to-use interface for developers to pass in their CSS code and receive the minified version in response.

Features
  • Lightweight and fast
  • Easy-to-use API
  • Supports minification of both CSS files and text content
  • Accepts different file formats, including css, less, and scss
Getting Started

To get started with the CSS Minifier API, sign up for an API key on the website. Once you have an API key, you can start using the API by making HTTP GET or POST requests.

Request Parameters

The following parameters can be included in the request:

  • key (required): the API key that you received when you signed up
  • input (required): the CSS code to be minified
  • dataType (optional): the type of data you are sending (e.g. "css", "less", "scss")
Response

The response returned by the CSS Minifier API will be in JSON format and will contain the following fields:

  • success: a boolean indicating whether the request was successful or not
  • message: a message indicating the status of the request (e.g. "OK" or an error message)
  • result: if the request was successful, the minified CSS code will be returned in this field
Examples
Example 1: Minify CSS code

Request:

curl https://api.cssminifier.com/sapi.cgi \
    -d "input=#menu a { color: #fff; text-decoration: none; }"

Response:

{
    "success": true,
    "message": "OK",
    "result": "#menu a{color:#fff;text-decoration:none}"
}
Example 2: Minify a CSS file

Request:

curl https://api.cssminifier.com/sapi.cgi \
    -F "input=@example.css" \
    -F "dataType=css"

Response:

{
    "success": true,
    "message": "OK",
    "result": ".test{color:red;font-weight:bold}"
}
Conclusion

Using the CSS Minifier API, developers can easily minify their CSS code and optimize their website's performance. The lightweight and fast nature of this API makes it an ideal solution for developers who want to streamline their development process. Get started today by signing up for an API key!