apyhub
Back

Compress Audio to Target File Size API

What it does

Compress Audio is a simple file-processing endpoint that takes an audio file and returns a compressed binary MP3 file. Send a file up to 30 MB, optionally set a targetFileSize, and get back the processed audio as the response body.

Use targetFileSize when you need a specific output size, such as 2MB, 500KB, or a byte count. If you omit it, the service defaults to about half the original file size. That makes it useful when you need to reduce upload costs, fit content into storage limits, or prepare audio for faster delivery in an app or pipeline.

Because the response is binary, you can write it straight to disk, pass it to another media workflow, or store it wherever your application keeps generated files. The API does one job: reduce audio file size and return the result as a downloadable MP3 file.

POST
Compress audio
https://api.eu.apyhub.com/freedailypro/compress-audio-to-target-file-size-api/audio-compress

QUICKSTART

GUIDE

Quickstart

Compress an audio file by uploading it. targetFileSize is optional; leave it out for about half the original size.

curl -X POST "https://api.eu.apyhub.com/freedailypro/compress-audio-to-target-file-size-api/audio-compress" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/audio.mp3" \
  -F "targetFileSize=500KB"

What you'll get back

Returns binary data as the compressed MP3 file.

TRY ITLIVE · 10 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*
The audio file. Up to 30 MB.
Optional. The size you want the file to end up at, for example 2MB, 500KB or a number of bytes. Default: half the original size.

About this endpoint

What it does

Compresses an uploaded audio file to a smaller size and returns it as an MP3. The size is reached by choosing a bitrate between 32 and 320 kbps, so very small or very large targets are limited to that range. Different targets give different file sizes.

Request Body

ParameterTypeMandatoryDescription
fileFileYesThe audio file. Up to 30 MB.
targetFileSizeStringNoThe size you want the file to end up at, for example 2MB, 500KB or a number of bytes. Default: about half the original size. A target at or above the original size is treated as 99% of it.

Response

Returns the compressed audio as a binary MP3 file in the response body.

ParameterTypeDescription
binaryStringThe response body is binary data containing the compressed MP3 audio.

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.