Node
Firecrawl Node SDK is a wrapper around the Firecrawl API to help you easily turn websites into markdown.
Note: this is using v0 version of the Firecrawl API which is being deprecated. We recommend switching to v1.
Installation
To install the Firecrawl Node SDK, you can use npm:
Usage
- Get an API key from firecrawl.dev
- Set the API key as an environment variable named
FIRECRAWL_API_KEY
or pass it as a parameter to theFirecrawlApp
class.
Here’s an example of how to use the SDK with error handling:
Scraping a URL
To scrape a single URL with error handling, use the scrapeUrl
method. It takes the URL as a parameter and returns the scraped data as a dictionary.
Crawling a Website
To crawl a website with error handling, use the crawlUrl
method. It takes the starting URL and optional parameters as arguments. The params
argument allows you to specify additional options for the crawl job, such as the maximum number of pages to crawl, allowed domains, and the output format.
Checking Crawl Status
To check the status of a crawl job with error handling, use the checkCrawlStatus
method. It takes the job ID as a parameter and returns the current status of the crawl job.
Extracting structured data from a URL
With LLM extraction, you can easily extract structured data from any URL. We support zod schema to make it easier for you too. Here is how you to use it:
Search for a query
With the search
method, you can search for a query in a search engine and get the top results along with the page content for each result. The method takes the query as a parameter and returns the search results.
Error Handling
The SDK handles errors returned by the Firecrawl API and raises appropriate exceptions. If an error occurs during a request, an exception will be raised with a descriptive error message. The examples above demonstrate how to handle these errors using try/catch
blocks.