apyhub
FILE CONVERSION · FILE MANIPULATION

Compress Images API

Hosted on ApyHub

What it does

Image Compressor reduces the size of raster image files while letting you control the compression level and output handling. Send a public image URL or upload an image file, and choose a compression_percentage from 1 to 100. You can also set preserve_format and an output name for the generated file.

Use the URL endpoints when your source image already lives on the web, or the multipart endpoints when you want to upload a local file. Supported formats include JPEG, PNG, WebP, GIF, TIFF, and BMP. The service returns either the compressed file itself or a time-limited signed URL to the stored result, depending on the endpoint you call.

This is useful when you need to cut image transfer costs, reduce storage usage, or generate lighter assets for web and mobile delivery. For example, you can compress product photos before serving them through a frontend, or shrink uploaded images before saving them to object storage.

If you need the file immediately, use the download endpoints. If you need a link you can pass to another system, use the signed-URL endpoints.

▣ ENDPOINT 01 / 04
POST
Compress image (fetch by URL, download file)
http://localhost:8080/apyhub/compress-images/url/download
QUICKSTARTGUIDE

Quickstart

Compress an image from a public URL by sending the image URL in the JSON body and the compression settings as query parameters.

curl -X POST "http://localhost:8080/apyhub/compress-images/url/download?compression_percentage=75" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.jpg"}'

What you'll get back

Returns the compressed image as a binary file.

TRY ITLIVE · 30 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Request body for URL-mode compression endpoints. Send as `application/json`. The `url` field is required and must be a publicly accessible image URL. All compression options (`compression_percentage`, `preserve_format`, `output`) are passed as query parameters — not in this body.
Publicly accessible URL of the raster image to compress. Supported formats — JPEG, PNG, WebP, GIF, TIFF, BMP. Hosts without a recognised scheme (`http`, `https`, `ftp`, `sftp`) receive an `https://` prefix automatically.

About this endpoint

What it does

Compresses an image fetched from a public URL and returns the compressed file as binary data. You provide the source image URL in the request body and control compression with query parameters.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput file name.
preserve_formatBooleanNoDefaults to false.
compression_percentageIntegerYesCompression level as a percentage between 1 and 100.

Request Body

ParameterTypeMandatoryDescription
urlStringYesPublicly accessible URL of the raster image to compress. Supported formats: JPEG, PNG, WebP, GIF, TIFF, BMP. If the URL does not start with a recognised scheme (http, https, ftp, sftp), https:// is prefixed automatically.

Response

Returns binary file data for the compressed image.

ParameterTypeMandatoryDescription
binaryStringYesBinary content of the compressed image file.

Query parameters

Name
Type
Description
outputOPTIONAL
string
preserve_formatOPTIONAL
boolean
DEFAULT false
compression_percentageREQUIRED
integer

Body

Name
Type
Description
bodyREQUIRED
object
Request body for URL-mode compression endpoints. Send as `application/json`. The `url` field is required and must be a publicly accessible image URL. All compression options (`compression_percentage`, `preserve_format`, `output`) are passed as query parameters — not in this body.
▣ ENDPOINT 02 / 04
POST
Compress image (fetch by URL, return signed URL)
http://localhost:8080/apyhub/compress-images/url/link
QUICKSTARTGUIDE

Quickstart

Compress an image from a public URL and get back a temporary download link.

curl -X POST "http://localhost:8080/apyhub/compress-images/url/link?compression_percentage=75" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.jpg"}'

What you'll get back

Returns a JSON object with a data string field containing a time-limited pre-signed URL to the compressed image.

{
  "data": "https://storage.example.com/compress/my-compressed.png?X-Amz-Signature=def456&X-Amz-Expires=3600"
}
TRY ITLIVE · 30 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Request body for URL-mode compression endpoints. Send as `application/json`. The `url` field is required and must be a publicly accessible image URL. All compression options (`compression_percentage`, `preserve_format`, `output`) are passed as query parameters — not in this body.
Publicly accessible URL of the raster image to compress. Supported formats — JPEG, PNG, WebP, GIF, TIFF, BMP. Hosts without a recognised scheme (`http`, `https`, `ftp`, `sftp`) receive an `https://` prefix automatically.

About this endpoint

What it does

Compresses an image fetched from a publicly accessible URL and returns a time-limited signed URL for the compressed file.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput filename base.
preserve_formatBooleanNoDefault: false.
compression_percentageIntegerYesCompression level. Minimum: 1, maximum: 100.

Request Body

