Skip to content

Commit 5f43957

Browse files
authored
docs: update Firecrawl example
Update the example to use Firecrawl v2 API
1 parent 9fdf91a commit 5f43957

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

docs/guides/examples/firecrawl-url-crawl.mdx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ Here are two examples of how to use Firecrawl with Trigger.dev:
2020
This task crawls a website and returns the `crawlResult` object. You can set the `limit` parameter to control the number of URLs that are crawled.
2121

2222
```ts trigger/firecrawl-url-crawl.ts
23-
import FirecrawlApp from "@mendable/firecrawl-js";
23+
import Firecrawl from "@mendable/firecrawl-js";
2424
import { task } from "@trigger.dev/sdk";
2525

2626
// Initialize the Firecrawl client with your API key
27-
const firecrawlClient = new FirecrawlApp({
27+
const firecrawlClient = new Firecrawl({
2828
apiKey: process.env.FIRECRAWL_API_KEY, // Get this from your Firecrawl dashboard
2929
});
3030

@@ -34,15 +34,15 @@ export const firecrawlCrawl = task({
3434
const { url } = payload;
3535

3636
// Crawl: scrapes all the URLs of a web page and return content in LLM-ready format
37-
const crawlResult = await firecrawlClient.crawlUrl(url, {
37+
const crawlResult = await firecrawlClient.crawl(url, {
3838
limit: 100, // Limit the number of URLs to crawl
3939
scrapeOptions: {
4040
formats: ["markdown", "html"],
4141
},
4242
});
4343

44-
if (!crawlResult.success) {
45-
throw new Error(`Failed to crawl: ${crawlResult.error}`);
44+
if (crawlResult.status === "failed") {
45+
throw new Error(`Failed to crawl: ${url}`);
4646
}
4747

4848
return {
@@ -65,11 +65,11 @@ You can test your task by triggering it from the Trigger.dev dashboard.
6565
This task scrapes a single URL and returns the `scrapeResult` object.
6666

6767
```ts trigger/firecrawl-url-scrape.ts
68-
import FirecrawlApp, { ScrapeResponse } from "@mendable/firecrawl-js";
68+
import Firecrawl from "@mendable/firecrawl-js";
6969
import { task } from "@trigger.dev/sdk";
7070

7171
// Initialize the Firecrawl client with your API key
72-
const firecrawlClient = new FirecrawlApp({
72+
const firecrawlClient = new Firecrawl({
7373
apiKey: process.env.FIRECRAWL_API_KEY, // Get this from your Firecrawl dashboard
7474
});
7575

@@ -79,13 +79,9 @@ export const firecrawlScrape = task({
7979
const { url } = payload;
8080

8181
// Scrape: scrapes a URL and get its content in LLM-ready format (markdown, structured data via LLM Extract, screenshot, html)
82-
const scrapeResult = (await firecrawlClient.scrapeUrl(url, {
82+
const scrapeResult = await firecrawlClient.scrape(url, {
8383
formats: ["markdown", "html"],
84-
})) as ScrapeResponse;
85-
86-
if (!scrapeResult.success) {
87-
throw new Error(`Failed to scrape: ${scrapeResult.error}`);
88-
}
84+
});
8985

9086
return {
9187
data: scrapeResult,

0 commit comments

Comments
 (0)