npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

compresso-api

v0.1.1

Published

Node.js client for the Compresso image compression API: one request returns the compressed PNG, JPEG or WebP.

Readme

compresso-api

Node.js client for the Compresso image compression API. One request returns the compressed image: no job ids, no polling, no temporary URLs.

Compresso compresses PNG, JPEG and WebP and checks every result against the original pixel by pixel, so files get smaller without a visible quality loss. The free tier is 100 images per day per account, no card required.

npm install compresso-api

Quickstart

import { Compresso } from "compresso-api"

const client = new Compresso() // reads COMPRESSO_API_KEY

const result = await client.compressFile("photo.png", "photo-min.png")
console.log(`${result.originalSize} → ${result.compressedSize} bytes (-${result.savedPercent}%)`)
console.log(`${result.usage?.count} of ${result.usage?.limit} images used today`)

Get a key at compresso.space/dashboard and export it:

export COMPRESSO_API_KEY="csk_..."

Command line

The package ships a small CLI:

npx compresso-api photo.png                  # writes photo-min.png
npx compresso-api *.jpg --out optimized      # writes into a directory
npx compresso-api photo.png --json           # one JSON object per file

API

new Compresso(options?)

| Option | Default | Meaning | |---|---|---| | apiKey | process.env.COMPRESSO_API_KEY | API key | | baseUrl | https://api.compresso.space/v1 | API root | | maxRetries | 2 | Retries for errors the API marks retryable | | maxRetryDelayMs | 60000 | Cap on a single Retry-After wait | | timeoutMs | 120000 | Per-request timeout | | fetch | global fetch | Injectable for tests or proxies |

client.compress(bytes)

Takes a Uint8Array or ArrayBuffer, resolves with:

{
  data: Uint8Array        // the compressed image
  contentType: string     // image/png, image/jpeg, image/webp
  originalSize: number
  compressedSize: number
  savedBytes: number
  savedPercent: number
  usage?: { count: number; limit: number; reset: string }
  requestId?: string
}

client.compressFile(inputPath, outputPath?)

Reads the file, compresses it, writes outputPath when given, and resolves with the same result object.

client.usage()

{ plan: "free", compressionCount: 3, compressionLimit: 100, compressionReset: "2026-09-27T00:00:00Z", key: "csk_…a1b2" }

Errors

Every failure is a CompressoError with a machine-readable code, the HTTP status, the API's message, and requestId. Errors that are worth retrying carry retryAfter (seconds) and error.retryable === true; the client already retries those maxRetries times.

import { CompressoError } from "compresso-api"

try {
  await client.compressFile("huge.png", "huge-min.png")
} catch (error) {
  if (error instanceof CompressoError && error.code === "file_too_large") {
    // resize before sending: the API takes up to 16 MB and 16 megapixels
  } else {
    throw error
  }
}

Common codes: unauthorized, input_missing, invalid_image, unsupported_format, file_too_large, image_too_large, daily_limit_exceeded, rate_limited, server_busy, compress_failed. The full table is in the API docs.

Limits

  • 16 MB and 16 megapixels per image
  • 100 images per day per account on the free tier (resets at 00:00 UTC)
  • one request in flight plus one waiting per account
  • images are processed in memory and never stored or logged

Requirements

Node.js 18 or newer. No runtime dependencies.

License

MIT