From be3eb211e9067ecebe103793ccc2629d8cac9af2 Mon Sep 17 00:00:00 2001 From: rafaelsideguide <150964962+rafaelsideguide@users.noreply.github.com> Date: Tue, 16 Apr 2024 11:38:22 -0300 Subject: [PATCH] adding JS-SDK --- apps/js-sdk/example.js | 20 ++++++++++++++++++++ apps/js-sdk/package.json | 16 ++++++++++++++++ apps/python-sdk/example.py | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 apps/js-sdk/example.js create mode 100644 apps/js-sdk/package.json diff --git a/apps/js-sdk/example.js b/apps/js-sdk/example.js new file mode 100644 index 0000000..5b478f9 --- /dev/null +++ b/apps/js-sdk/example.js @@ -0,0 +1,20 @@ +import { FirecrawlApp } from '@mendableai/firecrawl-js'; + +const app = new FirecrawlApp({apiKey: "YOUR_API_KEY"}); + +const crawlResult = await app.crawlUrl('mendable.ai', {crawlerOptions: {excludes: ['blog/*'], limit: 5}}, false); +console.log(crawlResult) + +const jobId = await crawlResult['jobId']; +console.log(jobId); + +let job; +while (true) { + job = await app.checkCrawlStatus(jobId); + if (job.status == 'completed') { + break; + } + await new Promise(resolve => setTimeout(resolve, 1000)); // wait 1 second +} + +console.log(job.data[0].content); \ No newline at end of file diff --git a/apps/js-sdk/package.json b/apps/js-sdk/package.json new file mode 100644 index 0000000..6b92feb --- /dev/null +++ b/apps/js-sdk/package.json @@ -0,0 +1,16 @@ +{ + "name": "js-example", + "version": "1.0.0", + "description": "", + "main": "example.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "axios": "^1.6.8" + } +} diff --git a/apps/python-sdk/example.py b/apps/python-sdk/example.py index 4ceee85..b178400 100644 --- a/apps/python-sdk/example.py +++ b/apps/python-sdk/example.py @@ -1,7 +1,7 @@ from firecrawl import FirecrawlApp -app = FirecrawlApp(api_key="a6a2d63a-ed2b-46a9-946d-2a7207efed4d") +app = FirecrawlApp(api_key="YOUR_API_KEY") crawl_result = app.crawl_url('mendable.ai', {'crawlerOptions': {'excludes': ['blog/*']}}) print(crawl_result[0]['markdown'])