Guides / Go
Maintaining your own headless-browser fleet for screenshots means babysitting Chromium versions, memory leaks, fonts, and proxy rules. RasterKit turns all of that into a single HTTPS call: send a URL from your Go code, get back finished image bytes.
The engine runs real Chromium, so modern CSS, web fonts and JavaScript-rendered pages come out exactly as users see them. Flags like full_page, device=mobile, dark_mode and block_cookie_banners handle the cases that make DIY screenshotting painful.
Sign up free (magic link, no card) — your key is shown right after sign-in. You get 100 renders/month free across screenshots, PDFs, and images.
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
"time"
)
func main() {
body := []byte(`{"url": "https://example.com", "full_page": true, "format": "png"}`)
req, _ := http.NewRequest("POST", "https://rasterkit.com/v1/screenshot", bytes.NewReader(body))
req.Header.Set("x-api-key", os.Getenv("RASTERKIT_API_KEY"))
req.Header.Set("content-type", "application/json")
client := &http.Client{Timeout: 60 * time.Second}
res, err := client.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode != 200 {
panic(fmt.Sprintf("render failed: %d %s", res.StatusCode, data))
}
os.WriteFile("screenshot.png", data, 0644)
fmt.Println("Saved screenshot.png")
} The response body is the file itself — no JSON envelope to unwrap, no second download request. Errors come back as JSON with a stable error code.
The Screenshot API reference documents every parameter. The ones people reach for first:
full_page: true — capture the whole scroll height (lazy content auto-scrolled in)device: "mobile" — real iPhone-class viewport and user agentdark_mode: true — render with prefers-color-scheme: darkcache_ttl: 86400 — repeat captures become instant and freePass "full_page": true. RasterKit auto-scrolls the page first so lazy-loaded images and infinite-scroll content are included.
Yes — every render runs in real Chromium with JS enabled. Use wait_until: "networkidle", wait_for_selector, or delay_ms for late-rendering apps.
Typical p50 is 1.5–3 s for a normal page (sync request). Add cache_ttl and repeated captures of the same URL return instantly and free.