Documentation

ZipStream is a high-performance service for creating zip files on-the-fly from multiple URLs. Instead of downloading files to a server first, ZipStream streams files directly from their sources to your download, minimizing memory usage and latency.

How It Works

  1. You send a JSON descriptor listing the files you want to include
  2. ZipStream fetches each file from its source URL
  3. Files are streamed directly into a zip archive
  4. The zip is streamed to your client as it's being created

This approach means:

  • Low memory usage - Files are never fully stored on the server
  • Fast response - Download starts immediately, no waiting for processing
  • High concurrency - Handle many simultaneous requests efficiently

Quick Start

Create your first zip file with a simple POST request:

curl -X POST https://zipstream.app/api/downloads \
  -H "Content-Type: application/json" \
  -d '{
    "suggestedFilename": "my-files.zip",
    "files": [
      {"url": "https://example.com/file1.jpg", "zipPath": "images/file1.jpg"},
      {"url": "https://example.com/file2.pdf", "zipPath": "docs/file2.pdf"}
    ]
  }' \
  --output my-files.zip

JSON Descriptor Format

The JSON descriptor specifies the zip file contents:

{
  "suggestedFilename": "archive.zip",
  "files": [
    {
      "url": "https://example.com/image.jpg",
      "zipPath": "images/photo.jpg"
    }
  ]
}

Fields

Field Type Required Description
suggestedFilename string No Filename suggested to the browser. Default: "archive.zip"
files array Yes Array of file entries to include
files[].url string Yes URL to fetch the file from (http or https)
files[].zipPath string Yes Path within the zip archive (relative, no leading /)

POST /api/downloads

Create and download a zip file immediately.

Request

POST /api/downloads
Content-Type: application/json

{
  "suggestedFilename": "my-archive.zip",
  "files": [
    {"url": "https://example.com/file.jpg", "zipPath": "file.jpg"}
  ]
}

Response

Returns the zip file as a binary stream:

  • Content-Type: application/zip
  • Content-Disposition: attachment; filename="my-archive.zip"

Error Responses

Status Description
400 Invalid JSON descriptor
429 Rate limit exceeded
500 Internal server error

GET /api/downloads

Create a zip file from a hosted JSON descriptor.

Query Parameters

Parameter Description
descriptorUrl Full URL to the JSON descriptor file
descriptorId ID appended to ZS_LISTFILE_URL_PREFIX

Example

curl "https://zipstream.app/api/downloads?descriptorUrl=https://example.com/descriptor.json" \
  --output archive.zip

Rate Limits

The free tier includes the following limits per IP address:

  • 10 requests per hour
  • 5 requests per 10 minutes (burst protection)
  • 50 files per request maximum
  • 5GB total size per request maximum

Rate Limit Headers

Every API response includes rate limit information:

Header Description
X-RateLimit-Limit Maximum requests per hour
X-RateLimit-Remaining Requests remaining in current window
X-RateLimit-Reset Unix timestamp when limit resets

Handling Rate Limits (429 Too Many Requests)

When you exceed the rate limit, you'll receive a 429 Too Many Requests response:

{
  "error": "Rate limit exceeded",
  "message": "Too many requests. Please wait before trying again.",
  "retry_after": 3600
}

Best Practices for Handling Rate Limits

  1. Check headers - Monitor X-RateLimit-Remaining to avoid hitting limits
  2. Implement backoff - Wait until X-RateLimit-Reset timestamp before retrying
  3. Queue requests - Space out requests to stay under burst limits
  4. Cache responses - Reuse download links where possible (valid for 60 seconds)

Need Higher Limits?

Premium tiers with higher rate limits are coming soon. Contact us if you need increased limits for your use case.

Code Examples

Examples in multiple languages for downloading files with ZipStream:

# Download directly
curl -X POST https://zipstream.app/api/downloads \
  -H "Content-Type: application/json" \
  -d '{"files": [{"url": "https://example.com/file.jpg", "zipPath": "file.jpg"}]}' \
  --output archive.zip

# Create download link
curl -X POST https://zipstream.app/api/download-links \
  -H "Content-Type: application/json" \
  -d '{"files": [{"url": "https://example.com/file.jpg", "zipPath": "file.jpg"}]}'

# Check rate limit status
curl https://zipstream.app/api/rate-limits

Frequently Asked Questions

What file types are supported?

ZipStream supports any file type that can be accessed via HTTP/HTTPS URLs. The files are included in the zip exactly as they are served from their source.

Is there a size limit?

Free tier: Maximum 50 files per request and 5GB total size. Individual file sizes are limited by source server capabilities.

How long do download links last?

Download links created via /api/download-links expire after 60 seconds.

Can I use this commercially?

Yes! ZipStream is available for commercial use. For high-volume usage, please contact us about premium tiers.

How do I increase my rate limit?

Premium tiers with higher limits are coming soon. Contact us if you need higher limits immediately.