Screenshot API for Ruby

Capture screenshots and PDFs from Ruby using net/http from the standard library. No gem required.

There is no official Ruby gem, and you do not need one. net/http from the standard library covers the whole API. If you already use Faraday or HTTParty, those work identically.

Install

# nothing to install - net/http ships with Ruby

Your first screenshot in Ruby

One POST, one JSON body, one URL back. The response is a CDN link to the finished image.

net/http

require "net/http"
require "json"

uri = URI("https://api.getsnap.dev/v1/screenshot")

response = Net::HTTP.post(
  uri,
  { url: "https://github.com", format: "png" }.to_json,
  "X-API-Key"    => "sk_live_YOUR_KEY",
  "Content-Type" => "application/json"
)

puts JSON.parse(response.body)["url"]   # CDN URL to your screenshot

Faraday

require "faraday"
require "json"

conn = Faraday.new(url: "https://api.getsnap.dev") do |f|
  f.request :json
  f.response :json
end

result = conn.post("/v1/screenshot") do |req|
  req.headers["X-API-Key"] = "sk_live_YOUR_KEY"
  req.body = { url: "https://github.com", format: "png" }
end

puts result.body["url"]

Full-page captures and other options

Every option is a field in the same JSON body. The common ones are full-page capture, popup and ad removal, viewport size, and lazy-load scrolling.

body = {
  url:             "https://example.com",
  format:          "png",
  full_page:       true,
  remove_popups:   true,
  block_ads:       true,
  lazy_load:       true,
  viewport_width:  1280,
  viewport_height: 720
}.to_json

response = Net::HTTP.post(uri, body,
  "X-API-Key" => "sk_live_YOUR_KEY", "Content-Type" => "application/json")

Saving the image to disk

By default you get a CDN URL. Ask for a binary response instead and you get the bytes directly, which saves a round-trip when you are storing the file yourself.

body = {
  url:           "https://example.com",
  format:        "webp",
  quality:       90,
  response_type: "binary"
}.to_json

response = Net::HTTP.post(uri, body,
  "X-API-Key" => "sk_live_YOUR_KEY", "Content-Type" => "application/json")

File.binwrite("screenshot.webp", response.body)

Handling errors

Every failure returns JSON with an error code and a human-readable message. These are the ones worth branching on:

StatuserrorWhat it means
400validation_errorA field is missing or out of range. The body names the field.
401unauthorizedMissing or unknown API key.
402quota_exceededMonthly capture limit reached.
429rate_limit_exceededToo many requests this minute. Back off and retry.
500capture_failedThe page could not be rendered - usually a timeout on a page that never settles.
response = Net::HTTP.post(uri, body,
  "X-API-Key" => "sk_live_YOUR_KEY", "Content-Type" => "application/json")

case response
when Net::HTTPSuccess
  puts JSON.parse(response.body)["url"]
else
  err = JSON.parse(response.body)
  # e.g. 429 rate_limit_exceeded
  warn "#{response.code} #{err["error"]}: #{err["message"]}"
end

Rate limits and quotas

PlanCaptures / monthRequests / minute
Free1005
Starter5,00030
Pro25,00060
Business100,000120

Exceeding the per-minute limit returns 429; exceeding the monthly quota returns 402. See pricing for the full breakdown.

Frequently asked questions

Is there an official Ruby SDK for taking screenshots?

No, and you do not need one. The API is a single JSON POST to one endpoint, so Ruby's standard HTTP client is enough. Everything on this page uses it.

Do I need to run or manage a headless browser?

No. getSnap.dev runs Chromium server-side and returns a finished image, PDF or video. You never install Playwright or Puppeteer, and you never maintain a browser pool.

Is there a free tier?

Yes - 100 captures a month at 5 requests a minute, with no credit card required. Paid plans start at $9/month for 5,000 captures at 30 requests a minute.

How do I capture a page that requires login from Ruby?

Pass your own cookies or HTTP headers in the request body and the capture runs authenticated. Use a dedicated least-privilege account rather than your own session.

Next steps

Related reading

Start capturing from Ruby

100 screenshots a month on the free tier. No credit card required.

Get Free API Key