Skip to main content

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:
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:

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.