Centro para desarrolladores

Integra Compressify en tus apps con una API REST simple y potente.

Primeros pasos

Compressify te permite subir imágenes y recibir versiones optimizadas en WebP, JPEG, PNG o AVIF para reducir peso y mejorar rendimiento.

Todas las peticiones autenticadas se sirven desde tu workspace de Compressify bajo /api/v1.

Plugin de WordPress disponible

Tenemos un plugin oficial de WordPress que intercepta las subidas y las optimiza vía API sin romper los metadatos de tu biblioteca.

Autenticación

Puedes autenticarte con tu API Key. Envíala en la cabecera Authorization como Bearer token o usa la cabecera X-API-Key.

Authorization: Bearer cf_live_your_api_key_here

Endpoint de optimización

Endpoint: POST /images/optimize

Envía una petición multipart/form-data con el archivo.

Video optimization is also available

Use POST /videos/optimize to compress or transcode common inputs such as MP4, MOV, AVI, MKV, and WebM into web-ready mp4 or webm. Pair it with POST /videos/analyze if you want duration, codecs, bitrate, and dimensions before converting.

Ejemplos

cURL

curl -X POST "https://your-compressify-workspace/api/v1/images/optimize" \
  -H "Authorization: Bearer cf_live_xxxxx" \
  -F "file=@/path/to/image.jpg" \
  -F "outputFormat=webp" \
  -F "quality=80" \
  -F "returnJson=true"

cURL (Video)

curl -X POST "https://your-compressify-workspace/api/v1/videos/optimize" \
  -H "Authorization: Bearer cf_live_xxxxx" \
  -F "file=@/path/to/video.mov" \
  -F "outputFormat=mp4" \
  -F "crf=28" \
  -F "returnJson=true"

PHP

$ch = curl_init('https://your-compressify-workspace/api/v1/images/optimize');
$cFile = new CURLFile('/path/to/image.jpg', 'image/jpeg', 'image.jpg');
$data = ['file' => $cFile, 'outputFormat' => 'webp', 'returnJson' => 'true'];

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer cf_live_xxxxx']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

Node.js (Fetch)

const formData = new FormData();
formData.append('file', fileInput.files[0]);
formData.append('outputFormat', 'webp');
formData.append('returnJson', 'true');

const response = await fetch('https://your-compressify-workspace/api/v1/images/optimize', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer cf_live_xxxxx' },
  body: formData
});
const data = await response.json();

ASP.NET (C#)

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "cf_live_xxxxx");

using var content = new MultipartFormDataContent();
using var fileStream = File.OpenRead("/path/to/image.jpg");
content.Add(new StreamContent(fileStream), "file", "image.jpg");
content.Add(new StringContent("webp"), "outputFormat");
content.Add(new StringContent("true"), "returnJson");

var response = await client.PostAsync("https://your-compressify-workspace/api/v1/images/optimize", content);
var result = await response.Content.ReadAsStringAsync();