Skip to content

Ruby HTML API

Get the fully rendered HTML of any URL with one HTTP request in Ruby — real Chromium under the hood, none to maintain.

Get HTML in Ruby

No gem and no browser — the Microlink REST API renders any URL and returns the HTML with a single HTTP GET. Here it is with Net::HTTP and JSON from the Ruby standard library.
Step 01 · Extract any URL
A few lines with the standard library — no gem to add, no Chromium download. Point it at a page and read the rendered HTML from the JSON response.
fetch.rb
require 'json'
require 'net/http'
require 'uri'

uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
  url: 'https://microlink.io',
  :'data.html.attr' => 'html'
)

data = JSON.parse(Net::HTTP.get(uri))['data']

puts data['html'].length  # full rendered document
puts data['html'][0, 15]  # '<!DOCTYPE html>'
Step 02 · Scope to a selector
Return the whole document or only the subtree you need — smaller responses, less parsing and lower token cost downstream.
selector.rb
require 'json'
require 'net/http'
require 'uri'

uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
  url: 'https://microlink.io/blog',
  :'data.html.attr' => 'html',
  :'data.html.selector' => 'main' # only the <main> subtree
)

data = JSON.parse(Net::HTTP.get(uri))['data']

# No nav, no footer — just the content you asked for
puts data['html']
Step 03 · Render JavaScript pages
Client-rendered apps only produce their markup after JavaScript runs — prerender in a real browser and wait for it, still one request.
spa.rb
require 'json'
require 'net/http'
require 'uri'

uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
  url: 'https://app.example.com',
  :'data.html.attr' => 'html',
  prerender: 'true',          # render JS in a real browser first
  waitForSelector: 'h1'       # capture only when the content exists
)

data = JSON.parse(Net::HTTP.get(uri))['data']

puts data['html']
Step 04 · Serve the raw HTML
Ask for embed=html and the API answers with text/html directly — proxy it straight to a browser or write it to a file.
raw.rb
require 'net/http'
require 'uri'

uri = URI('https://api.microlink.io')
uri.query = URI.encode_www_form(
  url: 'https://microlink.io',
  :'data.html.attr' => 'html',
  embed: 'html' # respond with text/html, no JSON
)

html = Net::HTTP.get(uri) # ready to serve or store

Drop it into your framework

A Rails controller, a Sinatra endpoint, or a Sidekiq archiver — the same request becomes your own rendering endpoint.
  • Rails
  • Sinatra
  • Sidekiq
  • Plain Ruby
require 'sinatra'

# GET /render?url=https://microlink.io
get '/render' do
  uri = URI('https://api.microlink.io')
  uri.query = URI.encode_www_form(
    url: params[:url],
    :'data.html.attr' => 'html'
  )

  data = JSON.parse(Net::HTTP.get(uri))['data']
  content_type :html
  data['html']
end

Skip the browser-farm ops

Rolling your own means running Ferrum or Cuprite against your own Chromium, writing per-site wait logic, and fighting antibot walls. The API returns the rendered HTML of any page without any of the moving parts.

DIY rendering stack

  • Run and patch your own headless Chromium fleet
  • Write per-site wait logic for JavaScript-rendered pages
  • Fight antibot walls and CAPTCHAs with your own proxy pool
  • Each browser eats hundreds of MB of RAM per worker
  • You build the caching, retries and autoscaling
  • Every Chromium upgrade breaks a selector somewhere

Microlink for Ruby

  • One HTTP request — no rendering infrastructure to run
  • Fully rendered HTML from managed Chromium, JS included
  • Selector scoping to return only the subtree you need
  • Antibot and CAPTCHA resolution handled for you
  • Cached responses from a global edge network
  • Autoscaled fleet with a 99.9% uptime SLA

Built for the way you write Ruby.

A REST API that feels native in Ruby — one call, JSON back, and at home in anything from a script to a background job. Read the API overview to go deeper.

  • Real Browser Rendering

    Every request runs in managed Chromium, so client-rendered apps return complete markup instead of an empty shell.
  • Standard Library Only

    Net::HTTP and JSON ship with Ruby — the examples work with zero gems and no browser to manage.
  • Selector Scoping

    Return the full document or a single subtree with a selector — smaller payloads and less parsing downstream.
  • JSON or Raw HTML

    Read data.html from the JSON response, or ask for embed=html and get the document back as text/html — no JSON involved.
  • Readiness You Control

    waitUntil and waitForSelector let you block on network idle or on a specific element before the HTML is captured.
  • One Call, Many Formats

    Request HTML together with markdown, text, metadata, screenshots or PDFs and pay for a single render instead of several.
  • Framework Friendly

    Drop it into Rails, Sinatra, or a Sidekiq job as a controller action or a few-line worker.
  • Zero Infrastructure

    Managed Headless Chrome, autoscaled and load-balanced. No browser pool, no servers, no patching to maintain.
  • Generous Free Tier

    Sign up for a free API key: 100 requests per month with every Pro feature, no credit card.
  • Real Browser Rendering

    Every request runs in managed Chromium, so client-rendered apps return complete markup instead of an empty shell.
  • Standard Library Only

    Net::HTTP and JSON ship with Ruby — the examples work with zero gems and no browser to manage.
  • Selector Scoping

    Return the full document or a single subtree with a selector — smaller payloads and less parsing downstream.
  • JSON or Raw HTML

    Read data.html from the JSON response, or ask for embed=html and get the document back as text/html — no JSON involved.
  • Readiness You Control

    waitUntil and waitForSelector let you block on network idle or on a specific element before the HTML is captured.
  • One Call, Many Formats

    Request HTML together with markdown, text, metadata, screenshots or PDFs and pay for a single render instead of several.
  • Framework Friendly

    Drop it into Rails, Sinatra, or a Sidekiq job as a controller action or a few-line worker.
  • Zero Infrastructure

    Managed Headless Chrome, autoscaled and load-balanced. No browser pool, no servers, no patching to maintain.
  • Generous Free Tier

    Sign up for a free API key: 100 requests per month with every Pro feature, no credit card.

Try it live in the playground

Paste a URL and see the rendered output before you write a line of Ruby.

Ruby HTML API FAQ

Everything Ruby developers ask before integrating the Microlink HTML API.

Do I get the source HTML or the rendered DOM?

Every request runs in a real Chromium instance, so data.html is the fully rendered DOM — JavaScript executed, lazy content loaded. Control the capture point with waitUntil and waitForSelector.

Do I need to install a gem or a browser?

No. Net::HTTP and JSON are part of the Ruby standard library, and rendering runs on Microlink — no Ferrum, no Cuprite, no Chromium binary to manage.

How do I control when the HTML is captured?

Use waitUntil to block on network idle or a fixed delay, and waitForSelector to hold the capture until a specific element exists — the HTML comes back exactly when your page is ready, still in one request.

Can I get only part of the page?

Yes. Add a selector to the extraction rule and only that subtree comes back — ideal for articles, product cards or pricing tables, with smaller payloads and less parsing downstream.

Is there a free tier or do I need an API key?

Yes, and it is free: sign up for an API key and you get 100 requests per month with every Pro feature, no credit card. Add it as x-api-key and start extracting.
When you need more volume, pick a paid plan: same key, bigger quota. See pricing for the limits.

How fresh is the HTML?

Responses are cached at the edge with a sane default TTL, and you control freshness per request — see the API overview for cache parameters.

Start extracting in Ruby

Sign up for a free API key: 100 requests per month with every Pro feature, no credit card. Send your first request and get HTML back in minutes.
Free API key
100 requests/month
No credit card