Bytefusedocs

Getting started

Quickstart

Compress a PDF and download the result in four steps. The compression tool runs on the free-try path, so you can complete this guide with no account at all.

Prerequisites

  • Any HTTP client — curl, Python requests, or browser fetch.
  • A PDF file to compress.
  • Optional: a Bytefuse account for an API key (lifts rate limits and unlocks every tool).

1. Get a key (optional)

Light tools like compression accept anonymous requests, so you can skip this step to try things out. To go beyond the free-try rate limits — or to use login-only tools — create a key from your dashboard. Self-serve keys always start with dt_live_ and are sent in the X-API-Key header.

Keep keys server-side

An API key carries your credits. Never ship it in client-side JavaScript or commit it to a repo — proxy calls through your own backend.

2. Call the API

Compression accepts a JSON body: the PDF as a Base64 string in file_data, plus its filename (which must end in .pdf). Send a POST to /api/v1/compression/single.

# base64-encode the PDF, then post it as JSON
B64=$(base64 -i report.pdf)

curl -X POST https://api.bytefuse.in/api/v1/compression/single \
  -H "Content-Type: application/json" \
  -H "X-API-Key: dt_live_your_key_here" \
  -d "{\"file_data\": \"$B64\", \"filename\": \"report.pdf\"}"

You don’t choose the compression level

The strength is set by your plan tier — free keys get basic, Pro gets medium, Enterprise gets maximum. Anonymous calls default to medium. See the Compress PDF reference for the exact mapping.

3. Read the response

A 200 returns a JSON object describing the result. The fields you’ll use most are download_url and compression_ratio.

200 OK
{
  "compression_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "original_size": 10485760,
  "compressed_size": 4194304,
  "compression_ratio": 0.4,
  "quality_score": 0.95,
  "processing_time_ms": 2500,
  "download_url": "https://<r2-host>/compressed/....pdf",
  "expires_at": "2026-07-05T10:00:00+00:00",
  "tier_power_used": 0.8,
  "could_compress_more": true
}

The call is synchronous — the file is already compressed and stored by the time you get the response. The response header X-Credits-Charged tells you exactly how many credits this call cost (0 on the anonymous path).

4. Download the file

download_url is a public link that stays valid for 24 hours (see expires_at). Fetch it and save the bytes.

Python — save the result
# continue the Python example
import requests

out = requests.get(result["download_url"])
with open("report.compressed.pdf", "wb") as f:
    f.write(out.content)

print("saved", len(out.content), "bytes")

Where to next