DBDelve
Dive deep into your data. A fast, native, multi-engine database client written in Rust. Free and open source, no telemetry.
翻訳待ち
Official Go SDK for Poli Page
翻訳待ち
Loading the full README.
Read the full README ↗Official Go SDK for Poli Page — render polished PDFs from HTML templates via the Poli Page API.
→ Documentation: https://poli-page.github.io/sdk-go/
→ API reference (auto-generated from doc comments): pkg.go.dev/github.com/poli-page/sdk-go
go get github.com/poli-page/sdk-go
Requires Go 1.25 or later. Zero runtime dependencies.
package main
import (
"context"
"log"
"os"
polipage "github.com/poli-page/sdk-go"
"github.com/poli-page/sdk-go/option"
)
func main() {
client := polipage.NewClient(option.WithAPIKey(os.Getenv("POLI_PAGE_API_KEY")))
pdf, err := client.Render.PDF(context.Background(), polipage.RenderInput{
Project: "getting-started",
Template: "welcome",
Data: map[string]any{"name": "SDK Demo"},
})
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("welcome.pdf", pdf, 0o644); err != nil {
log.Fatal(err)
}
}
Run it with a sandbox key: POLI_PAGE_API_KEY=pp_sandbox_x go run . (replace pp_sandbox_x with your key). Every organization gets a getting-started project with a welcome template, published into its sandbox environment when the organization is created, so the snippet runs as-is on a fresh organization. getting-started is a normal, editable project: if your organization renamed it, deleted it or removed it from sandbox, the API answers 404 PROJECT_NOT_FOUND or 404 PROJECT_NOT_IN_ENVIRONMENT. Use a fresh organization in that case.
A render uses the project's copy published in the API key's environment. For your own templates, publish the project to that environment, then swap the slugs:
pdf, err := client.Render.PDF(ctx, polipage.RenderInput{
Project: "billing",
Template: "invoice",
Data: map[string]any{"invoiceNumber": "INV-001", "total": 1280},
})
To try a template or raw HTML without an API key, use the playground at play.poli.page.
err := polipage.RenderToFile(ctx, client, polipage.RenderInput{
Project: "getting-started",
Template: "welcome",
Data: map[string]any{"name": "SDK Demo"},
}, "./welcome.pdf")
RenderToFile streams response bytes directly to disk (bounded memory). Parent directories are created on demand; an existing file is replaced. The PDF goes to a temporary file in the same directory, renamed over the target only once it is complete, so a failed render, download or write leaves the target untouched. When the path is a symbolic link, the file it points to is written and the link stays a link. An existing target keeps its permission bits (without setuid, setgid or sticky), but not its owner or group, and other hard links to it keep the old content (the PDF is a new file renamed into place). A read-only target, or one that is not a regular file (a directory, FIFO, socket or device such as /dev/stdout), is refused before any API call; to write to a pipe or stdout, copy Render.PDFStream into it. A file that cannot be written returns Code == ErrCodeIOError (io_error), with the message Failed to write PDF: <path>: <reason> (for example Failed to write PDF: /out/invoice.pdf: permission denied) and the os error as Cause; it is never retryable.
The repo ships a runnable demo that exercises every public method end-to-end against the API:
go run ./cmd/demo
# or remote-only, no checkout:
go run github.com/poli-page/sdk-go/cmd/demo@latest
The demo reads POLI_PAGE_API_KEY and the optional POLI_PAGE_BASE_URL from the shell or ./.env. With no key, it asks for a sandbox key (pp_sandbox_…), checks its format and saves it to .env, so later runs are silent. It renders getting-started/welcome and writes its output to ./output/, in nine steps:
This is the beginning of the README. Read the rest at the original. Read the full README ↗