CrispCache API Guide

Complete guide to using the CrispCache API for image optimization, format conversion, and code minification.

Image Resize API

Resize images while maintaining aspect ratio or specifying exact dimensions.

Parameters

  • width - Target width in pixels
  • height - Target height in pixels
  • fit - Fit mode: contain, cover, fill (default: contain)
  • maintainAspectRatio - Maintain aspect ratio (default: true)
  • smoothScaling - Smooth scaling (default: true)
  • url - URL of image to resize (for GET requests)
  • inline - Return base64 encoded image (default: false)

# Using GET with URL:
curl "https://crispcache.com/api/images/resize?width=800&height=600&fit=contain&url=https://example.com/image.jpg"

# Using POST with file:
curl -X POST "https://crispcache.com/api/images/resize?width=800&height=600&fit=contain" \
     -F "[email protected]"

// Using GET with URL:
$url = "https://crispcache.com/api/images/resize?width=800&height=600&fit=contain&url=https://example.com/image.jpg";
$response = file_get_contents($url);

// Using POST with file:
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => "https://crispcache.com/api/images/resize?width=800&height=600&fit=contain",
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'image' => new CURLFile('image.jpg')
    ]
]);
$response = curl_exec($curl);

// Using GET with URL:
fetch('https://crispcache.com/api/images/resize?width=800&height=600&fit=contain&url=https://example.com/image.jpg')
.then(response => response.blob())
.then(data => console.log(data));

// Using POST with file:
const formData = new FormData();
formData.append('image', imageFile);

fetch('https://crispcache.com/api/images/resize?width=800&height=600&fit=contain', {
    method: 'POST',
    body: formData
})
.then(response => response.blob())
.then(data => console.log(data));

# Using GET with URL:
import requests
response = requests.get(
    'https://crispcache.com/api/images/resize?width=800&height=600&fit=contain&url=https://example.com/image.jpg'
)

# Using POST with file:
files = {'image': open('image.jpg', 'rb')}
response = requests.post(
    'https://crispcache.com/api/images/resize?width=800&height=600&fit=contain',
    files=files
)

// Using GET with URL:
resp, err := http.Get("https://crispcache.com/api/images/resize?width=800&height=600&fit=contain&url=https://example.com/image.jpg")

// Using POST with file:
file, _ := os.Open("image.jpg")
defer file.Close()

body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("image", "image.jpg")
io.Copy(part, file)
writer.Close()

req, _ := http.NewRequest("POST", 
    "https://crispcache.com/api/images/resize?width=800&height=600&fit=contain",
    body)
req.Header.Set("Content-Type", writer.FormDataContentType())

client := &http.Client{}
resp, _ := client.Do(req)

# Using GET with URL:
require 'open-uri'
response = URI.open("https://crispcache.com/api/images/resize?width=800&height=600&fit=contain&url=https://example.com/image.jpg").read

# Using POST with file:
require 'rest-client'
response = RestClient.post(
  'https://crispcache.com/api/images/resize?width=800&height=600&fit=contain',
  {
    image: File.new('image.jpg')
  }
)

# Using GET with URL:
let url = "https://crispcache.com/api/images/resize?width=800&height=600&fit=contain&url=https://example.com/image.jpg";
let response = reqwest::get(url).await?.text().await?;

# Using POST with file:
let client = reqwest::Client::new();
let response = client.post("https://crispcache.com/api/images/resize?width=800&height=600&fit=contain")
    .multipart(vec![("image", "image.jpg")])
    .send().await?.text().await?;
                        

Use Cases

  • Generating thumbnails for image galleries
  • Resizing product images for e-commerce sites
  • Creating responsive images for different screen sizes
  • Optimizing banner images for web pages

Image Convert API

Convert images between different formats while optimizing for web delivery.

Parameters

  • format - Target format (jpeg, png)
  • quality - Output quality (0-100)
  • url - URL of image to convert (for GET requests)
  • inline - Return base64 encoded image

