Install
The Gin integration is the Go module github.com/poli-page/gin. It wraps the Go SDK, github.com/poli-page/sdk-go, so you install both and add polipagegin.Middleware to your router once.
Requirements
Section titled “Requirements”- Go
1.25+, the same floor as the SDK. github.com/poli-page/sdk-gov0.13.x. The module requiresv0.13.0and shares its major.minor with the Poli Page API and the SDK. Ago.modrequirement is a minimum and cannot cap a version, so keep the SDK on0.13.xwhile you use0.13.xof this module.- Gin
v1.12. The module requiresv1.12.0, and CI runs the suite and the example app against Ginv1.9.1,v1.10.0,v1.11.0andv1.12.0. The older three are a canary, not supported builds: the requirement wins in your module. A nightly job also runs Go tip against Ginv1.12.0andmaster. - A Poli Page API key, from app.poli.page.
Install the packages
Section titled “Install the packages”go get github.com/poli-page/gin@v0.13.1 github.com/poli-page/sdk-go@v0.13.0Set your API key
Section titled “Set your API key”Put the key in the environment your app reads:
POLI_PAGE_API_KEY=pp_sandbox_xxxA key is pp_{environment}_{32 lowercase hex}. It belongs to one environment of your organization, and that environment’s published copy of the project is the one rendered, so a render never names a version:
| Environment | Key | Watermark | Counted |
| --- | --- | --- | --- |
| sandbox (every org) | pp_sandbox_… | yes | no |
| live (every org, deletable on Pro+) | pp_live_… | no | yes |
| created on Pro+ (e.g. staging) | pp_staging_… | no | yes |
“Counted” means the render counts toward the organization’s monthly PDF quota.
Verify the key
Section titled “Verify the key”The module ships a smoke-test binary, polipage-render. It renders the welcome template of the getting-started project, which every organization has in sandbox:
go run github.com/poli-page/gin/cmd/polipage-render \ --project=getting-started \ --template=welcome \ --data='{"name":"World"}' \ -o welcome.pdfAdd the middleware
Section titled “Add the middleware”Install polipagegin.Middleware(client) once on your router. It attaches the SDK client to every request and answers a queued *polipage.Error as JSON. The middleware page covers its lifecycle.
Example
Section titled “Example”package main
import ( "log" "os"
"github.com/gin-gonic/gin" polipagegin "github.com/poli-page/gin" 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")), )
r := gin.Default() // includes gin.Recovery() r.Use(polipagegin.Middleware(client))
log.Fatal(r.Run(":8080"))}