ParameterTypeMandatoryDescription
urlStringYesPublicly accessible URL of the raster image to compress. Supported formats: JPEG, PNG, WebP, GIF, TIFF, BMP. Must be a URI. Hosts without a recognised scheme (http, https, ftp, sftp) receive an https:// prefix automatically.

Response

Returns a JSON object with a data string field containing a time-limited pre-signed URL to the stored compressed image. The URL is always present on a 200 response and should be downloaded or forwarded before it expires.

AttributeTypeMandatoryDescription
dataStringYesTime-limited pre-signed URL to the stored compressed image. Always present on a 200 response. Download or forward the file before the URL expires.

Query parameters

Name
Type
Description
outputOPTIONAL
string
preserve_formatOPTIONAL
boolean
DEFAULT false
compression_percentageREQUIRED
integer

Body

Name
Type
Description
bodyREQUIRED
object
Request body for URL-mode compression endpoints. Send as `application/json`. The `url` field is required and must be a publicly accessible image URL. All compression options (`compression_percentage`, `preserve_format`, `output`) are passed as query parameters — not in this body.
▣ ENDPOINT 03 / 04
POST
Compress image (multipart upload, download file)
http://localhost:8080/apyhub/compress-images/multi-part/download
QUICKSTARTGUIDE

Quickstart

Upload one image and get back the compressed file.

curl -X POST "http://localhost:8080/apyhub/compress-images/multi-part/download?compression_percentage=75&output=my-compressed" \
  -H "apy-token: $APY_TOKEN" \
  -F "image=@/path/to/image.jpg"

What you'll get back

Returns a binary file (string with format: binary) containing the compressed image.

<compressed image bytes>
TRY ITLIVE · 30 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
Raster image file to compress. Supported formats — JPEG, PNG, WebP, GIF, TIFF, BMP.

About this endpoint

What it does

Compresses an uploaded raster image and returns the compressed file as a binary download. You send the image in a multipart request body, along with query parameters that control the output name, whether to preserve the original format, and the compression percentage.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput filename/base name for the compressed file.
preserve_formatBooleanNoDefault: false.<br>When true, preserves the original image format.
compression_percentageIntegerYesCompression percentage from 1 to 100.

Request Body

ParameterTypeMandatoryDescription
imageStringYesRaster image file to compress. Supported formats: JPEG, PNG, WebP, GIF, TIFF, BMP. Format: binary file upload.

Response

Returns a binary file download containing the compressed image. The response schema is a string with binary format, so the success response body is the file content itself rather than a JSON object.

Query parameters

Name
Type
Description
outputOPTIONAL
string
preserve_formatOPTIONAL
boolean
DEFAULT false
compression_percentageREQUIRED
integer

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ ENDPOINT 04 / 04
POST
Compress image (multipart upload, return signed URL)
http://localhost:8080/apyhub/compress-images/multi-part/link
QUICKSTARTGUIDE

Quickstart

Compress a raster image from a public link by uploading the image file and setting the compression percentage.

curl -X POST "http://localhost:8080/apyhub/compress-images/multi-part/link?compression_percentage=75" \
  -H "apy-token: $APY_TOKEN" \
  -F "image=@/path/to/image.jpg"

What you'll get back

Returns a JSON object with a data string field containing a time-limited pre-signed URL for the compressed image.

{
  "data": "https://storage.example.com/compress/my-compressed.jpg?X-Amz-Signature=abc123&X-Amz-Expires=3600"
}
TRY ITLIVE · 30 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
Raster image file to compress. Supported formats — JPEG, PNG, WebP, GIF, TIFF, BMP.

About this endpoint

What it does

Compresses a raster image uploaded as multipart form data and returns a time-limited signed URL for the compressed file. The compression level is controlled by compression_percentage, and you can optionally provide an output name and preserve the original image format.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput name for the compressed file.
preserve_formatBooleanNoDefault: false.<br>When true, preserves the original image format.
compression_percentageIntegerYesCompression level as an integer from 1 to 100.

Request Body

ParameterTypeMandatoryDescription
imageStringYesRaster image file to compress. Supported formats: JPEG, PNG, WebP, GIF, TIFF, BMP. Binary file upload.

Response

Returns a JSON object with a data string field containing a time-limited pre-signed URI to the compressed image. The URL is available on a 200 response and should be used before it expires.

ParameterTypeMandatoryDescription
dataStringYesTime-limited pre-signed URL to the stored compressed image. Always present on a 200 response. Download or forward the file before the URL expires.

Query parameters

Name
Type
Description
outputOPTIONAL
string
preserve_formatOPTIONAL
boolean
DEFAULT false
compression_percentageREQUIRED
integer

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.