Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Add parsePDF parameter to JS SDK (#1720)

devin-ai-integration[bot]fa5b96c52190
diff --git a/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts b/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts
index 6328f4903..ffe3ac747 100644
--- a/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts
+++ b/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts
@@ -103,6 +103,32 @@ describe('FirecrawlApp E2E Tests', () => {
expect(response?.markdown).toContain('We present spectrophotometric observations of the Broad Line Radio Galaxy');
}, 30000); // 30 seconds timeout
+ test.concurrent('should return successful response for valid scrape with PDF file and parsePDF true', async () => {
+ const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
+ const response = await app.scrapeUrl('https://arxiv.org/pdf/astro-ph/9301001.pdf', {
+ parsePDF: true
+ });
+ if (!response.success) {
+ throw new Error(response.error);
+ }
+
+ expect(response).not.toBeNull();
+ expect(response?.markdown).toContain('We present spectrophotometric observations of the Broad Line Radio Galaxy');
+ }, 30000); // 30 seconds timeout
+
+ test.concurrent('should return successful response for valid scrape with PDF file and parsePDF false', async () => {
+ const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
+ const response = await app.scrapeUrl('https://arxiv.org/pdf/astro-ph/9301001.pdf', {
+ parsePDF: false
+ });
+ if (!response.success) {
+ throw new Error(response.error);
+ }
+
+ expect(response).not.toBeNull();
+ expect(response?.markdown).toMatch(/^[A-Za-z0-9+/]+=*$/);
+ }, 30000); // 30 seconds timeout
+
test.concurrent('should throw error for invalid API key on crawl', async () => {
if (API_URL.includes('api.firecrawl.dev')) {
const invalidApp = new FirecrawlApp({ apiKey: "invalid_api_key", apiUrl: API_URL });
diff --git a/apps/js-sdk/firecrawl/src/index.ts b/apps/js-sdk/firecrawl/src/index.ts
index 04def686f..b75f39708 100644
--- a/apps/js-sdk/firecrawl/src/index.ts
+++ b/apps/js-sdk/firecrawl/src/index.ts
@@ -125,6 +125,7 @@ export interface CrawlScrapeOptions {
proxy?: "basic" | "stealth" | "auto";
storeInCache?: boolean;
maxAge?: number;
+ parsePDF?: boolean;
}
export type Action = {