# Using GET with URL:
curl "https://crispcache.com/api/images/convert?format=webp&quality=80&url=https://example.com/image.jpg"

# Using POST with file:
curl -X POST "https://crispcache.com/api/images/convert?format=webp&quality=80" \
     -F "[email protected]"

// Using GET with URL:
$url = "https://crispcache.com/api/images/convert?format=webp&quality=80&url=https://example.com/image.jpg";
$response = file_get_contents($url);

// Using POST with file:
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => "https://crispcache.com/api/images/convert?format=webp&quality=80",
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'image' => new CURLFile('image.jpg')
    ]
]);
$response = curl_exec($curl);

// Using GET with URL:
fetch('https://crispcache.com/api/images/convert?format=webp&quality=80&url=https://example.com/image.jpg')
.then(response => response.blob())
.then(data => console.log(data));

// Using POST with file:
const formData = new FormData();
formData.append('image', imageFile);

fetch('https://crispcache.com/api/images/convert?format=webp&quality=80', {
    method: 'POST',
    body: formData
})
.then(response => response.blob())
.then(data => console.log(data));

# Using GET with URL:
import requests
response = requests.get(
    'https://crispcache.com/api/images/convert?format=webp&quality=80&url=https://example.com/image.jpg'
)

# Using POST with file:
files = {'image': open('image.jpg', 'rb')}
response = requests.post(
    'https://crispcache.com/api/images/convert?format=webp&quality=80',
    files=files
)

// Using GET with URL:
resp, err := http.Get("https://crispcache.com/api/images/convert?format=webp&quality=80&url=https://example.com/image.jpg")

// Using POST with file:
file, _ := os.Open("image.jpg")
defer file.Close()

body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("image", "image.jpg")
io.Copy(part, file)
writer.Close()

req, _ := http.NewRequest("POST", 
    "https://crispcache.com/api/images/convert?format=webp&quality=80",
    body)
req.Header.Set("Content-Type", writer.FormDataContentType())

client := &http.Client{}
resp, _ := client.Do(req)

# Using GET with URL:
require 'open-uri'
response = URI.open("https://crispcache.com/api/images/convert?format=webp&quality=80&url=https://example.com/image.jpg").read

# Using POST with file:
require 'rest-client'
response = RestClient.post(
  'https://crispcache.com/api/images/convert?format=webp&quality=80',
  {
    image: File.new('image.jpg')
  }
)

# Using GET with URL:
let url = "https://crispcache.com/api/images/convert?format=webp&quality=80&url=https://example.com/image.jpg";
let response = reqwest::get(url).await?.text().await?;

# Using POST with file:
let client = reqwest::Client::new();
let response = client.post("https://crispcache.com/api/images/convert?format=webp&quality=80")
    .multipart(vec![("image", "image.jpg")])
    .send().await?.text().await?;
                        

Use Cases

  • Converting legacy images to modern WebP format
  • Creating JPEG fallbacks for WebP images
  • Optimizing PNG images for transparency
  • Batch converting image formats for web optimization

Image Compress API

Compress images while maintaining visual quality for optimal web delivery.

Parameters

  • quality - Compression quality (0-100)
  • url - URL of image to compress (for GET requests)
  • inline - Return base64 encoded image

# Using GET with URL:
curl "https://crispcache.com/api/images/compress?quality=80&url=https://example.com/image.jpg"

# Using POST with file:
curl -X POST "https://crispcache.com/api/images/compress?quality=80" \
     -F "[email protected]"

// Using GET with URL:
$url = "https://crispcache.com/api/images/compress?quality=80&url=https://example.com/image.jpg";
$response = file_get_contents($url);

// Using POST with file:
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => "https://crispcache.com/api/images/compress?quality=80",
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'image' => new CURLFile('image.jpg')
    ]
]);
$response = curl_exec($curl);

// Using GET with URL:
fetch('https://crispcache.com/api/images/compress?quality=80&url=https://example.com/image.jpg')
.then(response => response.blob())
.then(data => console.log(data));

