{"openapi":"3.1.0","info":{"title":"compresso API","version":"1.0.0","description":"Visually lossless image compression. Documentation: https://compresso.space/developers"},"servers":[{"url":"https://api.compresso.space/v1"}],"security":[{"basicAuth":[]},{"bearerAuth":[]}],"paths":{"/compress":{"post":{"operationId":"compressImage","summary":"Compress an image","description":"Send one PNG, JPEG or WebP image (up to 16 MB and 16 MP) as the raw request body, or as multipart/form-data in a field named file.\n\nThe response body is the compressed image in the same format; when compression cannot make the file smaller without visible loss, the original bytes come back.\n\nOnly 200 responses count towards the daily limit. Retry 429/503 only when Retry-After is present.\n\nExample: curl --user api:YOUR_API_KEY --data-binary @photo.png -o photo-min.png --fail-with-body https://api.compresso.space/v1/compress","requestBody":{"required":true,"content":{"image/png":{"schema":{"type":"string","format":"binary"}},"image/jpeg":{"schema":{"type":"string","format":"binary"}},"image/webp":{"schema":{"type":"string","format":"binary"}},"application/octet-stream":{"schema":{"type":"string","format":"binary"}},"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"}}}}}},"responses":{"200":{"description":"The compressed image.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Original-Size":{"$ref":"#/components/headers/Original-Size"},"Compressed-Size":{"$ref":"#/components/headers/Compressed-Size"},"Compression-Count":{"$ref":"#/components/headers/Compression-Count"},"Compression-Limit":{"$ref":"#/components/headers/Compression-Limit"},"Compression-Reset":{"$ref":"#/components/headers/Compression-Reset"},"Cache-Control":{"$ref":"#/components/headers/Cache-Control"}},"content":{"image/png":{"schema":{"type":"string","format":"binary"}},"image/jpeg":{"schema":{"type":"string","format":"binary"}},"image/webp":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"The request or the image cannot be used. Do not retry. Codes: https_required, input_missing, invalid_multipart, invalid_image. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Compression-Count":{"$ref":"#/components/headers/Compression-Count"},"Compression-Limit":{"$ref":"#/components/headers/Compression-Limit"},"Compression-Reset":{"$ref":"#/components/headers/Compression-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"https_required":{"value":{"ok":false,"error":"https_required","message":"Use https://api.compresso.space/v1 — plain HTTP is not accepted.","docs":"https://compresso.space/developers#error-https_required","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}},"input_missing":{"value":{"ok":false,"error":"input_missing","message":"The request body is empty. Send the image bytes.","docs":"https://compresso.space/developers#error-input_missing","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}},"invalid_multipart":{"value":{"ok":false,"error":"invalid_multipart","message":"The multipart body is malformed or truncated.","docs":"https://compresso.space/developers#error-invalid_multipart","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}},"invalid_image":{"value":{"ok":false,"error":"invalid_image","message":"The image could not be decoded: the file is truncated or corrupted.","docs":"https://compresso.space/developers#error-invalid_image","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"401":{"description":"The API key is missing, malformed, unknown or revoked. Codes: unauthorized. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"WWW-Authenticate":{"$ref":"#/components/headers/WWW-Authenticate"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"unauthorized":{"value":{"ok":false,"error":"unauthorized","message":"No API key was sent. Authenticate with HTTP Basic auth.","docs":"https://compresso.space/developers#error-unauthorized","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"403":{"description":"Called from a browser page. Call the API from a server. Codes: browser_not_supported. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"browser_not_supported":{"value":{"ok":false,"error":"browser_not_supported","message":"The API cannot be called from a web page.","docs":"https://compresso.space/developers#error-browser_not_supported","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"405":{"description":"Wrong HTTP method. Codes: method_not_allowed. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Allow":{"$ref":"#/components/headers/Allow"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"method_not_allowed":{"value":{"ok":false,"error":"method_not_allowed","message":"This endpoint accepts POST only.","docs":"https://compresso.space/developers#error-method_not_allowed","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"413":{"description":"The file is over 16 MB or the image is over 16 MP. Never retried. Codes: file_too_large, image_too_large. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Compression-Count":{"$ref":"#/components/headers/Compression-Count"},"Compression-Limit":{"$ref":"#/components/headers/Compression-Limit"},"Compression-Reset":{"$ref":"#/components/headers/Compression-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"file_too_large":{"value":{"ok":false,"error":"file_too_large","message":"The file is larger than 16 MB, the API limit per image.","docs":"https://compresso.space/developers#error-file_too_large","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}},"image_too_large":{"value":{"ok":false,"error":"image_too_large","message":"The image is 5000×4000 (20.0 MP). The API accepts up to 16 MP.","docs":"https://compresso.space/developers#error-image_too_large","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"415":{"description":"Not a still PNG, JPEG or WebP. Codes: unsupported_format, animated_unsupported. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Compression-Count":{"$ref":"#/components/headers/Compression-Count"},"Compression-Limit":{"$ref":"#/components/headers/Compression-Limit"},"Compression-Reset":{"$ref":"#/components/headers/Compression-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"unsupported_format":{"value":{"ok":false,"error":"unsupported_format","message":"HEIC images are not supported by the API. Send PNG, JPEG or WebP.","docs":"https://compresso.space/developers#error-unsupported_format","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}},"animated_unsupported":{"value":{"ok":false,"error":"animated_unsupported","message":"Animated images are not supported.","docs":"https://compresso.space/developers#error-animated_unsupported","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"429":{"description":"daily_limit_exceeded: wait for Compression-Reset (no Retry-After). rate_limited: retry after Retry-After. Codes: daily_limit_exceeded, rate_limited. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Retry-After":{"$ref":"#/components/headers/Retry-After"},"Compression-Count":{"$ref":"#/components/headers/Compression-Count"},"Compression-Limit":{"$ref":"#/components/headers/Compression-Limit"},"Compression-Reset":{"$ref":"#/components/headers/Compression-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"daily_limit_exceeded":{"value":{"ok":false,"error":"daily_limit_exceeded","message":"This account has used all 100 compressions for today.","docs":"https://compresso.space/developers#error-daily_limit_exceeded","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}},"rate_limited":{"value":{"ok":false,"error":"rate_limited","message":"This account already has one compression running and one waiting.","docs":"https://compresso.space/developers#error-rate_limited","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"500":{"description":"Server error while compressing. May be retried once. Codes: compress_failed. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Compression-Count":{"$ref":"#/components/headers/Compression-Count"},"Compression-Limit":{"$ref":"#/components/headers/Compression-Limit"},"Compression-Reset":{"$ref":"#/components/headers/Compression-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"compress_failed":{"value":{"ok":false,"error":"compress_failed","message":"The image could not be compressed because of a server error.","docs":"https://compresso.space/developers#error-compress_failed","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"503":{"description":"Temporarily unable to compress. Retry after Retry-After. Codes: server_busy, daily_capacity_reached, api_disabled. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Retry-After":{"$ref":"#/components/headers/Retry-After"},"Compression-Count":{"$ref":"#/components/headers/Compression-Count"},"Compression-Limit":{"$ref":"#/components/headers/Compression-Limit"},"Compression-Reset":{"$ref":"#/components/headers/Compression-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"server_busy":{"value":{"ok":false,"error":"server_busy","message":"The server is busy right now. Retry after Retry-After seconds.","docs":"https://compresso.space/developers#error-server_busy","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}},"daily_capacity_reached":{"value":{"ok":false,"error":"daily_capacity_reached","message":"The API has used its capacity for today.","docs":"https://compresso.space/developers#error-daily_capacity_reached","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}},"api_disabled":{"value":{"ok":false,"error":"api_disabled","message":"The API is temporarily disabled. Retry later.","docs":"https://compresso.space/developers#error-api_disabled","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}}}}},"/usage":{"get":{"operationId":"getUsage","summary":"Today's usage for the account (also a quick key check)","responses":{"200":{"description":"Usage for the current UTC day.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Compression-Count":{"$ref":"#/components/headers/Compression-Count"},"Compression-Limit":{"$ref":"#/components/headers/Compression-Limit"},"Compression-Reset":{"$ref":"#/components/headers/Compression-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Usage"}}}},"400":{"description":"Plain HTTP. Codes: https_required. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"https_required":{"value":{"ok":false,"error":"https_required","message":"Use https://api.compresso.space/v1 — plain HTTP is not accepted.","docs":"https://compresso.space/developers#error-https_required","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"401":{"description":"The API key is missing, malformed, unknown or revoked. Codes: unauthorized. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"WWW-Authenticate":{"$ref":"#/components/headers/WWW-Authenticate"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"unauthorized":{"value":{"ok":false,"error":"unauthorized","message":"No API key was sent. Authenticate with HTTP Basic auth.","docs":"https://compresso.space/developers#error-unauthorized","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"403":{"description":"Called from a browser page. Codes: browser_not_supported. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"browser_not_supported":{"value":{"ok":false,"error":"browser_not_supported","message":"The API cannot be called from a web page.","docs":"https://compresso.space/developers#error-browser_not_supported","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"405":{"description":"Wrong HTTP method. Codes: method_not_allowed. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Allow":{"$ref":"#/components/headers/Allow"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"method_not_allowed":{"value":{"ok":false,"error":"method_not_allowed","message":"This endpoint accepts POST only.","docs":"https://compresso.space/developers#error-method_not_allowed","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"503":{"description":"The API is disabled. Codes: api_disabled. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"api_disabled":{"value":{"ok":false,"error":"api_disabled","message":"The API is temporarily disabled. Retry later.","docs":"https://compresso.space/developers#error-api_disabled","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}}}}},"/openapi.json":{"get":{"operationId":"getOpenApi","summary":"This document","security":[],"responses":{"200":{"description":"OpenAPI 3.1 document.","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"Plain HTTP. Codes: https_required. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"https_required":{"value":{"ok":false,"error":"https_required","message":"Use https://api.compresso.space/v1 — plain HTTP is not accepted.","docs":"https://compresso.space/developers#error-https_required","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}},"405":{"description":"Wrong HTTP method. Codes: method_not_allowed. See https://compresso.space/developers#errors.","headers":{"Request-Id":{"$ref":"#/components/headers/Request-Id"},"Allow":{"$ref":"#/components/headers/Allow"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"method_not_allowed":{"value":{"ok":false,"error":"method_not_allowed","message":"This endpoint accepts POST only.","docs":"https://compresso.space/developers#error-method_not_allowed","request_id":"3f2c9a8b7d6e5f4a3b2c1d0e9f8a7b6c"}}}}}}}}}},"components":{"securitySchemes":{"basicAuth":{"type":"http","scheme":"basic","description":"Any username (use api) and your API key as the password: curl --user api:YOUR_API_KEY. The key as the username with an empty password also works."},"bearerAuth":{"type":"http","scheme":"bearer","description":"Authorization: Bearer YOUR_API_KEY"}},"headers":{"Request-Id":{"description":"Identifier of this request; quote it when asking for support.","schema":{"type":"string"}},"Cache-Control":{"description":"Always no-store.","schema":{"type":"string"}},"Original-Size":{"description":"Size of the uploaded image in bytes.","schema":{"type":"integer"}},"Compressed-Size":{"description":"Size of the returned image in bytes (equal to Original-Size when compression could not help).","schema":{"type":"integer"}},"Compression-Count":{"description":"Compressions used by the account in the current UTC day, including this one when it succeeded. Sent on every response after the key was accepted.","schema":{"type":"integer"}},"Compression-Limit":{"description":"The account's daily limit (100 on the free plan).","schema":{"type":"integer"}},"Compression-Reset":{"description":"When the daily count starts over: the next 00:00 UTC, e.g. 2026-09-18T00:00:00Z.","schema":{"type":"string","format":"date-time"}},"Retry-After":{"description":"Seconds to wait before retrying. Without this header, do not retry.","schema":{"type":"integer"}},"WWW-Authenticate":{"description":"Always Basic realm=\"compresso API\".","schema":{"type":"string"}},"Allow":{"description":"Methods this endpoint accepts.","schema":{"type":"string"}}},"schemas":{"Error":{"type":"object","required":["ok","error","message","docs","request_id"],"properties":{"ok":{"type":"boolean","const":false},"error":{"type":"string","enum":["https_required","input_missing","invalid_multipart","invalid_image","unauthorized","browser_not_supported","not_found","method_not_allowed","file_too_large","image_too_large","unsupported_format","animated_unsupported","daily_limit_exceeded","rate_limited","server_busy","daily_capacity_reached","api_disabled","compress_failed"]},"message":{"type":"string","description":"What happened and what to do."},"docs":{"type":"string","format":"uri"},"request_id":{"type":"string"}}},"Usage":{"type":"object","required":["ok","plan","compression_count","compression_limit","compression_reset","key"],"properties":{"ok":{"type":"boolean","const":true},"plan":{"type":"string","examples":["free"]},"compression_count":{"type":"integer","description":"Compressions used today (UTC)."},"compression_limit":{"type":"integer","description":"Daily limit."},"compression_reset":{"type":"string","format":"date-time","description":"Next 00:00 UTC."},"key":{"type":"string","description":"The key used for this request, masked.","examples":["csk_…abcd"]}}}}}}