Skip to main content

Ruby

Firecrawl Ruby SDK is a wrapper around the Firecrawl API to help you easily turn websites into markdown.
2 min read

Installation#

The official Ruby SDK is maintained in the Firecrawl monorepo at apps/ruby-sdk.

To install the Firecrawl Ruby SDK, add it to your project:

Add to your Gemfile:

Then run:

Note
Requires Ruby 3.0 or later.

Usage#

  1. Get an API key from firecrawl.dev
  2. Set the API key as an environment variable named FIRECRAWL_API_KEY, or pass it directly with Firecrawl::Client.new(api_key: ...)

Here is a quick example using the current SDK API surface:

Scraping a URL#

To scrape a single URL, use the scrape method.

JSON Extraction#

Extract structured JSON via the scrape endpoint by including a json format with a prompt and schema:

Crawling a Website#

To crawl a website and wait for completion, use crawl. It auto-polls until the job finishes.

Start a Crawl#

Start a job without waiting using start_crawl.

Checking Crawl Status#

Check crawl progress with get_crawl_status.

Cancelling a Crawl#

Cancel a running crawl with cancel_crawl.

Mapping a Website#

Discover links on a site using map.

Searching the Web#

Search with optional settings using search.

Batch Scraping#

Scrape multiple URLs in parallel using batch_scrape.

Agent#

Run an AI-powered agent with agent.

With a JSON schema for structured output:

Usage & Metrics#

Check concurrency and remaining credits:

Browser#

The Ruby SDK includes Browser Sandbox helpers.

Scrape-Bound Interactive Session#

Use a scrape job ID to run follow-up browser code in the same replayed context:

  • interact(...) runs code in the scrape-bound browser session (and initializes it on first use).
  • stop_interactive_browser(...) explicitly stops the interactive session when you are done.

Configuration#

Firecrawl::Client.new supports the following options:

OptionTypeDefaultDescription
api_keyStringFIRECRAWL_API_KEY env varYour Firecrawl API key
api_urlStringhttps://api.firecrawl.dev (or FIRECRAWL_API_URL)API base URL
timeoutInteger300HTTP request timeout in seconds
max_retriesInteger3Automatic retries for transient failures
backoff_factorFloat0.5Exponential backoff factor in seconds

Error Handling#

The SDK raises exceptions under the Firecrawl module.

Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.