Ruby Screenshot API
Capture pixel-perfect screenshots of any URL with one HTTP request in Ruby — no Selenium, no ChromeDriver, no servers to maintain.
Take a screenshot in Ruby
No gem and no headless browser — the Microlink REST API turns any URL into a hosted screenshot with a single HTTP GET. Here it is with Net::HTTP and JSON from the Ruby standard library.
Step 01 · Capture any URL
A few lines with the standard library — no gem to add. Point it at a page and read the hosted image URL from the JSON response.
capture.rb
require 'json'
require 'net/http'
require 'uri'
uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
url: 'https://example.com',
screenshot: true,
meta: false # skip metadata extraction for a faster response
)
res = JSON.parse(Net::HTTP.get(uri))
puts res.dig('data', 'screenshot', 'url')Step 02 · Add timeouts and error handling
When it runs in production, wrap the request with explicit timeouts and raise on anything that is not a hosted screenshot URL.
microlink.rb
require 'json'
require 'net/http'
require 'uri'
module Microlink
Error = Class.new(StandardError)
ENDPOINT = 'https://api.microlink.io'.freeze
module_function
def screenshot_url(target)
uri = URI(ENDPOINT)
uri.query = URI.encode_www_form(url: target, screenshot: true, meta: false)
request = Net::HTTP::Get.new(uri)
response = begin
Net::HTTP.start(
uri.host, uri.port,
use_ssl: true, open_timeout: 10, read_timeout: 60
) { |http| http.request(request) }
rescue Net::OpenTimeout, Net::ReadTimeout => e
raise Error, "microlink: #{e.class}"
end
payload = begin
JSON.parse(response.body.to_s)
rescue JSON::ParserError
raise Error, "microlink: #{response.code} #{response.message}: invalid JSON"
end
unless response.is_a?(Net::HTTPSuccess)
raise Error, "microlink: #{response.code}: #{payload['message']}"
end
payload.dig('data', 'screenshot', 'url') ||
raise(Error, 'microlink: no screenshot url in response')
end
endStep 03 · Customize the capture
Output format, full-page captures, device emulation, and ad blocking — every Headless Chrome option is just a query field (dot notation for nested ones).
options.rb
require 'json'
require 'net/http'
require 'uri'
uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
'url' => 'https://example.com',
'screenshot.type' => 'jpeg', # png (default) | jpeg
'screenshot.fullPage' => 'true', # capture the entire scrollable page
'device' => 'iPhone X', # emulate any device
'adblock' => 'true', # strip ads & cookie banners (default)
'meta' => 'false'
)
res = JSON.parse(Net::HTTP.get(uri))
puts res.dig('data', 'screenshot', 'url')Step 04 · Save it to disk
The response is a hosted image URL on a global CDN. Download it with a second request, or just hand the URL to the browser.
save.rb
require 'json'
require 'net/http'
require 'uri'
uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(url: 'https://example.com', screenshot: true)
res = JSON.parse(Net::HTTP.get(uri))
image = res.dig('data', 'screenshot', 'url')
File.binwrite('screenshot.png', Net::HTTP.get(URI(image)))Drop it into your framework
A controller action, a Sinatra route, or a Sidekiq job — the same request becomes your own screenshot endpoint, perfect for dynamic Open Graph images on any host.
- Rails
- Sinatra
- Sidekiq
- Plain Ruby
require 'sinatra'
require_relative 'microlink'
# GET /screenshot?url=https://example.com
get '/screenshot' do
redirect Microlink.screenshot_url(params['url'])
rescue Microlink::Error => e
halt 502, e.message
endEvery tab reuses the quickstart module:
Microlink.screenshot_url(target)Skip the headless Chrome maintenance
Driving a browser from Ruby means wiring Selenium, Ferrum or Cuprite to a Chrome binary, shipping 300 MB of browser in every deploy, and fighting cold starts. The API gives you the same control without any of the infrastructure.
Self-hosted headless Chrome
- Wire selenium-webdriver, Ferrum or Cuprite to a Chrome binary
- Install & maintain Chromium (~300 MB) plus system libraries
- Each browser eats hundreds of MB of RAM; Puma workers stall
- Launching Chromium adds seconds of latency per request
- You build the process pool, queueing, retries and autoscaling
- Write your own cookie-banner & ad dismissal scripts
Microlink for Ruby
- One HTTP request — Net::HTTP from the standard library, no gem to add
- Runs anywhere: Heroku, Rails, serverless, containers, your laptop
- Autoscaled managed browser fleet with a 99.95% uptime SLA
- Sub-second cached responses from 340+ edge locations
- Built-in adblock removes ads & cookie banners automatically
- Full-page, device emulation, overlays & DOM interaction included
Built for the way you write Ruby.
A REST API that feels native in Ruby — one HTTP call, JSON back, and at home in anything from a Rake task to a Rails app. Read the screenshot guide to go deeper.
No Browser to Install
Ruby cannot run a headless browser natively. With the API there is no Chrome, ChromeDriver, or Ferrum setup to install or maintain.
Standard Library Only
Net::HTTP and JSON ship with Ruby — it is a plain HTTP GET, with no gem required and nothing to compile.
Framework Friendly
Drop it into Rails, Sinatra, or a Sidekiq job as a controller action, route, or worker in a few lines.
Runs on Any Host
Works on Heroku, serverless, and containers alike — there are no binaries or system libraries to ship.
Simple JSON Response
A single request returns JSON with the hosted image URL. No drivers, no explicit waits, no browser process to babysit.
Zero Infrastructure
Managed Headless Chrome, autoscaled and load-balanced. No browser pool, no servers, no patching to maintain.
Built-in Adblock
Captures arrive clean — GDPR cookie banners, newsletter popups, and injected ads are removed before the shot.
Full Browser Control
Full-page captures, viewport and device emulation, click and wait, plus custom CSS and JavaScript injection.
Generous Free Tier
Start with 25 requests per day — no account, no credit card. Add an API key when you are ready to scale.
No Browser to Install
Ruby cannot run a headless browser natively. With the API there is no Chrome, ChromeDriver, or Ferrum setup to install or maintain.Standard Library Only
Net::HTTP and JSON ship with Ruby — it is a plain HTTP GET, with no gem required and nothing to compile.Framework Friendly
Drop it into Rails, Sinatra, or a Sidekiq job as a controller action, route, or worker in a few lines.
Runs on Any Host
Works on Heroku, serverless, and containers alike — there are no binaries or system libraries to ship.Simple JSON Response
A single request returns JSON with the hosted image URL. No drivers, no explicit waits, no browser process to babysit.Zero Infrastructure
Managed Headless Chrome, autoscaled and load-balanced. No browser pool, no servers, no patching to maintain.
Built-in Adblock
Captures arrive clean — GDPR cookie banners, newsletter popups, and injected ads are removed before the shot.Full Browser Control
Full-page captures, viewport and device emulation, click and wait, plus custom CSS and JavaScript injection.Generous Free Tier
Start with 25 requests per day — no account, no credit card. Add an API key when you are ready to scale.
Try it live in the playground
Paste a URL and see the exact API request before you write a line of Ruby.
Ruby Screenshot FAQ
Everything Ruby developers ask before integrating the Microlink screenshot API.
Do I need a headless browser or Chrome?
No. Driving a browser from Ruby normally means Selenium, Ferrum or Cuprite wired to a Chrome binary. With the API it is just an HTTP request — the Headless Chrome fleet runs on Microlink's side.
Do I need to install a gem?
No.
Net::HTTP and JSON are part of the Ruby standard library, so the examples work with zero dependencies. If you already use faraday or httparty, the same request translates directly.Does it work with Rails, Sinatra, and Sidekiq?
Yes. Because it is just an HTTP call, it drops into a Rails controller, a Sinatra route, or a Sidekiq worker in a few lines — see the tabs above, or the screenshot guide.
Does it run on Heroku or serverless?
Yes. Because there are no binaries or system libraries to install, it works on Heroku, serverless functions, and containers alike — no Chrome buildpack to fight.
See the API overview for request details.
Is there a free tier or do I need an API key?
The free tier gives you 25 requests per day with no account, no credit card, and no API key. Just call the endpoint and start capturing.
When you need more throughput or caching control, add an
apiKey header and requests route to the Pro tier. See pricing for the limits.How fast is it and how does it scale?
Cached captures return sub-second from a global edge network, and the browser fleet autoscales behind a 99.95% uptime SLA — so a traffic spike does not mean provisioning more servers.
Compare the numbers on the screenshot API benchmarks.
Start capturing in Ruby
Get 25 requests/day with zero commitment — no account and no credit card. Send your first request and ship a screenshot in minutes.
No login needed
25 reqs/day free
No credit card