// Using POST with file:
const formData = new FormData();
formData.append('image', imageFile);

fetch('https://crispcache.com/api/images/compress?quality=80', {
    method: 'POST',
    body: formData
})
.then(response => response.blob())
.then(data => console.log(data));

# Using GET with URL:
import requests
response = requests.get(
    'https://crispcache.com/api/images/compress?quality=80&url=https://example.com/image.jpg'
)

# Using POST with file:
files = {'image': open('image.jpg', 'rb')}
response = requests.post(
    'https://crispcache.com/api/images/compress?quality=80',
    files=files
)

// Using GET with URL:
resp, err := http.Get("https://crispcache.com/api/images/compress?quality=80&url=https://example.com/image.jpg")

// Using POST with file:
file, _ := os.Open("image.jpg")
defer file.Close()

body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("image", "image.jpg")
io.Copy(part, file)
writer.Close()

req, _ := http.NewRequest("POST", 
    "https://crispcache.com/api/images/compress?quality=80",
    body)
req.Header.Set("Content-Type", writer.FormDataContentType())

client := &http.Client{}
resp, _ := client.Do(req)

# Using GET with URL:
require 'open-uri'
response = URI.open("https://crispcache.com/api/images/compress?quality=80&url=https://example.com/image.jpg").read

# Using POST with file:
require 'rest-client'
response = RestClient.post(
  'https://crispcache.com/api/images/compress?quality=80',
  {
    image: File.new('image.jpg')
  }
)

# Using GET with URL:
let url = "https://crispcache.com/api/images/compress?quality=80&url=https://example.com/image.jpg";
let response = reqwest::get(url).await?.text().await?;

# Using POST with file:
let client = reqwest::Client::new();
let response = client.post("https://crispcache.com/api/images/compress?quality=80")
    .multipart(vec![("image", "image.jpg")])
    .send().await?.text().await?;
                        

Use Cases

  • Reducing image file sizes for faster loading
  • Optimizing images for mobile devices
  • Batch compressing image galleries
  • Reducing bandwidth usage for image-heavy websites

Image Watermark API

Add text watermarks to images with customizable size, opacity and positioning.

Parameters

  • text - Watermark text to add
  • text_size - Font size in pixels (default: 24)
  • text_color - Font color (default: #ffffff)
  • opacity - Watermark opacity (0-100, default: 50)
  • position - Watermark position (center, top-left, top-right, bottom-left, bottom-right)
  • url - URL of image to watermark (for GET requests)
  • inline - Return base64 encoded image

# Using GET with URL:
curl "https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right&url=https://example.com/image.jpg"

# Using POST with file:
curl -X POST "https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right" \
     -F "[email protected]"

// Using GET with URL:
$url = "https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right&url=https://example.com/image.jpg";
$response = file_get_contents($url);

// Using POST with file:
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => "https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right",
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'image' => new CURLFile('image.jpg')
    ]
]);
$response = curl_exec($curl);

// Using GET with URL:
fetch('https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right&url=https://example.com/image.jpg')
.then(response => response.blob())
.then(data => console.log(data));

// Using POST with file:
const formData = new FormData();
formData.append('image', imageFile);

fetch('https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right', {
    method: 'POST',
    body: formData
})
.then(response => response.blob())
.then(data => console.log(data));

# Using GET with URL:
import requests
response = requests.get(
    'https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right&url=https://example.com/image.jpg'
)

# Using POST with file:
files = {'image': open('image.jpg', 'rb')}
response = requests.post(
    'https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right',
    files=files
)

// Using GET with URL:
resp, err := http.Get("https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right&url=https://example.com/image.jpg")

// Using POST with file:
file, _ := os.Open("image.jpg")
defer file.Close()

body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("image", "image.jpg")
io.Copy(part, file)
writer.Close()

req, _ := http.NewRequest("POST", 
    "https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right",
    body)
req.Header.Set("Content-Type", writer.FormDataContentType())

