@mendable/firecrawl-js 4.42.4 → 4.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/audit-ci.jsonc +16 -1
- package/dist/{chunk-TALYWLKJ.js → chunk-HEXXQWYV.js} +1 -1
- package/dist/index.cjs +29 -1
- package/dist/index.d.cts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +30 -2
- package/dist/{package-NTEZDZT4.js → package-GSILJ5AJ.js} +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/v2/gov.test.ts +66 -0
- package/src/v2/client.ts +14 -0
- package/src/v2/methods/gov.ts +34 -0
- package/src/v2/types.ts +14 -2
package/README.md
CHANGED
|
@@ -191,7 +191,7 @@ const scraped = await app.search('firecrawl changelog', {
|
|
|
191
191
|
```
|
|
192
192
|
|
|
193
193
|
Results are grouped by source: `.web`, `.news` and `.images`. Developer
|
|
194
|
-
category results are served inside `.web`.
|
|
194
|
+
and gov category results are served inside `.web`.
|
|
195
195
|
|
|
196
196
|
Use `categories` to narrow web search to a kind of site:
|
|
197
197
|
|
|
@@ -236,6 +236,26 @@ console.log(evidence.repos); // indexed-status echoes for requested repos
|
|
|
236
236
|
`archived`, `fork`, and `skills: 'only'`. Supplying both `repos` and `sources`
|
|
237
237
|
OR-combines GitHub-backed and documentation results.
|
|
238
238
|
|
|
239
|
+
### Government search
|
|
240
|
+
|
|
241
|
+
Use `govSearch` to search the Firecrawl Government Index: primary
|
|
242
|
+
law and regulatory material from US federal, state, and local government
|
|
243
|
+
sources, including statutes, regulations, codes, court opinions, and other
|
|
244
|
+
government publications. Results come back in the ordinary web-result shape.
|
|
245
|
+
Generic `search('food labeling requirements', { categories: ['gov'] })`
|
|
246
|
+
returns index results inside `.web`; like `developer`, it cannot be combined
|
|
247
|
+
with other categories.
|
|
248
|
+
|
|
249
|
+
```js
|
|
250
|
+
const law = await app.govSearch('food labeling requirements', {
|
|
251
|
+
k: 5,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
for (const result of law.data.web) {
|
|
255
|
+
console.log(result.position, result.title, result.url);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
239
259
|
### Research / paper search
|
|
240
260
|
|
|
241
261
|
Use `app.research` to search Firecrawl's research paper index: ~43M paper
|
package/audit-ci.jsonc
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://github.com/IBM/audit-ci/raw/main/docs/schema.json",
|
|
3
|
-
"low": true
|
|
3
|
+
"low": true,
|
|
4
|
+
"allowlist": [
|
|
5
|
+
// GHSA-vfj7-8cjw-p6xm (braces):
|
|
6
|
+
// Latest published braces is 3.0.3; advisory range is <=3.0.3 and
|
|
7
|
+
// no 3.0.4+ exists on npm. Same-major jest 30.x still resolves
|
|
8
|
+
// 3.0.3 via micromatch. Cannot override to a non-existent version.
|
|
9
|
+
// Owner: team-engineering-reviewers. Tracking: create internal ticket.
|
|
10
|
+
// Expires: 2026-10-17.
|
|
11
|
+
"GHSA-vfj7-8cjw-p6xm",
|
|
12
|
+
// GHSA-hp3w-g68c-fv3c (sprintf-js):
|
|
13
|
+
// Advisory asks for >=1.1.4; latest published sprintf-js is
|
|
14
|
+
// 1.1.3. Cannot override to a non-existent version.
|
|
15
|
+
// Owner: team-engineering-reviewers. Tracking: create internal ticket.
|
|
16
|
+
// Expires: 2026-10-20.
|
|
17
|
+
"GHSA-hp3w-g68c-fv3c"
|
|
18
|
+
]
|
|
4
19
|
}
|
|
@@ -12,7 +12,7 @@ var require_package = __commonJS({
|
|
|
12
12
|
"package.json"(exports, module) {
|
|
13
13
|
module.exports = {
|
|
14
14
|
name: "@mendable/firecrawl-js",
|
|
15
|
-
version: "4.
|
|
15
|
+
version: "4.43.0",
|
|
16
16
|
description: "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
17
17
|
main: "dist/index.js",
|
|
18
18
|
types: "dist/index.d.ts",
|
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,7 @@ var require_package = __commonJS({
|
|
|
39
39
|
"package.json"(exports2, module2) {
|
|
40
40
|
module2.exports = {
|
|
41
41
|
name: "@mendable/firecrawl-js",
|
|
42
|
-
version: "4.
|
|
42
|
+
version: "4.43.0",
|
|
43
43
|
description: "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
44
44
|
main: "dist/index.js",
|
|
45
45
|
types: "dist/index.d.ts",
|
|
@@ -1023,6 +1023,27 @@ async function developerSearch(http, query, options = {}) {
|
|
|
1023
1023
|
}
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
+
// src/v2/methods/gov.ts
|
|
1027
|
+
var ENDPOINT2 = "/v2/search/gov";
|
|
1028
|
+
async function govSearch(http, query, options = {}) {
|
|
1029
|
+
if (!query || !query.trim()) throw new Error("query cannot be empty");
|
|
1030
|
+
try {
|
|
1031
|
+
const response = await http.post(ENDPOINT2, {
|
|
1032
|
+
query,
|
|
1033
|
+
...options.k !== void 0 ? { k: options.k } : {}
|
|
1034
|
+
});
|
|
1035
|
+
if (response.status !== 200 || !response.data?.success) {
|
|
1036
|
+
throwForBadResponse(response, "search the Government Index");
|
|
1037
|
+
}
|
|
1038
|
+
return response.data;
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
if (error?.isAxiosError) {
|
|
1041
|
+
return normalizeAxiosError(error, "search the Government Index");
|
|
1042
|
+
}
|
|
1043
|
+
throw error;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1026
1047
|
// src/v2/methods/map.ts
|
|
1027
1048
|
function prepareMapPayload(url, options) {
|
|
1028
1049
|
if (!url || !url.trim()) throw new Error("URL cannot be empty");
|
|
@@ -2404,6 +2425,13 @@ var FirecrawlClient = class {
|
|
|
2404
2425
|
async developerSearch(query, options = {}) {
|
|
2405
2426
|
return developerSearch(this.http, query, options);
|
|
2406
2427
|
}
|
|
2428
|
+
/**
|
|
2429
|
+
* Search the Government Index: primary law and regulatory material
|
|
2430
|
+
* from US federal, state, and local government sources.
|
|
2431
|
+
*/
|
|
2432
|
+
async govSearch(query, options = {}) {
|
|
2433
|
+
return govSearch(this.http, query, options);
|
|
2434
|
+
}
|
|
2407
2435
|
/**
|
|
2408
2436
|
* Submit feedback for a v2 job.
|
|
2409
2437
|
* @param request Feedback payload with endpoint, job id, rating, and supporting signals.
|
package/dist/index.d.cts
CHANGED
|
@@ -659,6 +659,16 @@ interface DeveloperSearchResponse {
|
|
|
659
659
|
/** Present only when sources were requested. */
|
|
660
660
|
sources?: DeveloperSearchSourceStatus[];
|
|
661
661
|
}
|
|
662
|
+
interface GovSearchOptions {
|
|
663
|
+
/** Total ranked results, 1–100 (default 10). */
|
|
664
|
+
k?: number;
|
|
665
|
+
}
|
|
666
|
+
interface GovSearchResponse {
|
|
667
|
+
success: boolean;
|
|
668
|
+
data: {
|
|
669
|
+
web: SearchResultWeb[];
|
|
670
|
+
};
|
|
671
|
+
}
|
|
662
672
|
interface SearchResultWeb {
|
|
663
673
|
url: string;
|
|
664
674
|
title?: string;
|
|
@@ -814,6 +824,8 @@ interface AlexandriaOptions {
|
|
|
814
824
|
* - `pdf` — restrict results to PDFs (adds `filetype:pdf`).
|
|
815
825
|
* - `developer` — developer-index results (issues, pull requests, READMEs and
|
|
816
826
|
* documentation) served in `web`; cannot be combined with other categories.
|
|
827
|
+
* - `gov` — Government Index results served in `web`; cannot be combined
|
|
828
|
+
* with other categories.
|
|
817
829
|
*
|
|
818
830
|
* ⚠️ `categories: ["research"]` is **not** Firecrawl's research paper index.
|
|
819
831
|
* To search papers themselves — ~43M abstracts, roughly 90% biomedical
|
|
@@ -825,7 +837,7 @@ interface AlexandriaOptions {
|
|
|
825
837
|
* happen to live on academic domains → `search({ categories: ["research"] })`.
|
|
826
838
|
*/
|
|
827
839
|
interface CategoryOption {
|
|
828
|
-
type: "github" | "research" | "pdf" | "developer";
|
|
840
|
+
type: "github" | "research" | "pdf" | "developer" | "gov";
|
|
829
841
|
}
|
|
830
842
|
interface SearchRequest {
|
|
831
843
|
query: string;
|
|
@@ -844,7 +856,7 @@ interface SearchRequest {
|
|
|
844
856
|
* over ~43M paper abstracts (PubMed / bioRxiv / medRxiv / arXiv) use
|
|
845
857
|
* `firecrawl.research.searchPapers()` instead.
|
|
846
858
|
*/
|
|
847
|
-
categories?: Array<"github" | "research" | "pdf" | "developer" | CategoryOption>;
|
|
859
|
+
categories?: Array<"github" | "research" | "pdf" | "developer" | "gov" | CategoryOption>;
|
|
848
860
|
includeDomains?: string[];
|
|
849
861
|
excludeDomains?: string[];
|
|
850
862
|
limit?: number;
|
|
@@ -2323,6 +2335,11 @@ declare class FirecrawlClient {
|
|
|
2323
2335
|
* requested passages, citations, license disclosures, and indexing echoes.
|
|
2324
2336
|
*/
|
|
2325
2337
|
developerSearch(query: string, options?: DeveloperSearchOptions): Promise<DeveloperSearchResponse>;
|
|
2338
|
+
/**
|
|
2339
|
+
* Search the Government Index: primary law and regulatory material
|
|
2340
|
+
* from US federal, state, and local government sources.
|
|
2341
|
+
*/
|
|
2342
|
+
govSearch(query: string, options?: GovSearchOptions): Promise<GovSearchResponse>;
|
|
2326
2343
|
/**
|
|
2327
2344
|
* Submit feedback for a v2 job.
|
|
2328
2345
|
* @param request Feedback payload with endpoint, job id, rating, and supporting signals.
|
|
@@ -3557,4 +3574,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
3557
3574
|
get v1(): FirecrawlApp;
|
|
3558
3575
|
}
|
|
3559
3576
|
|
|
3560
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatInfo, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
|
3577
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type GovSearchOptions, type GovSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatInfo, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
package/dist/index.d.ts
CHANGED
|
@@ -659,6 +659,16 @@ interface DeveloperSearchResponse {
|
|
|
659
659
|
/** Present only when sources were requested. */
|
|
660
660
|
sources?: DeveloperSearchSourceStatus[];
|
|
661
661
|
}
|
|
662
|
+
interface GovSearchOptions {
|
|
663
|
+
/** Total ranked results, 1–100 (default 10). */
|
|
664
|
+
k?: number;
|
|
665
|
+
}
|
|
666
|
+
interface GovSearchResponse {
|
|
667
|
+
success: boolean;
|
|
668
|
+
data: {
|
|
669
|
+
web: SearchResultWeb[];
|
|
670
|
+
};
|
|
671
|
+
}
|
|
662
672
|
interface SearchResultWeb {
|
|
663
673
|
url: string;
|
|
664
674
|
title?: string;
|
|
@@ -814,6 +824,8 @@ interface AlexandriaOptions {
|
|
|
814
824
|
* - `pdf` — restrict results to PDFs (adds `filetype:pdf`).
|
|
815
825
|
* - `developer` — developer-index results (issues, pull requests, READMEs and
|
|
816
826
|
* documentation) served in `web`; cannot be combined with other categories.
|
|
827
|
+
* - `gov` — Government Index results served in `web`; cannot be combined
|
|
828
|
+
* with other categories.
|
|
817
829
|
*
|
|
818
830
|
* ⚠️ `categories: ["research"]` is **not** Firecrawl's research paper index.
|
|
819
831
|
* To search papers themselves — ~43M abstracts, roughly 90% biomedical
|
|
@@ -825,7 +837,7 @@ interface AlexandriaOptions {
|
|
|
825
837
|
* happen to live on academic domains → `search({ categories: ["research"] })`.
|
|
826
838
|
*/
|
|
827
839
|
interface CategoryOption {
|
|
828
|
-
type: "github" | "research" | "pdf" | "developer";
|
|
840
|
+
type: "github" | "research" | "pdf" | "developer" | "gov";
|
|
829
841
|
}
|
|
830
842
|
interface SearchRequest {
|
|
831
843
|
query: string;
|
|
@@ -844,7 +856,7 @@ interface SearchRequest {
|
|
|
844
856
|
* over ~43M paper abstracts (PubMed / bioRxiv / medRxiv / arXiv) use
|
|
845
857
|
* `firecrawl.research.searchPapers()` instead.
|
|
846
858
|
*/
|
|
847
|
-
categories?: Array<"github" | "research" | "pdf" | "developer" | CategoryOption>;
|
|
859
|
+
categories?: Array<"github" | "research" | "pdf" | "developer" | "gov" | CategoryOption>;
|
|
848
860
|
includeDomains?: string[];
|
|
849
861
|
excludeDomains?: string[];
|
|
850
862
|
limit?: number;
|
|
@@ -2323,6 +2335,11 @@ declare class FirecrawlClient {
|
|
|
2323
2335
|
* requested passages, citations, license disclosures, and indexing echoes.
|
|
2324
2336
|
*/
|
|
2325
2337
|
developerSearch(query: string, options?: DeveloperSearchOptions): Promise<DeveloperSearchResponse>;
|
|
2338
|
+
/**
|
|
2339
|
+
* Search the Government Index: primary law and regulatory material
|
|
2340
|
+
* from US federal, state, and local government sources.
|
|
2341
|
+
*/
|
|
2342
|
+
govSearch(query: string, options?: GovSearchOptions): Promise<GovSearchResponse>;
|
|
2326
2343
|
/**
|
|
2327
2344
|
* Submit feedback for a v2 job.
|
|
2328
2345
|
* @param request Feedback payload with endpoint, job id, rating, and supporting signals.
|
|
@@ -3557,4 +3574,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
3557
3574
|
get v1(): FirecrawlApp;
|
|
3558
3575
|
}
|
|
3559
3576
|
|
|
3560
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatInfo, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
|
3577
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type GovSearchOptions, type GovSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatInfo, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
require_package
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HEXXQWYV.js";
|
|
4
4
|
|
|
5
5
|
// src/v2/utils/httpClient.ts
|
|
6
6
|
import axios from "axios";
|
|
@@ -891,6 +891,27 @@ async function developerSearch(http, query, options = {}) {
|
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
893
|
|
|
894
|
+
// src/v2/methods/gov.ts
|
|
895
|
+
var ENDPOINT2 = "/v2/search/gov";
|
|
896
|
+
async function govSearch(http, query, options = {}) {
|
|
897
|
+
if (!query || !query.trim()) throw new Error("query cannot be empty");
|
|
898
|
+
try {
|
|
899
|
+
const response = await http.post(ENDPOINT2, {
|
|
900
|
+
query,
|
|
901
|
+
...options.k !== void 0 ? { k: options.k } : {}
|
|
902
|
+
});
|
|
903
|
+
if (response.status !== 200 || !response.data?.success) {
|
|
904
|
+
throwForBadResponse(response, "search the Government Index");
|
|
905
|
+
}
|
|
906
|
+
return response.data;
|
|
907
|
+
} catch (error) {
|
|
908
|
+
if (error?.isAxiosError) {
|
|
909
|
+
return normalizeAxiosError(error, "search the Government Index");
|
|
910
|
+
}
|
|
911
|
+
throw error;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
894
915
|
// src/v2/methods/map.ts
|
|
895
916
|
function prepareMapPayload(url, options) {
|
|
896
917
|
if (!url || !url.trim()) throw new Error("URL cannot be empty");
|
|
@@ -2272,6 +2293,13 @@ var FirecrawlClient = class {
|
|
|
2272
2293
|
async developerSearch(query, options = {}) {
|
|
2273
2294
|
return developerSearch(this.http, query, options);
|
|
2274
2295
|
}
|
|
2296
|
+
/**
|
|
2297
|
+
* Search the Government Index: primary law and regulatory material
|
|
2298
|
+
* from US federal, state, and local government sources.
|
|
2299
|
+
*/
|
|
2300
|
+
async govSearch(query, options = {}) {
|
|
2301
|
+
return govSearch(this.http, query, options);
|
|
2302
|
+
}
|
|
2275
2303
|
/**
|
|
2276
2304
|
* Submit feedback for a v2 job.
|
|
2277
2305
|
* @param request Feedback payload with endpoint, job id, rating, and supporting signals.
|
|
@@ -2706,7 +2734,7 @@ var FirecrawlApp = class {
|
|
|
2706
2734
|
if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
|
|
2707
2735
|
return process.env.npm_package_version;
|
|
2708
2736
|
}
|
|
2709
|
-
const packageJson = await import("./package-
|
|
2737
|
+
const packageJson = await import("./package-GSILJ5AJ.js");
|
|
2710
2738
|
return packageJson.default.version;
|
|
2711
2739
|
} catch (error) {
|
|
2712
2740
|
const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mendable/firecrawl-js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.43.0",
|
|
4
4
|
"description": "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { describe, expect, jest, test } from "@jest/globals";
|
|
2
|
+
import { FirecrawlClient } from "../../../v2/client";
|
|
3
|
+
|
|
4
|
+
const response = {
|
|
5
|
+
success: true,
|
|
6
|
+
data: {
|
|
7
|
+
web: [
|
|
8
|
+
{
|
|
9
|
+
url: "https://www.ecfr.gov/current/title-21/chapter-I/subchapter-B/part-101",
|
|
10
|
+
title: "21 CFR Part 101 -- Food Labeling",
|
|
11
|
+
description: "matched snippet",
|
|
12
|
+
position: 1,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function clientWith(http: any) {
|
|
19
|
+
const client = new FirecrawlClient({
|
|
20
|
+
apiKey: "test",
|
|
21
|
+
apiUrl: "http://localhost",
|
|
22
|
+
});
|
|
23
|
+
(client as any).http = http;
|
|
24
|
+
return client;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe("govSearch", () => {
|
|
28
|
+
test.each([
|
|
29
|
+
[{ k: 5 }, { query: "food labeling requirements", k: 5 }],
|
|
30
|
+
[undefined, { query: "food labeling requirements" }],
|
|
31
|
+
])("posts %p and returns web results", async (options, body) => {
|
|
32
|
+
const http = {
|
|
33
|
+
post: jest.fn(async () => ({ status: 200, data: response })),
|
|
34
|
+
} as any;
|
|
35
|
+
|
|
36
|
+
const result = await clientWith(http).govSearch(
|
|
37
|
+
"food labeling requirements",
|
|
38
|
+
options,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
expect(http.post).toHaveBeenCalledWith("/v2/search/gov", body);
|
|
42
|
+
expect(result).toEqual(response);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("rejects an empty query", async () => {
|
|
46
|
+
const http = { post: jest.fn() } as any;
|
|
47
|
+
|
|
48
|
+
await expect(clientWith(http).govSearch(" ")).rejects.toThrow(
|
|
49
|
+
"query cannot be empty",
|
|
50
|
+
);
|
|
51
|
+
expect(http.post).not.toHaveBeenCalled();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("throws on an unsuccessful response body", async () => {
|
|
55
|
+
const http = {
|
|
56
|
+
post: jest.fn(async () => ({
|
|
57
|
+
status: 200,
|
|
58
|
+
data: { success: false, error: "Search failed" },
|
|
59
|
+
})),
|
|
60
|
+
} as any;
|
|
61
|
+
|
|
62
|
+
await expect(clientWith(http).govSearch("zoning variance")).rejects.toThrow(
|
|
63
|
+
"Search failed",
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
});
|
package/src/v2/client.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { parse as parseMethod, getParseFormats } from "./methods/parse";
|
|
|
8
8
|
import { search } from "./methods/search";
|
|
9
9
|
import { scrapeAlexandria, findTools } from "./methods/tools";
|
|
10
10
|
import { developerSearch as developerSearchMethod } from "./methods/developer";
|
|
11
|
+
import { govSearch as govSearchMethod } from "./methods/gov";
|
|
11
12
|
import { map as mapMethod } from "./methods/map";
|
|
12
13
|
import { feedback as feedbackMethod, searchFeedback as searchFeedbackMethod } from "./methods/feedback";
|
|
13
14
|
import {
|
|
@@ -60,6 +61,8 @@ import type {
|
|
|
60
61
|
SearchRequest,
|
|
61
62
|
DeveloperSearchOptions,
|
|
62
63
|
DeveloperSearchResponse,
|
|
64
|
+
GovSearchOptions,
|
|
65
|
+
GovSearchResponse,
|
|
63
66
|
EndpointFeedbackRequest,
|
|
64
67
|
FeedbackResponse,
|
|
65
68
|
SearchFeedbackRequest,
|
|
@@ -306,6 +309,17 @@ export class FirecrawlClient {
|
|
|
306
309
|
return developerSearchMethod(this.http, query, options);
|
|
307
310
|
}
|
|
308
311
|
|
|
312
|
+
/**
|
|
313
|
+
* Search the Government Index: primary law and regulatory material
|
|
314
|
+
* from US federal, state, and local government sources.
|
|
315
|
+
*/
|
|
316
|
+
async govSearch(
|
|
317
|
+
query: string,
|
|
318
|
+
options: GovSearchOptions = {},
|
|
319
|
+
): Promise<GovSearchResponse> {
|
|
320
|
+
return govSearchMethod(this.http, query, options);
|
|
321
|
+
}
|
|
322
|
+
|
|
309
323
|
/**
|
|
310
324
|
* Submit feedback for a v2 job.
|
|
311
325
|
* @param request Feedback payload with endpoint, job id, rating, and supporting signals.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { GovSearchOptions, GovSearchResponse } from "../types";
|
|
2
|
+
import { HttpClient } from "../utils/httpClient";
|
|
3
|
+
import {
|
|
4
|
+
normalizeAxiosError,
|
|
5
|
+
throwForBadResponse,
|
|
6
|
+
} from "../utils/errorHandler";
|
|
7
|
+
|
|
8
|
+
const ENDPOINT = "/v2/search/gov";
|
|
9
|
+
|
|
10
|
+
/** Search the Government Index. */
|
|
11
|
+
export async function govSearch(
|
|
12
|
+
http: HttpClient,
|
|
13
|
+
query: string,
|
|
14
|
+
options: GovSearchOptions = {},
|
|
15
|
+
): Promise<GovSearchResponse> {
|
|
16
|
+
if (!query || !query.trim()) throw new Error("query cannot be empty");
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const response = await http.post<GovSearchResponse>(ENDPOINT, {
|
|
20
|
+
query,
|
|
21
|
+
...(options.k !== undefined ? { k: options.k } : {}),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (response.status !== 200 || !response.data?.success) {
|
|
25
|
+
throwForBadResponse(response, "search the Government Index");
|
|
26
|
+
}
|
|
27
|
+
return response.data;
|
|
28
|
+
} catch (error: any) {
|
|
29
|
+
if (error?.isAxiosError) {
|
|
30
|
+
return normalizeAxiosError(error, "search the Government Index");
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/v2/types.ts
CHANGED
|
@@ -806,6 +806,16 @@ export interface DeveloperSearchResponse {
|
|
|
806
806
|
sources?: DeveloperSearchSourceStatus[];
|
|
807
807
|
}
|
|
808
808
|
|
|
809
|
+
export interface GovSearchOptions {
|
|
810
|
+
/** Total ranked results, 1–100 (default 10). */
|
|
811
|
+
k?: number;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
export interface GovSearchResponse {
|
|
815
|
+
success: boolean;
|
|
816
|
+
data: { web: SearchResultWeb[] };
|
|
817
|
+
}
|
|
818
|
+
|
|
809
819
|
export interface SearchResultWeb {
|
|
810
820
|
url: string;
|
|
811
821
|
title?: string;
|
|
@@ -973,6 +983,8 @@ export interface AlexandriaOptions {
|
|
|
973
983
|
* - `pdf` — restrict results to PDFs (adds `filetype:pdf`).
|
|
974
984
|
* - `developer` — developer-index results (issues, pull requests, READMEs and
|
|
975
985
|
* documentation) served in `web`; cannot be combined with other categories.
|
|
986
|
+
* - `gov` — Government Index results served in `web`; cannot be combined
|
|
987
|
+
* with other categories.
|
|
976
988
|
*
|
|
977
989
|
* ⚠️ `categories: ["research"]` is **not** Firecrawl's research paper index.
|
|
978
990
|
* To search papers themselves — ~43M abstracts, roughly 90% biomedical
|
|
@@ -984,7 +996,7 @@ export interface AlexandriaOptions {
|
|
|
984
996
|
* happen to live on academic domains → `search({ categories: ["research"] })`.
|
|
985
997
|
*/
|
|
986
998
|
export interface CategoryOption {
|
|
987
|
-
type: "github" | "research" | "pdf" | "developer";
|
|
999
|
+
type: "github" | "research" | "pdf" | "developer" | "gov";
|
|
988
1000
|
}
|
|
989
1001
|
|
|
990
1002
|
export interface SearchRequest {
|
|
@@ -1006,7 +1018,7 @@ export interface SearchRequest {
|
|
|
1006
1018
|
* `firecrawl.research.searchPapers()` instead.
|
|
1007
1019
|
*/
|
|
1008
1020
|
categories?: Array<
|
|
1009
|
-
"github" | "research" | "pdf" | "developer" | CategoryOption
|
|
1021
|
+
"github" | "research" | "pdf" | "developer" | "gov" | CategoryOption
|
|
1010
1022
|
>;
|
|
1011
1023
|
includeDomains?: string[];
|
|
1012
1024
|
excludeDomains?: string[];
|