scraperapi-ruby-sdklisted
Install: claude install-skill scraperapi/scraperapi-skills
# ScraperAPI — Ruby SDK Best Practices
**Requires:** Ruby >= 2.0, `gem install scraperapi` (or `gem 'scraperapi'` in Gemfile), `SCRAPERAPI_API_KEY` environment variable.
## Setup
```ruby
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
```ruby
# 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
```ruby
# Render JavaScript before returning HTML
# Use when: page is a React/Vue/Angu