Why this page does not install a Java package
Snapshot Site has no official Java SDK today. Publishing package coordinates, generated methods, or support claims would mislead developers and create a maintenance contract that does not exist. The reliable integration is the documented REST API.
Java 11 and later include java.net.http.HttpClient, so applications can call the API without a third-party transport. Most production Java services already use a JSON mapper through their framework. Combine those existing pieces in a small adapter and keep its behavior visible.
Design the adapter around operations
Use one reusable HttpClient
Build the client once with the connection policy required by the service. Reuse it across calls so connections and resources are shared. Inject it into an application service rather than constructing it inside a controller method.
Set a connection timeout on the client and a request timeout appropriate to browser work. Timeouts should be bounded but not copied blindly from a normal low-latency internal API.
Define typed request and response models
Create a screenshot request record with fields such as URL, format, width, height, full-page behavior, timing, and cleanup only when the workflow needs them. Define separate models for analyze and compare because their payloads and outputs are different.
Use the JSON naming configuration already adopted by the project. Confirm that fields such as fullSize and hideCookie serialize with the exact documented names rather than a framework-specific naming convention.
Model response fields the application consumes and preserve error, message, and retry information needed for operations. Ignoring unknown fields can help compatibility, but missing required fields such as a successful asset link should still fail the job.
Keep controller and worker concerns separate
Browser rendering can take longer than ordinary service calls. For interactive product requests, decide whether the user waits for the result or receives a job identifier. For batches and schedules, execute work in a queue or dedicated job runner rather than tying up application request threads.
Propagate cancellation when a job is abandoned. With asynchronous flows, make sure exceptions are observed and the application does not leave failed futures without monitoring.
Response and error handling
Check the transport response, then parse the JSON body and inspect the API-level outcome. A valid HTTP exchange can still describe an invalid target or rendering failure. Convert those results into a domain-specific exception or job status with enough context to act.
Do not copy full response bodies, secret headers, or URLs with private query parameters into unrestricted logs. Log the target identifier, operation, sanitized host, attempt, error code where available, and correlation or job identifier.
Retry only outcomes the application classifies as transient. Use bounded exponential backoff with jitter and stop when the request is invalid. Scheduled batches should continue or stop according to an explicit policy, not because an exception happened to escape a loop.
Download generated assets
The screenshot response returns a link. If the asset is part of a durable report, QA record, or documentation set, download it into storage owned by the application. Validate response status and content type, then stream into a file or object-store upload rather than accumulating large images in heap memory unnecessarily.
Store the capture options and source metadata with the object. This supports reproduction and prevents a future reviewer from guessing which viewport or delay created the file.
Java integration patterns
Spring Boot service
Register the Snapshot Site adapter as a service and inject the API key through the framework's externalized secret configuration. Keep endpoint payload construction inside the adapter and call it from jobs or application use cases.
Do not expose a generic “capture any URL with any script” controller unless the product has a reviewed target and authorization policy. A narrow service method is safer and easier to operate.
Scheduled report job
Use the application's existing scheduler to create report URLs, request PDF or image outputs, validate responses, and store results under a deterministic report key. See the Screenshot Scheduler page for overlap and retention patterns.
Visual release checks
Call the compare endpoint with staging and production or a stored baseline. Persist the diff and summary with the release identifier. A mismatch is a review signal; do not automatically fail every release until the team has tuned stable inputs and ownership.
Security and performance
Read the API key from a secret manager or environment injected at runtime. Never commit it, embed it in a frontend bundle, or place it in a target URL. Restrict which application components can call the adapter.
Validate user-controlled target URLs according to the product's destination policy. Bound batch concurrency with an executor sized for the plan and service resources. Cache unchanged outputs and avoid generating a fresh image for every request when a stored asset is valid.
Java integration checklist
- Reuse a configured
HttpClient.
- Use the project's existing JSON mapper.
- Create separate types for screenshot, analyze, and compare.
- Set connection and request timeouts deliberately.
- Check transport and API-level errors.
- Stream durable assets into owned storage.
- Bound concurrency and retry only transient failures.
- Keep secrets and sensitive target data out of logs.