Build

SDKs & CLI

Install the TypeScript, Python, Go or Rust SDK or the wellfriend CLI, and compress a PDF in three lines.

Install

ClientPackageInstallGuide
TypeScriptwellfriend-document-sdknpm install wellfriend-document-sdk@latest/docs/sdk-cli/typescript
Pythonwellfriend-document-sdkpip install -U wellfriend-document-sdk/docs/sdk-cli/python
Gowellfriend.dev/go/wellfriendgo get wellfriend.dev/go/wellfriend@latest/docs/sdk-cli/go
Rustwellfriend-document-sdkcargo add wellfriend-document-sdk/docs/sdk-cli/rust
CLIwellfriend (in wellfriend-document-sdk)npm install -g wellfriend-document-sdk@latest/docs/sdk-cli/cli

Quickstart

Create a key in the dashboard (/dashboard/developer-api/keys) and set it as WELLFRIEND_API_KEY on your server. Each client compresses a PDF to a file in three lines.

TypeScript: compress a PDF to a file
import { Wellfriend } from "wellfriend-document-sdk";
const wf = new Wellfriend(); // reads WELLFRIEND_API_KEY
await wf.tools.compressPdf("input.pdf").then((result) => result.save("output.pdf"));
Python: compress a PDF to a file
from wellfriend import Wellfriend
wf = Wellfriend()  # reads WELLFRIEND_API_KEY
wf.tools.compress_pdf("input.pdf").save("output.pdf")
Go: compress a PDF to a file
wf := wellfriend.New() // reads WELLFRIEND_API_KEY
res, err := wf.Tools.CompressPDF(ctx, wellfriend.File("input.pdf"), nil)
if err == nil { err = res.Save(ctx, "output.pdf") }
Rust: compress a PDF to a file
let wf = Wellfriend::new(); // reads WELLFRIEND_API_KEY
let result = wf.tools().compress_pdf("input.pdf", None).await?;
result.save("output.pdf").await?;
CLI: compress a PDF to a file
npm install -g wellfriend-document-sdk@latest
wellfriend login   # or set WELLFRIEND_API_KEY
wellfriend compress-pdf input.pdf -o output.pdf

Tools

Every tool is one method: wf.tools.compressPdf in TypeScript, wf.tools.compress_pdf in Python, wf.Tools.CompressPDF in Go, wf.tools().compress_pdf in Rust, and wellfriend compress-pdf in the CLI. It uploads the file, runs the tool, waits and returns a result you save, read or stream.

Pipelines

wf.pipeline(steps).run(input) runs up to ten tools on one file in one run, and wellfriend pipeline does the same from a terminal. workflows.define keeps a named pipeline to run again.

Errors

All four SDKs raise the same error types, and every message carries a reference to quote to Support.

The error types
WellfriendError
├─ APIError (status, code, message, referenceId, details)
│  ├─ BadRequestError (400) / ValidationError (422)
│  ├─ AuthenticationError (401) / PermissionDeniedError (403)
│  ├─ NotFoundError (404) / ConflictError (409)
│  ├─ RateLimitError (429, retryAfter)
│  └─ ServerError (5xx)
├─ ConnectionError
├─ TimeoutError
├─ OperationFailedError (code, message, operation)
└─ WaitTimeoutError (operation id, to resume)

Webhooks

webhooks.verify (or verifyWebhook on its own) checks a delivery's signature over the raw body and returns the typed event. See /docs/webhooks/signatures.

Packages and source

Every SDK is open source in the public repository, where each package's changelog is. What the registries serve now: TypeScript 1.0.0 on npm; Python 1.0.0 on PyPI; Go v1.0.1 on pkg.go.dev; Rust 1.0.0 on crates.io.

Server-side rules

  • Load the key from an environment variable or a secret manager; never put it in a web page or a mobile app.
  • Check that your user may send a file before you forward it.
  • Store the document, version and operation IDs your code needs later.
  • Keep the SDK's automatic retries; add your own only for errors it does not retry.