Skip to main content

Ruby SDK

The official Ruby SDK for the Generator Labs API v4.0. Uses Ruby-idiomatic conventions including keyword arguments and optional parentheses.

Packagegeneratorlabs (RubyGems)
Minimum versionRuby 3.0+
GitHubgenerator-labs/ruby-sdk

Installation

gem install generatorlabs

Or add to your Gemfile:

gem 'generatorlabs'

Then run:

bundle install

Usage

require 'generatorlabs'

client = GeneratorLabs::Client.new('your_account_sid', 'your_auth_token')

# Get a single host
host = client.rbl.hosts.get('host_id')

# List all hosts with automatic pagination
hosts = client.rbl.hosts.get_all

# Create a certificate monitor
monitor = client.cert.monitors.create(name: 'example.com')

# Responses support hash-like access
puts host['data']['name']

Configuration

config = GeneratorLabs::Config.new(
timeout: 45,
max_retries: 5,
retry_backoff: 2.0,
)

client = GeneratorLabs::Client.new('your_account_sid', 'your_auth_token', config)
OptionDefaultDescription
timeout30Total request timeout in seconds
connect_timeout5TCP connection timeout in seconds
max_retries3Maximum number of retry attempts
retry_backoff1.0Backoff multiplier between retries
base_urlOverride the default API base URL

Webhook Verification

GeneratorLabs::Webhook.verify(body, signature_header, secret, tolerance)

See Using Web Hooks for more details on webhook payloads and signature verification.

Error Handling

The Ruby SDK raises GeneratorLabs::Error errors that you can catch with standard begin / rescue:

begin
host = client.rbl.hosts.get('host_id')
rescue GeneratorLabs::Error => e
puts e.message
end

Rate Limit Information

Rate limit details are available on every response:

puts response.rate_limit_info.remaining
puts response.rate_limit_info.reset

See What Are the API Rate Limits? for more information.