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 specificationAuthentication
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_key | Missing, unknown or revoked key |
| 413 too_large | The image exceeds the size limit |
| 415 unsupported_image | Synchronous path: not a supported PNG, JPEG, WebP or AVIF image |
| 422 image_too_large | Synchronous path: the image has more pixels than the service can process |
| failed / unsupported | Queued jobs report unsupported images in the result as status: failed and failure: unsupported |
| failed / too_large | Queued jobs report images beyond the processing limit as status: failed and failure: too_large |
| 429 quota_exceeded | The monthly quota is used up |
| 503 busy | The server is busy, try again shortly |