Go Screenshot API
High-performance screenshot capture with Go using the standard net/http package. Build fast, concurrent screenshot services with goroutines and channels. Includes examples for parallel batch capture, context-based timeouts, streaming responses to disk, and deploying as a microservice.
Quick Start
Install dependencies
No external dependencies needed — Go's standard library net/http handles all HTTP requests.
Get your API key
Sign up for Screenshotly and get your API key from the dashboard.
Copy the code example
Use our Go code example as a starting point.
Customize and integrate
Modify the code to fit your specific use case and requirements.
Code Example
// Go
package main
import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
)
func captureScreenshot(url, outputPath string) error {
payload, _ := json.Marshal(map[string]interface{}{
"url": url,
"device": "desktop",
"format": "png",
})
req, _ := http.NewRequest("POST",
"https://api.screenshotly.app/screenshot",
bytes.NewBuffer(payload))
req.Header.Set("Authorization", "Bearer "+os.Getenv("SCREENSHOTLY_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
data, _ := io.ReadAll(resp.Body)
return os.WriteFile(outputPath, data, 0644)
}When to Use Go with Screenshotly
Use the Go integration for high-throughput microservices, CLI tools, and concurrent screenshot pipelines. Go excels at processing thousands of captures per minute with minimal memory overhead thanks to goroutines and efficient streaming I/O.
Go Best Practices
Use a semaphore pattern (buffered channel of size N) to limit concurrent goroutines to your plan's rate limit.
Always pass context.WithTimeout to http.NewRequestWithContext — this prevents goroutine leaks on slow or hung API responses.
Use io.Copy(file, resp.Body) to stream directly to disk instead of io.ReadAll, especially for full-page screenshots.
Build a reusable http.Client with custom Transport settings: MaxIdleConnsPerHost=10, IdleConnTimeout=90s for connection pooling.
Want a step-by-step walkthrough?
Read the full Go tutorial →API Reference
POST /api/screenshotBearer tokenapplication/jsonFrequently Asked Questions
How do I capture screenshots concurrently in Go?
Use goroutines with a semaphore pattern (buffered channel) to limit concurrent requests. This prevents hitting rate limits while maximizing throughput. A worker pool of 5-10 concurrent captures is a good starting point.
What's the best way to handle errors in Go?
Check resp.StatusCode after each request. Implement retry logic with exponential backoff for 429 and 5xx errors. Use context.WithTimeout to prevent hung requests. Return errors up the call chain rather than logging and continuing.
Can I use Screenshotly in a Go microservice?
Yes. Create a screenshot service with an HTTP handler that accepts URL parameters and returns captured images. Use Go's standard http package or frameworks like Gin/Echo. Store API keys in environment variables.
How do I stream screenshot responses in Go?
Use io.Copy to stream the API response body directly to your HTTP response writer or file, avoiding loading the entire image into memory. This is especially important for full-page screenshots that can be several megabytes.
Start building with Go
Get your API key and start capturing screenshots in minutes.
Other Languages
JavaScript
Capture website screenshots from the browser using client-side JavaScript. Call the Screenshotly API with the Fetch API from React, Vue, Angular, or vanilla JS — no server required for basic workflows. This guide covers browser JavaScript screenshot API usage, async/await patterns, error handling, blob URLs for display, and best practices for CORS and API key security when calling from the client.
Node.js
Server-side screenshot capture with Node.js — for backend services, Express/Fastify APIs, CLI tools, and automation scripts. This guide covers the Node.js screenshot API for server-side use only: streaming responses to disk or S3, Express screenshot middleware, cron jobs, and integrating with Bull/BullMQ for batch processing. Keep API keys on the server where they belong.
Python
Integrate screenshot capture into Python applications using the requests library or httpx. Ideal for data pipelines, Django/Flask web apps, automation scripts, and web scraping projects. Includes examples for synchronous and async requests, saving images to files, and handling rate limits with exponential backoff.
PHP
Add screenshot capabilities to PHP applications using cURL or Guzzle HTTP. Perfect for WordPress plugins, Laravel apps, and REST-based web services. Covers authentication, error handling, saving to local storage or S3, and integrating with Laravel queues for background processing.