Project

zyterb

0.0
The project is in a healthy, maintained state
Simple Ruby client to extract data and take screenshots using Zyte API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Zyterb

A zero-dependency Ruby client for the Zyte API. It uses only Ruby's standard library (Net::HTTP, JSON, Base64).

Installation

Add this line to your application's Gemfile:

gem 'zyterb'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install zyterb

Usage

Configuration

You can provide your Zyte API key via an environment variable:

export ZYTE_API_KEY='your_api_key_here'

Or via a configuration block:

require 'zyterb'

Zyterb.configure do |config|
  config.api_key = 'your_api_key_here'
end

client = Zyterb::Client.new

Or pass it when initializing the client:

client = Zyterb::Client.new(api_key: 'your_api_key_here')

Basic Extraction

By default, it fetches browserHtml:

result = client.extract("https://example.com")
puts result['browserHtml']

AI Structured Extraction

Zyte API supports AI-driven extraction for specific page types:

# Extract an article
article = client.extract("https://example.com/blog/post", article: true)
puts article['article']['headline']

# Extract a product
product = client.extract("https://example.com/p/123", product: true)
puts product['product']['name']

Supported AI fields include: article, product, jobPosting, serp, and more.

Screenshots

The #screenshot method returns the raw binary image data (it handles Base64 decoding for you).

image_data = client.screenshot("https://example.com", format: 'png', full_page: true)

File.binwrite("example.png", image_data)

License

The gem is available as open source under the terms of the MIT License.