Data Science

Capture screenshots in R

Add screenshot and scrolling GIF capabilities to your R workflows with httr2. Perfect for R Markdown reports, Shiny apps, and data visualization.

Installation

  1. 1Install httr2: install.packages("httr2")
  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:

library(httr2)

response <- request(url) |>
  req_headers("X-KEY" = "your-api-key") |>
  req_perform()

R Screenshot Example

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

Screenshot
library(httr)

response <- GET(
  "https://api.scrnpix.com/screenshot?url=https%3A%2F%2Fexample.com&width=1280&height=720&format=png",
  add_headers("X-KEY" = "your-api-key")
)

writeBin(content(response, "raw"), "screenshot.png")
Animation
library(httr)

response <- GET(
  "https://api.scrnpix.com/animate?url=https%3A%2F%2Fexample.com&scroll_duration=3000&scroll_easing=ease-in-out",
  add_headers("X-KEY" = "your-api-key")
)

writeBin(content(response, "raw"), "animation.gif")

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 (raw vector)
Error ResponseError message with 4xx/5xx status

Key Features

Zero Setup

No need to install webshot2 or PhantomJS. Just use the httr2 package for simple HTTP calls.

Production Ready

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

R Integration

Pipe-friendly API with httr2. Integrates seamlessly with R Markdown, Shiny, plumber, or any R workflow.

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 R?

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

Can I use this with R Markdown or Shiny?

Yes. Scrnpix works with any R environment — R Markdown, Shiny, plumber APIs, or plain R scripts.

How do I handle errors in R?

Check the response status code with resp_status(). A 200 status means success with image bytes in the body. Use tryCatch for error handling.

What R version is required?

R 4.0+ with httr2 package support. The API is a simple HTTP GET request.

Ready to capture screenshots in R?

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

Start Free