File compression REST API Documentation

You can compress a single file as well as multiple files into a single file archive. In this section we will describe each option to pass the files to our compressor.


Compress files accessible via URL using JSON

To compress the files using JSON, please set the "content-type" header to "application/json". An example request would look like this:

    [HTTP POST] https://api.archiveapi.com/zip?secret=your_secret
    Content-Type: application/json
    {
        "files": [
            "https://sample.com/path-to-file.pdf",
            "https://sample.com/path-to-file.pdf",
            "https://sample.com/path-to-file.pdf"
        ]
        "password": "123456",
        "compressionLevel": 9,
        "archiveName": "result.zip"
    }

Request Body

file string
The file URL to be compressed

files array[string]
The array of file URLs to be compressed

password string
The compressed ZIP archive password

compressionLevel integer
Archive compression level. Value range: 1...9

archiveName string
Compressed archive name


Compress files using FormData

You can pass your files structured as "multipart/form-data". Simply put your files into the FormData's Files property and POST it to our compression endpoint:

    [HTTP POST] https://api.archiveapi.com/zip?secret=your_secret
    Content-Type: multipart/form-data; boundary=----FpbVSjGhtld6EDEy

    ------7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="Password"

    123456

    ------7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="CompressionLevel"

    9

    ------7MA4YWxkTrZu0gW
    Content-Disposition: form-data; name="ArchiveName"

    sample.zip

    ----FpbVSjGhtld6EDEy
    Content-Disposition: form-data; name="File"; filename="sample.pdf"

    FILE

    ----FpbVSjGhtld6EDEy--

FormData Parameters

Files array[File]
The array of files compressed

Password string
The compressed ZIP archive password

CompressionLevel integer
Archive compression level. Value range: 1...9

ArchiveName string
Compressed archive name


Compress files using application/octet-stream

The application/octet-stream MIME type is used for binary files transfer. It preserves the file contents, but requires to specify the file name including the type. For this case, Content disposition header must be provided with the file name. Example: Content-Disposition: inline; filename="sample.png"

    [HTTP POST] https://api.archiveapi.com/zip?secret=your_secret
    Content-Type: application/octet-stream
    Content-Disposition: inline; filename="sample.png"
    
    ---File Bytes---

Hapy coding!