CSS Minify API version

Minify CSS from an input string or URLs.

.Maui CSS Minify API for minifying CSS documents from an input string or URLs.

POSTGET *
https://api.dotmaui.com/client/1.2/cssmin/

Parameters

Field Type Description Required
apikey String

.Maui Api key

True

css String

CSS valid code

1

url String

Valid URL to a CSS file

1

url[] String[]

One or more valid URL to CSS files

1

removeurlquotes Boolean

Removes quotes from urls. Default is true.

False

removecomments Boolean

Removes all comments. Default is true.

False

sortproperties Boolean

Sort CSS properties alphabetically. Default is false.

False

wrapcsslines Boolean

Wrap lines at 80 characters. Default is false.

False

unquoteselectors Boolean

Remove some specific selectors from selectors. Default is true.

True

mode String

Accepted values are:

  • default (default), the result of the operation will be the minified file as a string.

  • cdn, the minified file will be saved in .Maui's CDN.

False

name String

The name of the file that will be saved in the CDN. Ignored in default mode.

False

1 There must be one of these values

 

Examples of responses

In default mode, the response will be a string containing the minimized CSS code.

HTTP/2.0 200 OK         
body{background-color:#000}div{border:1px solid red}p,span{font-weight:bold;font-size:15px}

In CDN mode, the response will be a JSON object with the following properties:

Field Type Description
url String

The url where the minimized file was saved

size Integer

File size in bytes

UID String

Unique alphanumeric ID assigned in the .Maui CDN.

HTTP/2.0 200 OK         
{
    "url": "https://cdn.dotmaui.com/dotmaui/css/mystyle.min.css", 
    "size": 51913, 
    "UID": "d9dju4"
}

Examples

import urllib.parse
import urllib.request

css_string = """ 
body {
    background-color: #000000;
}

div {
    border: 1px solid red;
}

p,
span {

    font-weight: bold;
    font-size: 15px

}

"""

params = urllib.parse.urlencode({'apikey': 'YOUR_API_KEY', 'css': css_string}).encode("utf-8")
minified = urllib.request.urlopen("https://api.dotmaui.com/client/1.2/cssmin/", data = params).read().decode("utf-8")

print(minified) #body{background-color:#000}div{border:1px solid red}p,span{font-weight:bold;font-size:15px}
<?php

$data = array('apikey' => 'YOUR_API_KEY', 
              'url' => "https://dotmaui.com/assets/css/default.min.css");

$curl = curl_init("https://api.dotmaui.com/client/1.2/cssmin/");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 

$output = curl_exec($curl);  

curl_close($curl);

echo $output;
var url = "https://api.dotmaui.com/client/1.2/cssmin/";

var httpRequest = (HttpWebRequest)WebRequest.Create(url);
httpRequest.Method = "POST";

httpRequest.Accept = "application/json";
httpRequest.ContentType = "application/x-www-form-urlencoded";

var data = "apikey=YOUR_API_KEY&css=.maui%20is%20awesome%20%7B%20%09color%3A%23FFFFFF%3B%20%7D";

using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
{
   streamWriter.Write(data);
}

var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
   var result = streamReader.ReadToEnd();
}

Console.WriteLine(httpResponse.StatusCode);

* Only for premium users.