@spider-cloud/spider-client 0.0.10 → 0.0.11
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/dist/spiderwebai.d.ts +7 -1
- package/dist/spiderwebai.js +2 -2
- package/package.json +2 -1
package/dist/spiderwebai.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Configuration interface for Spider.
|
|
4
|
+
*/
|
|
5
|
+
export interface SpiderConfig {
|
|
6
|
+
apiKey?: string | null;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* A class to interact with the Spider API.
|
|
4
10
|
*/
|
|
@@ -9,7 +15,7 @@ export default class Spider {
|
|
|
9
15
|
* @param {string | null} apiKey - The API key used to authenticate to the Spider API. If null, attempts to source from environment variables.
|
|
10
16
|
* @throws Will throw an error if the API key is not provided.
|
|
11
17
|
*/
|
|
12
|
-
constructor(apiKey
|
|
18
|
+
constructor({ apiKey }: SpiderConfig);
|
|
13
19
|
/**
|
|
14
20
|
* Internal method to handle POST requests.
|
|
15
21
|
* @param {string} endpoint - The API endpoint to which the POST request should be sent.
|
package/dist/spiderwebai.js
CHANGED
|
@@ -9,7 +9,7 @@ class Spider {
|
|
|
9
9
|
* @param {string | null} apiKey - The API key used to authenticate to the Spider API. If null, attempts to source from environment variables.
|
|
10
10
|
* @throws Will throw an error if the API key is not provided.
|
|
11
11
|
*/
|
|
12
|
-
constructor(apiKey) {
|
|
12
|
+
constructor({ apiKey = null }) {
|
|
13
13
|
this.apiKey = apiKey || process?.env?.SPIDER_API_KEY;
|
|
14
14
|
if (!this.apiKey) {
|
|
15
15
|
throw new Error("No API key provided");
|
|
@@ -64,7 +64,7 @@ class Spider {
|
|
|
64
64
|
* @returns {Promise<any>} The scraped data from the URL.
|
|
65
65
|
*/
|
|
66
66
|
async scrapeUrl(url, params = {}) {
|
|
67
|
-
return this._apiPost("crawl", { url: url,
|
|
67
|
+
return this._apiPost("crawl", { url: url, limit: 1, ...params });
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Initiates a crawling job starting from the specified URL.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spider-cloud/spider-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "A Javascript SDK for Spider Cloud services",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@jest/globals": "^29.7.0",
|
|
25
25
|
"@types/jest": "^29.5.12",
|
|
26
26
|
"@types/node": "20.12.7",
|
|
27
|
+
"dotenv": "^16.4.5",
|
|
27
28
|
"ts-jest": "^29.1.2",
|
|
28
29
|
"typescript": "5.4.5"
|
|
29
30
|
},
|