Quick start
This page walks through your first render, from key to PDF bytes. It uses the welcome template of the getting-started project, which every organization gets published into its sandbox environment when the organization is created, so it needs no project setup.
Set your API key
Section titled “Set your API key”Create a sandbox key in the dashboard and export it into the environment your program runs in:
export POLI_PAGE_API_KEY=pp_sandbox_x # replace with your keyRender a PDF
Section titled “Render a PDF”package main
import ( "context" "os"
"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 { panic(err) } _ = pdf // []byte — write to disk, return from a handler, upload to object storage.}pdf is a []byte. Write it to disk, stream it to S3, or return it directly from an HTTP handler. There is no version to pass: the render uses the project’s copy published in the key’s environment.
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. For your own templates, publish the project to the key’s environment and swap the slugs. To try a template or raw HTML without an API key, use the playground at play.poli.page.
Example
Section titled “Example”package main
import ( "context" "os"
"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")), )
if err := polipage.RenderToFile( context.Background(), client, polipage.RenderInput{ Project: "getting-started", Template: "welcome", Data: map[string]any{"name": "SDK Demo"}, }, "./out/welcome.pdf", ); err != nil { panic(err) }}