Website screenshots & PDFs in Ruby

Leave Grover, wicked_pdf and a bundled Chromium out of your Rails deploy. Net::HTTP is all you need.

1. Get an API key

Click Get free key. You get 100 free renders instantly, no account needed. Store the key in an environment variable called SHOTMINT_KEY.

2. Screenshot a URL

require "net/http"
require "uri"

uri = URI("https://shotmint.creasework.com/v1/screenshot")
uri.query = URI.encode_www_form(url: "https://example.com", full_page: true)
req = Net::HTTP::Get.new(uri, "X-API-Key" => ENV.fetch("SHOTMINT_KEY"))
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 60) { |h| h.request(req) }
raise "Render failed: #{res.body}" unless res.is_a?(Net::HTTPSuccess)
File.binwrite("shot.png", res.body)

Useful parameters: full_page=true for the whole scrollable page, width/height for the viewport, device_scale_factor=2 for retina, selector to capture a single element, dark_mode=true, and hide_selectors to remove cookie banners. See the full list.

3. Turn HTML into a PDF

uri = URI("https://shotmint.creasework.com/v1/pdf")
req = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("SHOTMINT_KEY"), "Content-Type" => "application/json")
req.body = { html: ApplicationController.render(template: "invoices/show", assigns: { invoice: @invoice }), format: "A4" }.to_json
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.request(req) }
send_data res.body, type: "application/pdf", filename: "invoice.pdf"

PDF options include format (A4, Letter…), landscape, margin, and print_background. You can pass a url instead of html.

Errors & credits

A failed render never costs a credit. Status 400 means bad input or an unreachable URL, 402 means you're out of credits, and 429/503 mean you should retry with backoff. Every successful response includes an X-Credits-Remaining header.

Try it with 100 free renders

No signup, no card. Get a key in one click, then buy credits only if you need more (from €5 for 2,000, never expire).

Get a free API key Full API reference