client := &http.Client{}
resp, _ := client.Do(req)

# Using GET with URL:
require 'open-uri'
response = URI.open("https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right&url=https://example.com/image.jpg").read

# Using POST with file:
require 'rest-client'
response = RestClient.post(
  'https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right',
  {
    image: File.new('image.jpg')
  }
)

# Using GET with URL:
let url = "https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right&url=https://example.com/image.jpg";
let response = reqwest::get(url).await?.text().await?;

# Using POST with file:
let client = reqwest::Client::new();
let response = client.post("https://crispcache.com/api/images/watermark?text=Copyright&text_size=24&opacity=50&position=bottom-right")
    .multipart(vec![("image", "image.jpg")])
    .send().await?.text().await?;
                        

Use Cases

  • Adding copyright notices to images
  • Branding images with company logos
  • Protecting image ownership
  • Adding timestamps or location data

CSS Minification API

Minify CSS files to reduce file size and improve load times.

Parameters

  • url - URL of CSS file to minify (for GET requests)
  • inline - Return minified CSS as text
  • removeWhitespace - Remove whitespace (default: true)
  • removeLastNewline - Remove last newline (default: true)
  • removeLastSemicolon - Remove last semicolon (default: true)
  • shortenColors - Shorten 6-digit hex colors to 3-digit (default: false)

# Using GET with URL:
curl "https://crispcache.com/api/css/minify?url=https://example.com/styles.css&removeWhitespace=false&removeLastNewline=false&removeLastSemicolon=false&shortenColors=true"

# Using POST with file:
curl -X POST "https://crispcache.com/api/css/minify" \
     -F "[email protected]" \
     -F "removeWhitespace=false" \
     -F "shortenColors=true"

// Using GET with URL:
$url = "https://crispcache.com/api/css/minify?url=https://example.com/styles.css&removeWhitespace=false&shortenColors=true";
$response = file_get_contents($url);

// Using POST with file:
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => "https://crispcache.com/api/css/minify",
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'css' => new CURLFile('styles.css'),
        'removeWhitespace' => 'false',
        'shortenColors' => 'true'
    ]
]);
$response = curl_exec($curl);

// Using GET with URL:
fetch('https://crispcache.com/api/css/minify?url=https://example.com/styles.css&removeWhitespace=false&shortenColors=true')
.then(response => response.text())
.then(data => console.log(data));

// Using POST with file:
const formData = new FormData();
formData.append('css', cssFile);

fetch('https://crispcache.com/api/css/minify?removeWhitespace=false&shortenColors=true', {
    method: 'POST',
    body: formData
})
.then(response => response.text())
.then(data => console.log(data));

# Using GET with URL:
import requests
response = requests.get(
    'https://crispcache.com/api/css/minify?url=https://example.com/styles.css&removeWhitespace=false&shortenColors=true'
)

# Using POST with file:
files = {'css': open('styles.css', 'rb')}
response = requests.post(
    'https://crispcache.com/api/css/minify?removeWhitespace=false&shortenColors=true',
    files=files
)

// Using GET with URL:
resp, err := http.Get("https://crispcache.com/api/css/minify?url=https://example.com/styles.css&removeWhitespace=false&shortenColors=true")

// Using POST with file:
file, _ := os.Open("styles.css")
defer file.Close()

body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("file", "styles.css")
io.Copy(part, file)
writer.Close()

req, _ := http.NewRequest("POST", 
    "https://crispcache.com/api/css/minify?removeWhitespace=false&shortenColors=true",
    body)
req.Header.Set("Content-Type", writer.FormDataContentType())

client := &http.Client{}
resp, _ := client.Do(req)

# Using GET with URL:
require 'open-uri'
response = URI.open("https://crispcache.com/api/css/minify?url=https://example.com/styles.css&removeWhitespace=false&shortenColors=true").read

