-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathfirecrawl.app.mjs
81 lines (80 loc) · 1.8 KB
/
firecrawl.app.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { axios } from "@pipedream/platform";
export default {
type: "app",
app: "firecrawl",
propDefinitions: {
url: {
type: "string",
label: "URL",
description: "The URL to start crawling from",
},
additionalOptions: {
type: "object",
label: "Additional Options",
description:
"Additional parameters to send in the request. [See the documentation](https://docs.firecrawl.dev/api-reference/endpoint/scrape) for available parameters. Values will be parsed as JSON where applicable.",
optional: true,
},
crawlId: {
type: "string",
label: "Crawl ID",
description: "The ID of a crawl job (e.g. as returned by the **Crawl URL** action)",
},
},
methods: {
_baseUrl() {
return "https://api.firecrawl.dev/v1";
},
_headers() {
return {
Authorization: `Bearer ${this.$auth.api_key}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
crawl(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/crawl",
...opts,
});
},
getCrawlStatus({
crawlId, ...opts
}) {
return this._makeRequest({
path: `/crawl/${crawlId}`,
...opts,
});
},
scrape(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/scrape",
...opts,
});
},
extract(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/extract",
...opts,
});
},
getExtractStatus({
id, ...opts
}) {
return this._makeRequest({
path: `/extract/${id}`,
...opts,
});
},
},
};