Skip to content

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

Nick: v15

Nicolasb7c7291b0e88
diff --git a/apps/js-sdk/firecrawl/build/index.js b/apps/js-sdk/firecrawl/build/index.js
index 1b23bb54f..9d8237b47 100644
--- a/apps/js-sdk/firecrawl/build/index.js
+++ b/apps/js-sdk/firecrawl/build/index.js
@@ -61,6 +61,43 @@ export default class FirecrawlApp {
return { success: false, error: 'Internal server error.' };
});
}
+ /**
+ * Searches for a query using the Firecrawl API.
+ * @param {string} query - The query to search for.
+ * @param {Params | null} params - Additional parameters for the search request.
+ * @returns {Promise<SearchResponse>} The response from the search operation.
+ */
+ search(query_1) {
+ return __awaiter(this, arguments, void 0, function* (query, params = null) {
+ const headers = {
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${this.apiKey}`,
+ };
+ let jsonData = { query };
+ if (params) {
+ jsonData = Object.assign(Object.assign({}, jsonData), params);
+ }
+ try {
+ const response = yield axios.post('https://api.firecrawl.dev/v0/search', jsonData, { headers });
+ if (response.status === 200) {
+ const responseData = response.data;
+ if (responseData.success) {
+ return responseData;
+ }
+ else {
+ throw new Error(`Failed to search. Error: ${responseData.error}`);
+ }
+ }
+ else {
+ this.handleError(response, 'search');
+ }
+ }
+ catch (error) {
+ throw new Error(error.message);
+ }
+ return { success: false, error: 'Internal server error.' };
+ });
+ }
/**
* Initiates a crawl job for a URL using the Firecrawl API.
* @param {string} url - The URL to crawl.
diff --git a/apps/js-sdk/firecrawl/package.json b/apps/js-sdk/firecrawl/package.json
index 566fdde97..c35a93b60 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.13",
+ "version": "0.0.15",
"description": "JavaScript SDK for Firecrawl API",
"main": "build/index.js",
"types": "types/index.d.ts",
diff --git a/apps/js-sdk/firecrawl/src/index.ts b/apps/js-sdk/firecrawl/src/index.ts
index 654560011..54e4e2372 100644
--- a/apps/js-sdk/firecrawl/src/index.ts
+++ b/apps/js-sdk/firecrawl/src/index.ts
@@ -25,6 +25,14 @@ export interface ScrapeResponse {
error?: string;
}
+/**
+ * Response interface for searching operations.
+ */
+export interface SearchResponse {
+ success: boolean;
+ data?: any;
+ error?: string;
+}
/**
* Response interface for crawling operations.
*/
@@ -96,6 +104,39 @@ export default class FirecrawlApp {
return { success: false, error: 'Internal server error.' };
}
+ /**
+ * Searches for a query using the Firecrawl API.
+ * @param {string} query - The query to search for.
+ * @param {Params | null} params - Additional parameters for the search request.
+ * @returns {Promise<SearchResponse>} The response from the search operation.
+ */
+ async search(query: string, params: Params | null = null): Promise<SearchResponse> {
+ const headers: AxiosRequestHeaders = {
+ 'Content-Type': 'application/json',
+ 'Authorization': `Bearer ${this.apiKey}`,
+ } as AxiosRequestHeaders;
+ let jsonData: Params = { query };
+ if (params) {
+ jsonData = { ...jsonData, ...params };
+ }
+ try {
+ const response: AxiosResponse = await axios.post('https://api.firecrawl.dev/v0/search', jsonData, { headers });
+ if (response.status === 200) {
+ const responseData = response.data;
+ if (responseData.success) {
+ return responseData;
+ } else {
+ throw new Error(`Failed to search. Error: ${responseData.error}`);
+ }
+ } else {
+ this.handleError(response, 'search');
+ }
+ } catch (error: any) {
+ throw new Error(error.message);
+ }
+ return { success: false, error: 'Internal server error.' };
+ }
+
/**
* Initiates a crawl job for a URL using the Firecrawl API.
* @param {string} url - The URL to crawl.
diff --git a/apps/js-sdk/firecrawl/types/index.d.ts b/apps/js-sdk/firecrawl/types/index.d.ts
index be960f7c6..7f79d6443 100644
--- a/apps/js-sdk/firecrawl/types/index.d.ts
+++ b/apps/js-sdk/firecrawl/types/index.d.ts
@@ -19,6 +19,14 @@ export interface ScrapeResponse {
data?: any;
error?: string;
}
+/**
+ * Response interface for searching operations.
+ */
+export interface SearchResponse {
+ success: boolean;
+ data?: any;
+ error?: string;
+}
/**
* Response interface for crawling operations.
*/
@@ -55,6 +63,13 @@ export default class FirecrawlApp {
* @returns {Promise<ScrapeResponse>} The response from the scrape operation.
*/
scrapeUrl(url: string, params?: Params | null): Promise<ScrapeResponse>;
+ /**
+ * Searches for a query using the Firecrawl API.
+ * @param {string} query - The query to search for.
+ * @param {Params | null} params - Additional parameters for the search request.
+ * @returns {Promise<SearchResponse>} The response from the search operation.
+ */
+ search(query: string, params?: Params | null): Promise<SearchResponse>;
/**
* Initiates a crawl job for a URL using the Firecrawl API.
* @param {string} url - The URL to crawl.
diff --git a/apps/js-sdk/package-lock.json b/apps/js-sdk/package-lock.json
index a73272f4d..363f30137 100644
--- a/apps/js-sdk/package-lock.json
+++ b/apps/js-sdk/package-lock.json
@@ -9,14 +9,14 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
- "@mendable/firecrawl-js": "^0.0.8",
+ "@mendable/firecrawl-js": "^0.0.15",
"axios": "^1.6.8"
}
},
"node_modules/@mendable/firecrawl-js": {
- "version": "0.0.8",
- "resolved": "https://registry.npmjs.org/@mendable/firecrawl-js/-/firecrawl-js-0.0.8.tgz",
- "integrity": "sha512-dD7eA5X6UT8CM3z7qCqHgA4YbCsdwmmlaT/L0/ozM6gGvb0PnJMoB+e51+n4lAW8mxXOvHGbq9nrgBT1wEhhhw==",
+ "version": "0.0.15",
+ "resolved": "https://registry.npmjs.org/@mendable/firecrawl-js/-/firecrawl-js-0.0.15.tgz",
+ "integrity": "sha512-e3iCCrLIiEh+jEDerGV9Uhdkn8ymo+sG+k3osCwPg51xW1xUdAnmlcHrcJoR43RvKXdvD/lqoxg8odUEsqyH+w==",
"dependencies": {
"axios": "^1.6.8",
"dotenv": "^16.4.5"
diff --git a/apps/js-sdk/package.json b/apps/js-sdk/package.json
index 9bb5c4f2e..563e1e39c 100644
--- a/apps/js-sdk/package.json
+++ b/apps/js-sdk/package.json
@@ -11,7 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
- "@mendable/firecrawl-js": "^0.0.8",
+ "@mendable/firecrawl-js": "^0.0.15",
"axios": "^1.6.8"
}
}