From 114bc56b43e4d16d4180d69b993f64c0662c62bd Mon Sep 17 00:00:00 2001 From: "firecrawl-spring[bot]" <254786068+firecrawl-spring[bot]@users.noreply.github.com> Date: Wed, 1 Apr 2026 10:29:28 +0000 Subject: [PATCH] docs(actions): add executeJavascript example and document javascriptReturns Add a code example for the executeJavascript action in the advanced scraping guide and clarify that return values are available in actions.javascriptReturns. Co-Authored-By: micahstairs --- advanced-scraping-guide.mdx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/advanced-scraping-guide.mdx b/advanced-scraping-guide.mdx index 8003d389..48209f8a 100644 --- a/advanced-scraping-guide.mdx +++ b/advanced-scraping-guide.mdx @@ -138,7 +138,7 @@ Run browser actions before scraping. This is useful for dynamic content, navigat | `scroll` | `direction?: "up" \| "down"`, `selector?: string` | Scroll the page or a specific element. Direction defaults to `"down"`. | | `screenshot` | `fullPage?: boolean`, `quality?: number`, `viewport?: { width, height }` | Capture a screenshot. Max viewport resolution is 7680×4320. | | `scrape` | _(none)_ | Capture the current page HTML at this point in the action sequence. | -| `executeJavascript` | `script: string` | Run JavaScript code in the page. Returns `{ type, value }`. | +| `executeJavascript` | `script: string` | Run JavaScript code in the page. Return values are available in the `actions.javascriptReturns` array of the response. | | `pdf` | `format?: string`, `landscape?: boolean`, `scale?: number` | Generate a PDF. Supported formats: `"A0"` through `"A6"`, `"Letter"`, `"Legal"`, `"Tabloid"`, `"Ledger"`. Defaults to `"Letter"`. | @@ -262,6 +262,23 @@ curl -X POST https://api.firecrawl.dev/v2/scrape \ }' ``` +**Executing JavaScript (e.g. extracting embedded page data):** + +```bash cURL +curl -X POST https://api.firecrawl.dev/v2/scrape \ + -H 'Content-Type: application/json' \ + -H 'Authorization: Bearer fc-YOUR-API-KEY' \ + -d '{ + "url": "https://example.com", + "actions": [ + { "type": "executeJavascript", "script": "document.querySelector(\"#__NEXT_DATA__\").textContent" } + ], + "formats": ["markdown"] + }' +``` + +The return value of each `executeJavascript` action is captured in the `actions.javascriptReturns` array of the response. + ### Full scrape example The following request combines multiple scrape options: