Documentation
¶
Overview ¶
Package screenshotscout provides a small, synchronous Go client for the inline Screenshot Scout capture API.
Client.Capture waits for the final buffered response. A required context controls cancellation, and callers can use ordinary goroutines for concurrent I/O. Client.BuildCaptureURL constructs a sensitive capture URL without performing network I/O.
Index ¶
- Variables
- type APIError
- type BinaryCaptureResponse
- type CaptureColorScheme
- type CaptureFormat
- type CaptureHTTPMethod
- type CaptureImageAnchor
- type CaptureImageMode
- type CaptureMediaType
- type CaptureOptions
- type CapturePDFPaperFormat
- type CaptureResponse
- type CaptureResponseKind
- type CaptureResponseType
- type CaptureResult
- type CaptureStorageMode
- type CaptureWaitUntil
- type Client
- type ClientOptions
- type ConfigurationError
- type JSONCaptureResponse
- type RawResponse
- type ResponseDecodingError
- type SerializationError
- type TransportError
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConfiguration identifies invalid client configuration. ErrConfiguration = errors.New("screenshotscout: configuration error") // ErrSerialization identifies values that cannot be serialized safely. ErrSerialization = errors.New("screenshotscout: serialization error") // ErrTransport identifies failures before a complete HTTP response body is received. ErrTransport = errors.New("screenshotscout: transport error") // ErrAPI identifies non-2xx Screenshot Scout HTTP responses. ErrAPI = errors.New("screenshotscout: API error") // ErrResponseDecoding identifies invalid or representation-mismatched 2xx responses. ErrResponseDecoding = errors.New("screenshotscout: response decoding error") )
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
ErrorCode *string
ErrorMessage *string
Errors []any
ResponseBody any
RawResponse RawResponse
}
APIError reports a non-2xx Screenshot Scout response while retaining the parsed service fields, complete parsed body when available, and raw response.
type BinaryCaptureResponse ¶
type BinaryCaptureResponse struct {
Bytes []byte
ScreenshotURL *string
ScreenshotURLExpiresAt *string
CacheStatus *string
}
BinaryCaptureResponse contains a buffered binary capture result.
type CaptureColorScheme ¶
type CaptureColorScheme string
CaptureColorScheme is an open string type for emulated color schemes.
const ( CaptureColorSchemeAuto CaptureColorScheme = "auto" CaptureColorSchemeDark CaptureColorScheme = "dark" CaptureColorSchemeLight CaptureColorScheme = "light" )
type CaptureFormat ¶
type CaptureFormat string
CaptureFormat is an open string type for Screenshot Scout output formats.
const ( CaptureFormatGIF CaptureFormat = "gif" CaptureFormatJPEG CaptureFormat = "jpeg" CaptureFormatJPG CaptureFormat = "jpg" CaptureFormatPDF CaptureFormat = "pdf" CaptureFormatPNG CaptureFormat = "png" CaptureFormatTIFF CaptureFormat = "tiff" CaptureFormatWEBP CaptureFormat = "webp" )
type CaptureHTTPMethod ¶
type CaptureHTTPMethod string
CaptureHTTPMethod is the closed, SDK-owned HTTP method selector for Capture.
const ( CaptureHTTPMethodGET CaptureHTTPMethod = "GET" CaptureHTTPMethodPOST CaptureHTTPMethod = "POST" )
type CaptureImageAnchor ¶
type CaptureImageAnchor string
CaptureImageAnchor is an open string type for image resize anchors.
const ( CaptureImageAnchorBottom CaptureImageAnchor = "bottom" CaptureImageAnchorBottomLeft CaptureImageAnchor = "bottom_left" CaptureImageAnchorBottomRight CaptureImageAnchor = "bottom_right" CaptureImageAnchorCenter CaptureImageAnchor = "center" CaptureImageAnchorLeft CaptureImageAnchor = "left" CaptureImageAnchorRight CaptureImageAnchor = "right" CaptureImageAnchorTop CaptureImageAnchor = "top" CaptureImageAnchorTopLeft CaptureImageAnchor = "top_left" CaptureImageAnchorTopRight CaptureImageAnchor = "top_right" )
type CaptureImageMode ¶
type CaptureImageMode string
CaptureImageMode is an open string type for image resize modes.
const ( CaptureImageModeFill CaptureImageMode = "fill" CaptureImageModeFit CaptureImageMode = "fit" CaptureImageModeStretch CaptureImageMode = "stretch" )
type CaptureMediaType ¶
type CaptureMediaType string
CaptureMediaType is an open string type for emulated CSS media types.
const ( CaptureMediaTypePrint CaptureMediaType = "print" CaptureMediaTypeScreen CaptureMediaType = "screen" )
type CaptureOptions ¶
type CaptureOptions struct {
// Target and output.
Format *CaptureFormat
ResponseType *CaptureResponseType
// Network and location.
Country *string
Proxy *string
GeolocationLatitude *float64
GeolocationLongitude *float64
GeolocationAccuracy *float64
// Cookies and webpage request headers. Order and duplicates are preserved.
Cookies []string
Headers []string
// Navigation and service-side timing.
Timeout *int
WaitUntil *CaptureWaitUntil
Delay *int
// Viewport and device emulation.
Device *string
DeviceViewportWidth *int
DeviceViewportHeight *int
DeviceScaleFactor *float64
DeviceIsMobile *bool
DeviceHasTouch *bool
DeviceUserAgent *string
// Page behavior and preferences.
Timezone *string
MediaType *CaptureMediaType
ColorScheme *CaptureColorScheme
ReducedMotion *bool
// Full-page capture and pre-scroll behavior.
FullPage *bool
FullPagePreScroll *bool
FullPagePreScrollStep *int
FullPagePreScrollStepDelay *int
FullPageMaxHeight *int
// Blocking.
BlockCookieBanners *bool
BlockAds *bool
BlockChatWidgets *bool
// DOM interactions and injections. Order and duplicates are preserved.
HideSelectors []string
ClickSelectors []string
ClickAllSelectors []string
InjectCSS []string
InjectJS []string
BypassCSP *bool
// Framing and selection.
Selector *string
ClipX *int
ClipY *int
ClipWidth *int
ClipHeight *int
// Image resizing and quality.
ImageWidth *int
ImageHeight *int
ImageMode *CaptureImageMode
ImageAnchor *CaptureImageAnchor
ImageAllowUpscale *bool
ImageBackground *string
ImageQuality *int
// PDF.
PDFPaperFormat *CapturePDFPaperFormat
PDFLandscape *bool
PDFPrintBackground *bool
PDFMargin *string
PDFMarginTop *string
PDFMarginRight *string
PDFMarginBottom *string
PDFMarginLeft *string
PDFScale *float64
// Caching.
Cache *bool
CacheTTL *int
CacheKey *string
// Storage.
StorageMode *CaptureStorageMode
StorageEndpoint *string
StorageBucket *string
StorageRegion *string
StorageObjectKey *string
}
CaptureOptions contains Screenshot Scout service options. URL, access_key, signature, and the request HTTP method are deliberately separate.
Pointer fields preserve the distinction between omission and explicit zero, false, or an empty string. Empty repeated slices are omitted.
type CapturePDFPaperFormat ¶
type CapturePDFPaperFormat string
CapturePDFPaperFormat is an open string type for PDF paper formats.
const ( CapturePDFPaperFormatA3 CapturePDFPaperFormat = "a3" CapturePDFPaperFormatA4 CapturePDFPaperFormat = "a4" CapturePDFPaperFormatContent CapturePDFPaperFormat = "content" CapturePDFPaperFormatLegal CapturePDFPaperFormat = "legal" CapturePDFPaperFormatLetter CapturePDFPaperFormat = "letter" CapturePDFPaperFormatTabloid CapturePDFPaperFormat = "tabloid" )
type CaptureResponse ¶
type CaptureResponse struct {
Kind CaptureResponseKind
Binary *BinaryCaptureResponse
JSON *JSONCaptureResponse
RawResponse RawResponse
}
CaptureResponse is the discriminated Go response shape. Exactly one of Binary and JSON is non-nil on a successful return.
type CaptureResponseKind ¶
type CaptureResponseKind string
CaptureResponseKind identifies which CaptureResponse member is populated.
const ( CaptureResponseKindBinary CaptureResponseKind = "binary" CaptureResponseKindJSON CaptureResponseKind = "json" )
type CaptureResponseType ¶
type CaptureResponseType string
CaptureResponseType is an open string type for successful response representations.
const ( CaptureResponseTypeBinary CaptureResponseType = "binary" CaptureResponseTypeJSON CaptureResponseType = "json" )
type CaptureResult ¶
type CaptureResult struct {
ScreenshotURL *string
ScreenshotURLExpiresAt *string
CacheStatus *string
AdditionalFields map[string]any
}
CaptureResult contains documented JSON result metadata and any additional response fields returned by the service.
type CaptureStorageMode ¶
type CaptureStorageMode string
CaptureStorageMode is an open string type for screenshot storage modes.
const ( CaptureStorageModeExternal CaptureStorageMode = "external" CaptureStorageModeManaged CaptureStorageMode = "managed" )
type CaptureWaitUntil ¶
type CaptureWaitUntil string
CaptureWaitUntil is an open string type for navigation completion conditions.
const ( CaptureWaitUntilDOMContentLoaded CaptureWaitUntil = "domcontentloaded" CaptureWaitUntilLoad CaptureWaitUntil = "load" CaptureWaitUntilNetworkIdle0 CaptureWaitUntil = "networkidle0" CaptureWaitUntilNetworkIdle2 CaptureWaitUntil = "networkidle2" )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a reusable Screenshot Scout API client.
func NewClient ¶
func NewClient(accessKey string, options *ClientOptions) (*Client, error)
NewClient creates a reusable client. The access key is configured once and is sent in the Authorization header for Capture calls.
func (*Client) BuildCaptureURL ¶
func (client *Client) BuildCaptureURL(targetURL string, options *CaptureOptions) (string, error)
BuildCaptureURL constructs a sensitive GET capture URL without making an HTTP request. The access key is included in the query, and a configured secret key signs the URL automatically.
Example ¶
package main
import (
"fmt"
screenshotscout "github.com/screenshotscout/screenshotscout-go"
)
func main() {
client, err := screenshotscout.NewClient("ak_test", nil)
if err != nil {
panic(err)
}
fullPage := true
captureURL, err := client.BuildCaptureURL(
"https://example.com",
&screenshotscout.CaptureOptions{FullPage: &fullPage},
)
if err != nil {
panic(err)
}
fmt.Println(captureURL)
}
Output: https://api.screenshotscout.com/v1/capture?access_key=ak_test&url=https%3A%2F%2Fexample.com&full_page=true
func (*Client) Capture ¶
func (client *Client) Capture( ctx context.Context, targetURL string, options *CaptureOptions, method ...CaptureHTTPMethod, ) (*CaptureResponse, error)
Capture performs one inline Screenshot Scout request and waits for the final buffered response. POST is used when method is omitted. At most one method may be supplied, and it must be CaptureHTTPMethodGET or CaptureHTTPMethodPOST. Cancellation follows the supplied context's normal semantics.
type ClientOptions ¶
ClientOptions configures signing and HTTP transport for a reusable Client.
type ConfigurationError ¶
ConfigurationError reports invalid client configuration.
func (*ConfigurationError) Error ¶
func (e *ConfigurationError) Error() string
func (*ConfigurationError) Is ¶
func (e *ConfigurationError) Is(target error) bool
func (*ConfigurationError) Unwrap ¶
func (e *ConfigurationError) Unwrap() error
type JSONCaptureResponse ¶
type JSONCaptureResponse struct {
Result CaptureResult
}
JSONCaptureResponse contains a decoded JSON capture result.
type RawResponse ¶
type RawResponse struct {
StatusCode int
Status string
Headers http.Header
ContentType string
Body []byte
}
RawResponse contains the exact buffered HTTP response data retained on successes and API failures.
type ResponseDecodingError ¶
type ResponseDecodingError struct {
Message string
RawResponse RawResponse
Cause error
}
ResponseDecodingError reports an invalid or representation-mismatched 2xx response while retaining the raw response.
func (*ResponseDecodingError) Error ¶
func (e *ResponseDecodingError) Error() string
func (*ResponseDecodingError) Is ¶
func (e *ResponseDecodingError) Is(target error) bool
func (*ResponseDecodingError) Unwrap ¶
func (e *ResponseDecodingError) Unwrap() error
type SerializationError ¶
SerializationError reports a value that cannot be represented safely on the wire.
func (*SerializationError) Error ¶
func (e *SerializationError) Error() string
func (*SerializationError) Is ¶
func (e *SerializationError) Is(target error) bool
func (*SerializationError) Unwrap ¶
func (e *SerializationError) Unwrap() error
type TransportError ¶
TransportError reports a failure before a complete HTTP response body is available. Unwrap exposes the native transport cause.
func (*TransportError) Error ¶
func (e *TransportError) Error() string
func (*TransportError) Is ¶
func (e *TransportError) Is(target error) bool
func (*TransportError) Unwrap ¶
func (e *TransportError) Unwrap() error