Functional JVM

Capture screenshots in Scala

Add screenshot and scrolling GIF capabilities to your Scala applications with sttp or http4s. Functional, type-safe, no headless browsers to manage.

Installation

  1. 1Add sttp: libraryDependencies += "com.softwaremill.sttp.client3" %% "core" % "3.9.0"
  2. 2Get your API key from the dashboard
  3. 3Set the X-KEY header in your requests

Authentication

Include your API key in the X-KEY header with every request:

import sttp.client3._

val request = basicRequest
  .get(uri"$url")
  .header("X-KEY", "your-api-key")

Scala Screenshot Example

Capture a screenshot or create a scrolling GIF animation with a simple GET request:

Screenshot
import sttp.client3._
import java.nio.file.{Files, Paths}

val backend = HttpURLConnectionBackend()
val response = basicRequest
  .get(uri"https://api.scrnpix.com/screenshot?url=https%3A%2F%2Fexample.com&width=1280&height=720&format=png")
  .header("X-KEY", "your-api-key")
  .response(asByteArray)
  .send(backend)

Files.write(Paths.get("screenshot.png"), response.body.getOrElse(Array.empty))
Animation
import sttp.client3._
import java.nio.file.{Files, Paths}

val backend = HttpURLConnectionBackend()
val response = basicRequest
  .get(uri"https://api.scrnpix.com/animate?url=https%3A%2F%2Fexample.com&scroll_duration=3000&scroll_easing=ease-in-out")
  .header("X-KEY", "your-api-key")
  .response(asByteArray)
  .send(backend)

Files.write(Paths.get("animation.gif"), response.body.getOrElse(Array.empty))

Response Format

On success, the API returns the image binary data directly in the response body.

Status Code200 OK
Content-Typeimage/png, image/jpeg, or image/gif
BodyBinary image data (Array[Byte])
Error ResponseError message with 4xx/5xx status

Key Features

Zero Setup

No need to install Selenium or manage headless Chrome. Just add sttp or http4s to your build.

Production Ready

Built on Cloudflare Workers with global edge network. Handles concurrency and browser lifecycle automatically.

Scala Integration

Functional, composable API. Integrates seamlessly with Play, Akka HTTP, ZIO, Cats Effect, or any Scala framework.

Rich Features

Custom viewport sizes, full page capture, PNG/JPEG formats, scrolling GIFs with 15 easing functions.

Frequently Asked Questions

Do I need to install any browser dependencies for Scala?

No. Scrnpix runs browsers on our infrastructure. You only need sttp or http4s to make HTTP calls.

Can I use this with Play Framework or ZIO?

Yes. Scrnpix works with any Scala framework — Play, Akka HTTP, ZIO HTTP, http4s, or plain Scala applications.

How do I handle errors in Scala?

Check the response status code. A 200 status means success with image bytes in the body. Use Either, Try, or effect types for error handling.

What Scala version is required?

Scala 2.13+ or Scala 3 with sttp or http4s support. The API is a simple HTTP GET request.

Ready to capture screenshots in Scala?

Get your API key and start rendering screenshots in seconds. Free tier includes 50 screenshots per month.

Start Free