Ruby SDK
Official SDK for the ScreenshotCenter API. Capture screenshots, PDFs, HTML, and video — without writing raw HTTP calls.
Installation
terminal
gem install screenshotcenter
Package coming soon to RubyGems — rubygems.org/gems/screenshotcenter
Quick start
main.rb
require "screenshotcenter"
client = ScreenshotCenter::Client.new(ENV["SCREENSHOTCENTER_API_KEY"])
shot = client.screenshot.create("https://example.com")
result = client.wait_for(shot["id"])
puts result["url"] # final URL
puts result["status"] # "finished" More examples
Geo-targeting
shot = client.screenshot.create("https://example.com",
country: "fr", lang: "fr-FR", tz: "Europe/Paris")
done = client.wait_for(shot["id"])
client.screenshot.save_image(done["id"], "/tmp/fr.png") PDF generation
shot = client.screenshot.create("https://example.com", pdf: true)
done = client.wait_for(shot["id"])
client.screenshot.save_pdf(done["id"], "/tmp/page.pdf") Error handling
begin
result = client.wait_for(shot["id"], interval: 2, timeout: 60)
rescue ScreenshotCenter::ScreenshotFailedError => e
puts "Failed: #{e.reason}"
rescue ScreenshotCenter::TimeoutError => e
puts "Timed out after #{e.timeout_ms}ms"
rescue ScreenshotCenter::ApiError => e
puts "API error #{e.status}: #{e.message}"
end