Libraries/5 of 24
Official SDKs
Install the Node, Python, PHP, Go, or Ruby client for the same REST API.
Official clients wrap compress, convert, download, usage, and white-label reports from the OpenAPI description. Keep API keys on the server. Quotas are enforced by the API.
- Node.js ·
npm install comprestack - Python ·
pip install comprestack - PHP ·
composer require comprestack/sdk - Go ·
go get github.com/MichaelGenesisII/Comprestack-API/sdk/go - Ruby ·
gem install comprestack
UI and batch tools live on the next pages: React, CLI, WordPress.
Node.js
npm install comprestack
import { writeFile } from "node:fs/promises"
import { Comprestack } from "comprestack"
const client = new Comprestack({
apiKey: process.env.COMPRESTACK_API_KEY,
})
// Keep the key on the server only (Route Handler / API route / backend).
const job = await client.convert({
files: ["photo.jpg"], // path, Blob, Buffer, or { data, filename }
format: "webp",
quality: "balanced",
})
await writeFile("photo.webp", Buffer.from(await client.download(job)))
console.log(job.usage.remaining, "images left this period")