Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
added idempotency key to python sdk
rafaelsideguidec201ea1986c8
diff --git a/apps/js-sdk/firecrawl/build/index.js b/apps/js-sdk/firecrawl/build/index.jsindex 2a258cfae..76edfe59c 100644--- a/apps/js-sdk/firecrawl/build/index.js+++ b/apps/js-sdk/firecrawl/build/index.js@@ -19,7 +19,7 @@ export default class FirecrawlApp {* @param {FirecrawlAppConfig} config - Configuration options for the FirecrawlApp instance.*/constructor({ apiKey = null }) {- this.apiKey = apiKey || '';+ this.apiKey = apiKey || "";if (!this.apiKey) {throw new Error("No API key provided");}diff --git a/apps/js-sdk/firecrawl/package.json b/apps/js-sdk/firecrawl/package.jsonindex 3bacdf43b..e43f6ea63 100644--- a/apps/js-sdk/firecrawl/package.json+++ b/apps/js-sdk/firecrawl/package.json@@ -1,6 +1,6 @@{"name": "@mendable/firecrawl-js",- "version": "0.0.21",+ "version": "0.0.22","description": "JavaScript SDK for Firecrawl API","main": "build/index.js","types": "types/index.d.ts",diff --git a/apps/python-sdk/example.py b/apps/python-sdk/example.pyindex d83be6dea..d80fa7959 100644--- a/apps/python-sdk/example.py+++ b/apps/python-sdk/example.py@@ -1,4 +1,5 @@-from firecrawl import FirecrawlApp+import uuid+from firecrawl.firecrawl import FirecrawlAppapp = FirecrawlApp(api_key="fc-YOUR_API_KEY")@@ -7,7 +8,8 @@ scrape_result = app.scrape_url('firecrawl.dev')print(scrape_result['markdown'])# Crawl a website:-crawl_result = app.crawl_url('mendable.ai', {'crawlerOptions': {'excludes': ['blog/*']}})+idempotency_key = str(uuid.uuid4()) # optional idempotency key+crawl_result = app.crawl_url('mendable.ai', {'crawlerOptions': {'excludes': ['blog/*']}}, True, 2, idempotency_key)print(crawl_result)# LLM Extraction:diff --git a/apps/python-sdk/firecrawl/firecrawl.py b/apps/python-sdk/firecrawl/firecrawl.pyindex 98cb8ed68..1f59ec711 100644--- a/apps/python-sdk/firecrawl/firecrawl.py+++ b/apps/python-sdk/firecrawl/firecrawl.py@@ -81,8 +81,8 @@ class FirecrawlApp:else:raise Exception(f'Failed to search. Status code: {response.status_code}')- def crawl_url(self, url, params=None, wait_until_done=True, timeout=2):- headers = self._prepare_headers()+ def crawl_url(self, url, params=None, wait_until_done=True, timeout=2, idempotency_key=None):+ headers = self._prepare_headers(idempotency_key)json_data = {'url': url}if params:json_data.update(params)@@ -104,10 +104,16 @@ class FirecrawlApp:else:self._handle_error(response, 'check crawl status')- def _prepare_headers(self):+ def _prepare_headers(self, idempotency_key=None):+ if idempotency_key:+ return {+ 'Content-Type': 'application/json',+ 'Authorization': f'Bearer {self.api_key}',+ 'x-idempotency-key': idempotency_key+ }return {'Content-Type': 'application/json',- 'Authorization': f'Bearer {self.api_key}'+ 'Authorization': f'Bearer {self.api_key}',}def _post_request(self, url, data, headers, retries=3, backoff_factor=0.5):