Developer API

A REST API for server-side image compression — for automation, backends, and pipelines. This is a separate product from the free browser tool above: requests here are processed on our servers (in memory, never persisted to disk), gated by an API key tied to your plan. Get a key from the dashboard.

Authentication

Pass your API key as a bearer token on every request:

Authorization: Bearer webpninja_live_<your_key>

Compress an image

POST /api/v1/compress — multipart form upload. Returns the compressed image bytes with the matching Content-Type.

Field Description
file The image to compress (multipart file field). Any format sharp can decode.
format Output format: webp, jpeg, png, or avif.
quality 10–100, default 80. Same compression settings as the browser tool at the same quality.
curl -X POST https://api.webpninja.com/api/v1/compress \
  -H "Authorization: Bearer webpninja_live_your_key" \
  -F "file=@photo.png" \
  -F "format=webp" \
  -F "quality=75" \
  --output photo.webp

Quotas & rate limits

Each plan includes a monthly compression quota that resets at the start of your billing period. Exceeding it returns 429 Too Many Requests. See current plan quotas and your usage on the dashboard.

Errors

Status Meaning
400 Missing file, or an invalid format/quality value.
401 Missing, invalid, or revoked API key.
422 The file couldn't be decoded or compressed.
429 Monthly quota exceeded for your plan.