scraperapi-ruby-sdk

A reference for using ScraperAPI from Ruby through its official software library, called an SDK. It covers setup, page fetching, JavaScript-rendered pages, location settings, and multi-page requests.

In plain words
What is it for?
Writing, debugging, or reviewing Ruby code that fetches website pages with ScraperAPI, including pages that load content with JavaScript or sites that block ordinary data-center requests.
Why use it?
It helps Ruby developers choose the right request pattern and avoid common setup mistakes, such as putting an API key directly in source code. It also explains when a simple request is not enough.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/scraperapi/scraperapi-skills/scraperapi-ruby-sdk
Any agent
npx skills add scraperapi/scraperapi-skills --skill scraperapi-ruby-sdk
Clone the repo
git clone --depth 1 https://github.com/scraperapi/scraperapi-skills

Made for: Claude Code, Codex.

Per session 150 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,209 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00150 $0.02209
Opus 5 $0.00075 $0.01104
Sonnet 5 $0.00030 $0.00442
Haiku 4.5 $0.00015 $0.00221

Measured 2d ago against content hash 0ccaca76bd8e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

scraperapi-ruby-sdk scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/scraperapi-ruby-sdk/SKILL.md · 264 lines

How it starts

The opening of the file, as written. The whole thing — 264 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ScraperAPI — Ruby SDK Best Practices

Requires: Ruby >= 2.0, gem install scraperapi (or gem 'scraperapi' in Gemfile), SCRAPERAPI_API_KEY environment variable.

Setup

require "scraper_api"

client = ScraperAPI::Client.new(ENV["SCRAPERAPI_API_KEY"])

Never hardcode the API key. Read it from the environment every time.

Basic Usage

# Simple GET — returns raw HTML string via .raw_body
html = client.get("https://example.com/").raw_body
puts html

# With a single parameter
html = client.get("https://example.com/", render: true).raw_body

# With multiple parameters
html = client.get(
  "https://example.com/",
  render: true,
  country_code: "us"
).raw_body

Parameters are passed as keyword arguments after the URL. .raw_body extracts the HTML string from the response object.

Decision Guide

Situation Approach
Single URL, synchronous client.get(url, **params).raw_body
Page loads content via JavaScript Pass render: true
Site blocks datacenter proxies Pass premium: true
Toughest anti-bot protection Pass ultra_premium: true
Multi-step / paginated flow on same domain Use session_number:
20+ URLs or batch jobs Use async endpoint via Net::HTTP or Faraday
Supported platform (Amazon, Google, etc.) Use structured data endpoint directly

Parameter Reference

Rendering

# Render JavaScript before returning HTML
# Use when: page is a React/Vue/Angular SPA, or initial scrape returns empty/partial content
# Cost: +10 credits
html = client.get("https://spa-site.com/", render: true).raw_body

# Wait for a specific DOM element (requires render: true)
html = client.get(
  "https://spa-site.com/",
  render: true,
  wait_for_selector: ".product-list"
).raw_body

Don't add render: true by default — try without it first. It increases cost and latency.

Proxies and Geotargeting

# Route through a country-specific proxy — no extra credit cost
html = client.get("https://example.com/", country_code: "gb").raw_body

# Premium residential/mobile IPs — for sites that block datacenter proxies
# Cost: 10 credits (25 with render: true)
html = client.get("https://hard-site.com/", premium: true).raw_body

# Ultra-premium — for the toughest anti-bot protections
# Cost: 30 credits (75 with render: true)
# Note: incompatible with keep_headers — custom headers are discarded
html = client.get("https://hardest-site.com/", ultra_premium: true).raw_body

Read the full file on GitHub · 264 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 264 lines · 150 tokens per session scan A 0ccaca76bd8e

Subscribe to this mod's changes

scraperapi-ruby-sdk is a skill published in the GitHub repository scraperapi/scraperapi-skills (10 stars, last pushed 25d ago), licensed MIT. It adds 150 tokens to every session and 2,209 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

scrapling-official

Scrape web pages using Scrapling with anti-bot bypass (like Cloudflare Turnstile), stealth headless browsing, spiders framework, adaptive scraping, and JavaScript rendering. Use when asked to scrape, crawl, or extract data from websites; webfetch fails; the site has anti-bot protections; write Python code to…

D4Vinci/Scrapling · 80 tokens

browser-automation

Playwright-based browser automation patterns for autonomous web interaction.

RightNow-AI/openfang · 14 tokens

ketch

Research skill for ketch — a fast stateless CLI for web search, OSS code search, curated library docs, page scraping, and site crawling; an optional MCP server exists for operators who want it, but the CLI is the primary interface. Use when a question needs live sources: 'research X', 'what are people saying about Y'…

1broseidon/ketch · 148 tokens

browser-automation

Playwright-based browser automation patterns for autonomous web interaction.

librefang/librefang · 14 tokens

web-browse

Drive a headless browser to navigate pages, read content, click, and fill forms — for sites that need JavaScript rendering or interaction beyond a plain HTTP fetch.

initializ/forge · 37 tokens

ecommerce-full-pipeline

电商运营在开展跨境电商或闲鱼捡漏业务时,若需解决选品难、上架繁琐等痛点,必用此技能!一键打通“爆品挖掘→1688采集→多平台上架→推广文案→短视频生成”全自动流水线,轻松实现端到端自动化,让开店运营效率翻倍。.

anbeime/skill · 96 tokens