# Using POST with file:
require 'rest-client'
response = RestClient.post(
  'https://crispcache.com/api/css/minify?removeWhitespace=false&shortenColors=true',
  {
    css: File.new('styles.css')
  }
)

# Using GET with URL:
let url = "https://crispcache.com/api/css/minify?url=https://example.com/styles.css&removeWhitespace=false&shortenColors=true";
let response = reqwest::get(url).await?.text().await?;

# Using POST with file:
let client = reqwest::Client::new();
let response = client.post("https://crispcache.com/api/css/minify?removeWhitespace=false&shortenColors=true")
    .multipart(vec![("file", "styles.css")])
    .send().await?.text().await?;
                        

Use Cases

Common Use Cases for CrispCache API
Image Optimization Pipeline

Automatically optimize and resize images during your build process or content upload workflow.

Dynamic Asset Optimization

Minify CSS/JS files on-the-fly when serving to users, reducing bandwidth and improving load times.

Content Delivery Networks

Use CrispCache as part of your CDN strategy to serve optimized assets from edge locations.

Media Processing

Convert and resize images to different formats based on user device and browser capabilities.

Font Compress API

Compress fonts while maintaining quality for optimal web delivery.

Parameters

  • url - URL of font to compress (for GET requests)
  • inline - Return base64 encoded font

# Using GET with URL:
curl "https://crispcache.com/api/fonts/compress?url=https://example.com/font.ttf"

# Using POST with file:
curl -X POST "https://crispcache.com/api/fonts/compress" \
     -F "[email protected]"

// Using GET with URL:
$url = "https://crispcache.com/api/fonts/compress?url=https://example.com/font.ttf";
$response = file_get_contents($url);

// Using POST with file:
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => "https://crispcache.com/api/fonts/compress",
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'font' => new CURLFile('font.ttf')
    ]
]);
$response = curl_exec($curl);

// Using GET with URL:
fetch('https://crispcache.com/api/fonts/compress?url=https://example.com/font.ttf')
.then(response => response.blob())
.then(data => console.log(data));

// Using POST with file:
const formData = new FormData();
formData.append('font', fontFile);

fetch('https://crispcache.com/api/fonts/compress', {
    method: 'POST',
    body: formData
})
.then(response => response.blob())
.then(data => console.log(data));

# Using GET with URL:
import requests
response = requests.get(
    'https://crispcache.com/api/fonts/compress?url=https://example.com/font.ttf'
)

# Using POST with file:
files = {'font': open('font.ttf', 'rb')}
response = requests.post(
    'https://crispcache.com/api/fonts/compress',
    files=files
)

// Using GET with URL:
resp, err := http.Get("https://crispcache.com/api/fonts/compress?url=https://example.com/font.ttf")

// Using POST with file:
file, _ := os.Open("font.ttf")
defer file.Close()

body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("font", "font.ttf")
io.Copy(part, file)
writer.Close()

req, _ := http.NewRequest("POST", 
    "https://crispcache.com/api/fonts/compress",
    body)
req.Header.Set("Content-Type", writer.FormDataContentType())

client := &http.Client{}
resp, _ := client.Do(req)

# Using GET with URL:
require 'open-uri'
response = URI.open("https://crispcache.com/api/fonts/compress?url=https://example.com/font.ttf").read

# Using POST with file:
require 'rest-client'
response = RestClient.post(
  'https://crispcache.com/api/fonts/compress',
  {
    font: File.new('font.ttf')
  }
)

# Using GET with URL:
let url = "https://crispcache.com/api/fonts/compress?url=https://example.com/font.ttf";
let response = reqwest::get(url).await?.text().await?;

# Using POST with file:
let client = reqwest::Client::new();
let response = client.post("https://crispcache.com/api/fonts/compress")
    .multipart(vec![("font", "font.ttf")])
    .send().await?.text().await?;
                        

Use Cases

  • Reducing font file sizes for faster loading
  • Optimizing web fonts for better performance
  • Converting fonts to WOFF2 format
  • Reducing bandwidth usage for font-heavy websites