Nick: urls optional on extract

This commit is contained in:
Nicolas
2025-03-15 22:50:19 -04:00
parent ca93ba6c6d
commit f1206e4870
5 changed files with 58 additions and 13 deletions
+3 -3
View File
@@ -1119,14 +1119,14 @@ export default class FirecrawlApp {
/**
* Extracts information from URLs using the Firecrawl API.
* Currently in Beta. Expect breaking changes on future minor versions.
* @param url - The URL to extract information from.
* @param urls - The URLs to extract information from. Optional if using other methods for data extraction.
* @param params - Additional parameters for the extract request.
* @returns The response from the extract operation.
*/
async extract<T extends zt.ZodSchema = any>(urls: string[], params?: ExtractParams<T>): Promise<ExtractResponse<zt.infer<T>> | ErrorResponse> {
async extract<T extends zt.ZodSchema = any>(urls?: string[], params?: ExtractParams<T>): Promise<ExtractResponse<zt.infer<T>> | ErrorResponse> {
const headers = this.prepareHeaders();
let jsonData: { urls: string[] } & ExtractParams<T> = { urls, ...params };
let jsonData: { urls?: string[] } & ExtractParams<T> = { urls: urls || [], ...params };
let jsonSchema: any;
try {
if (!params?.schema) {