Developers

Image Compression API

Compress JPG, PNG, WebP and AVIF with the Bitinz image compression API. Add smaller images to your workflow, with a free monthly quota for every account.

Download the OpenAPI specification
Get an API key

Authentication

Create an API key in your dashboard, then use HTTP Basic auth (user api, password = key) or send Authorization: Bearer <key>.

curl --user api:YOUR_API_KEY ...
# or
curl -H "Authorization: Bearer YOUR_API_KEY" ...

Compress an image

POST the image as the request body to /api/v1/shrink. Optional query parameters: level (fast / default / best) and filename.

curl -i --user api:YOUR_API_KEY \
  --data-binary @photo.jpg \
  "https://bitinz.com/api/v1/shrink?level=default&filename=photo.jpg"

Response

Successful requests usually return 201 with status done. The Location header and output.url point to the download. Compression-Count is your usage this month.

HTTP/1.1 201 Created
Location: https://bitinz.com/api/v1/results/<id>/download
Compression-Count: 1

{
  "id": "<id>",
  "status": "done",
  "input":  { "size": 2277375, "type": "image/jpeg" },
  "output": { "size": 992450, "type": "image/jpeg", "ratio": 0.436,
              "url": "https://bitinz.com/api/v1/results/<id>/download" },
  "unchanged": false,
  "expiresAt": "2026-10-02T12:00:00Z"
}

Accepted and waiting: 202

A longer queue may return 202 Accepted with status pending. Location points to the job status, not the download. Keep this URL and poll it instead of submitting the image again.

HTTP/1.1 202 Accepted
Location: https://bitinz.com/api/v1/results/<id>

{
  "id": "<id>",
  "status": "pending",
  "input": { "size": 2277375 },
  "expiresAt": "2026-10-02T12:00:00Z"
}

Poll the job status

Send GET /api/v1/results/{id} to the URL returned in Location every 1–2 seconds. pending means queued (queuePosition gives its current place); processing means compression is underway. When status is done, download from downloadUrl. failed means the job could not finish; failure identifies the category and note explains why.

curl "https://bitinz.com/api/v1/results/<id>"

{
  "id": "<id>",
  "status": "done",
  "available": true,
  "downloadUrl": "/api/v1/results/<id>/download",
  "outputSize": 992450,
  "unchanged": false
}

Download the result

Results can be downloaded until they expire; afterwards the URL returns 410.

curl -o photo.min.jpg "https://bitinz.com/api/v1/results/<id>/download"

Error codes

{ "error": { "code": "...", "message": "..." } }

401 unauthorized / invalid_keyMissing, unknown or revoked key
413 too_largeThe image exceeds the size limit
415 unsupported_imageSynchronous path: not a supported PNG, JPEG, WebP or AVIF image
422 image_too_largeSynchronous path: the image has more pixels than the service can process
failed / unsupportedQueued jobs report unsupported images in the result as status: failed and failure: unsupported
failed / too_largeQueued jobs report images beyond the processing limit as status: failed and failure: too_large
429 quota_exceededThe monthly quota is used up
503 busyThe server is busy, try again shortly