serpex 2.3.0 → 2.4.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 +74 -36
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -30
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +32 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,21 +15,21 @@ pnpm add serpex
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import { SerpexClient } from
|
|
18
|
+
import { SerpexClient } from "serpex";
|
|
19
19
|
|
|
20
20
|
// Initialize the client with your API key
|
|
21
|
-
const client = new SerpexClient(
|
|
21
|
+
const client = new SerpexClient("your-api-key-here");
|
|
22
22
|
|
|
23
23
|
// Search with auto-routing (recommended)
|
|
24
24
|
const results = await client.search({
|
|
25
|
-
q:
|
|
26
|
-
engine:
|
|
25
|
+
q: "typescript tutorial",
|
|
26
|
+
engine: "auto",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
// Search with specific engine
|
|
30
30
|
const googleResults = await client.search({
|
|
31
|
-
q:
|
|
32
|
-
engine:
|
|
31
|
+
q: "typescript tutorial",
|
|
32
|
+
engine: "google",
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
console.log(results.results[0].title);
|
|
@@ -57,10 +57,7 @@ Extract content from web pages and convert them to LLM-ready markdown data. Acce
|
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
59
|
const results = await client.extract({
|
|
60
|
-
urls: [
|
|
61
|
-
'https://example.com',
|
|
62
|
-
'https://httpbin.org'
|
|
63
|
-
]
|
|
60
|
+
urls: ["https://example.com", "https://httpbin.org"],
|
|
64
61
|
});
|
|
65
62
|
```
|
|
66
63
|
|
|
@@ -116,19 +113,54 @@ interface SearchParams {
|
|
|
116
113
|
q: string;
|
|
117
114
|
|
|
118
115
|
// Optional: Engine selection (defaults to 'auto')
|
|
119
|
-
engine?:
|
|
116
|
+
engine?:
|
|
117
|
+
| "auto"
|
|
118
|
+
| "google"
|
|
119
|
+
| "bing"
|
|
120
|
+
| "duckduckgo"
|
|
121
|
+
| "brave"
|
|
122
|
+
| "yahoo"
|
|
123
|
+
| "yandex";
|
|
120
124
|
|
|
121
|
-
// Optional: Search category (
|
|
122
|
-
category?:
|
|
125
|
+
// Optional: Search category ('web' for general search, 'news' for news articles - always returns latest news)
|
|
126
|
+
category?: "web" | "news";
|
|
123
127
|
|
|
124
|
-
// Optional: Time range filter
|
|
125
|
-
time_range?:
|
|
128
|
+
// Optional: Time range filter (only applicable for 'web' category, ignored for 'news')
|
|
129
|
+
time_range?: "all" | "day" | "week" | "month" | "year";
|
|
126
130
|
|
|
127
131
|
// Optional: Response format
|
|
128
|
-
format?:
|
|
132
|
+
format?: "json" | "csv" | "rss";
|
|
129
133
|
}
|
|
130
134
|
```
|
|
131
135
|
|
|
136
|
+
### News Search Example
|
|
137
|
+
|
|
138
|
+
News search always returns the latest news articles. The `time_range` parameter is ignored for news searches.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// Search for latest news articles
|
|
142
|
+
const newsResults = await client.search({
|
|
143
|
+
q: "artificial intelligence",
|
|
144
|
+
engine: "google",
|
|
145
|
+
category: "news", // Always returns latest news
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
console.log(newsResults.results[0].title);
|
|
149
|
+
console.log(newsResults.results[0].published_date);
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
q: "artificial intelligence",
|
|
153
|
+
engine: "google",
|
|
154
|
+
category: "news",
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
console.log(newsResults.results[0].title);
|
|
158
|
+
console.log(newsResults.results[0].published_date);
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
|
|
132
164
|
## Supported Engines
|
|
133
165
|
|
|
134
166
|
- **auto**: Automatically routes to the best available search engine
|
|
@@ -175,15 +207,15 @@ interface SearchResponse {
|
|
|
175
207
|
The SDK throws `SerpApiException` for API errors:
|
|
176
208
|
|
|
177
209
|
```typescript
|
|
178
|
-
import { SerpexClient, SerpApiException } from
|
|
210
|
+
import { SerpexClient, SerpApiException } from "serpex";
|
|
179
211
|
|
|
180
212
|
try {
|
|
181
|
-
const results = await client.search({ q:
|
|
213
|
+
const results = await client.search({ q: "test query" });
|
|
182
214
|
} catch (error) {
|
|
183
215
|
if (error instanceof SerpApiException) {
|
|
184
|
-
console.log(
|
|
185
|
-
console.log(
|
|
186
|
-
console.log(
|
|
216
|
+
console.log("API Error:", error.message);
|
|
217
|
+
console.log("Status Code:", error.statusCode);
|
|
218
|
+
console.log("Details:", error.details);
|
|
187
219
|
}
|
|
188
220
|
}
|
|
189
221
|
```
|
|
@@ -191,52 +223,57 @@ try {
|
|
|
191
223
|
## Examples
|
|
192
224
|
|
|
193
225
|
### Basic Search
|
|
226
|
+
|
|
194
227
|
```typescript
|
|
195
228
|
const results = await client.search({
|
|
196
|
-
q:
|
|
229
|
+
q: "coffee shops near me",
|
|
197
230
|
});
|
|
198
231
|
```
|
|
199
232
|
|
|
200
233
|
### Advanced Search with Filters
|
|
234
|
+
|
|
201
235
|
```typescript
|
|
202
236
|
const results = await client.search({
|
|
203
|
-
q:
|
|
204
|
-
engine:
|
|
205
|
-
time_range:
|
|
206
|
-
category:
|
|
237
|
+
q: "latest AI news",
|
|
238
|
+
engine: "google",
|
|
239
|
+
time_range: "day",
|
|
240
|
+
category: "web",
|
|
207
241
|
});
|
|
208
242
|
```
|
|
209
243
|
|
|
210
244
|
### Extract Web Content to LLM-Ready Data
|
|
211
245
|
|
|
212
246
|
#### Extract from a Single URL
|
|
247
|
+
|
|
213
248
|
```typescript
|
|
214
249
|
// Extract content from one website
|
|
215
250
|
const result = await client.extract({
|
|
216
|
-
urls: [
|
|
251
|
+
urls: ["https://example.com"],
|
|
217
252
|
});
|
|
218
253
|
|
|
219
254
|
if (result.results[0].success) {
|
|
220
255
|
console.log(`✅ Extracted ${result.results[0].markdown?.length} characters`);
|
|
221
|
-
console.log(
|
|
256
|
+
console.log(
|
|
257
|
+
"Markdown content:",
|
|
258
|
+
result.results[0].markdown?.substring(0, 200) + "..."
|
|
259
|
+
);
|
|
222
260
|
}
|
|
223
261
|
```
|
|
224
262
|
|
|
225
263
|
#### Extract from Multiple URLs (up to 10 at once)
|
|
264
|
+
|
|
226
265
|
```typescript
|
|
227
266
|
// Extract content from multiple websites (up to 10 URLs)
|
|
228
267
|
const extractResults = await client.extract({
|
|
229
|
-
urls: [
|
|
230
|
-
'https://example.com',
|
|
231
|
-
'https://httpbin.org',
|
|
232
|
-
'https://github.com'
|
|
233
|
-
]
|
|
268
|
+
urls: ["https://example.com", "https://httpbin.org", "https://github.com"],
|
|
234
269
|
});
|
|
235
270
|
|
|
236
|
-
console.log(
|
|
271
|
+
console.log(
|
|
272
|
+
`Successfully extracted ${extractResults.metadata.successful_crawls} pages`
|
|
273
|
+
);
|
|
237
274
|
console.log(`Total credits used: ${extractResults.metadata.credits_used}`);
|
|
238
275
|
|
|
239
|
-
extractResults.results.forEach(result => {
|
|
276
|
+
extractResults.results.forEach((result) => {
|
|
240
277
|
if (result.success) {
|
|
241
278
|
console.log(`✅ ${result.url}: ${result.markdown?.length} characters`);
|
|
242
279
|
// Use result.markdown for LLM processing
|
|
@@ -247,6 +284,7 @@ extractResults.results.forEach(result => {
|
|
|
247
284
|
```
|
|
248
285
|
|
|
249
286
|
#### Sample Response
|
|
287
|
+
|
|
250
288
|
```typescript
|
|
251
289
|
// Example response structure
|
|
252
290
|
{
|
|
@@ -273,4 +311,4 @@ extractResults.results.forEach(result => {
|
|
|
273
311
|
|
|
274
312
|
## License
|
|
275
313
|
|
|
276
|
-
MIT
|
|
314
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SearchResponse, SearchParams, SerpApiException } from
|
|
2
|
-
export { SearchResponse, SearchParams, SerpApiException };
|
|
1
|
+
import { SearchResponse, SearchParams, ExtractResponse, ExtractParams, SerpApiException } from "./types";
|
|
2
|
+
export { SearchResponse, SearchParams, ExtractResponse, ExtractParams, SerpApiException, };
|
|
3
3
|
export declare class SerpexClient {
|
|
4
4
|
private baseUrl;
|
|
5
5
|
private apiKey;
|
|
@@ -19,5 +19,11 @@ export declare class SerpexClient {
|
|
|
19
19
|
* @returns Search results
|
|
20
20
|
*/
|
|
21
21
|
search(params: SearchParams): Promise<SearchResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Extract content from web pages
|
|
24
|
+
* @param params - Extraction parameters including URLs to scrape
|
|
25
|
+
* @returns Extraction results
|
|
26
|
+
*/
|
|
27
|
+
extract(params: ExtractParams): Promise<ExtractResponse>;
|
|
22
28
|
}
|
|
23
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACb,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,cAAc,EACd,YAAY,EACZ,eAAe,EACf,aAAa,EACb,gBAAgB,GACjB,CAAC;AAEF,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IAEvB;;;;OAIG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,MAAiC;IAStE;;OAEG;YACW,WAAW;IA4DzB;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;IAiC3D;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;CAoC/D"}
|
package/dist/index.js
CHANGED
|
@@ -9,38 +9,49 @@ class SerpexClient {
|
|
|
9
9
|
* @param apiKey - Your API key from the Serpex dashboard
|
|
10
10
|
* @param baseUrl - Base URL for the API (optional, defaults to production)
|
|
11
11
|
*/
|
|
12
|
-
constructor(apiKey, baseUrl =
|
|
13
|
-
if (!apiKey || typeof apiKey !==
|
|
14
|
-
throw new Error(
|
|
12
|
+
constructor(apiKey, baseUrl = "https://api.serpex.dev") {
|
|
13
|
+
if (!apiKey || typeof apiKey !== "string") {
|
|
14
|
+
throw new Error("API key is required and must be a string");
|
|
15
15
|
}
|
|
16
16
|
this.apiKey = apiKey;
|
|
17
|
-
this.baseUrl = baseUrl.replace(/\/$/,
|
|
17
|
+
this.baseUrl = baseUrl.replace(/\/$/, ""); // Remove trailing slash
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Make an authenticated request to the API
|
|
21
21
|
*/
|
|
22
|
-
async makeRequest(endpoint, params = {}) {
|
|
22
|
+
async makeRequest(endpoint, params = {}, method = "GET") {
|
|
23
23
|
const url = `${this.baseUrl}${endpoint}`;
|
|
24
24
|
const headers = {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
let finalUrl = url;
|
|
29
|
+
let body;
|
|
30
|
+
if (method === "POST") {
|
|
31
|
+
// For POST requests, send params as JSON body
|
|
32
|
+
body = JSON.stringify(params);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// For GET requests, send params as query parameters
|
|
36
|
+
const searchParams = new URLSearchParams();
|
|
37
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
38
|
+
if (value !== undefined && value !== null) {
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
value.forEach((v) => searchParams.append(key, v.toString()));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
searchParams.append(key, value.toString());
|
|
44
|
+
}
|
|
37
45
|
}
|
|
46
|
+
});
|
|
47
|
+
if (searchParams.toString()) {
|
|
48
|
+
finalUrl = `${url}?${searchParams.toString()}`;
|
|
38
49
|
}
|
|
39
|
-
}
|
|
40
|
-
const finalUrl = searchParams.toString() ? `${url}?${searchParams.toString()}` : url;
|
|
50
|
+
}
|
|
41
51
|
const response = await fetch(finalUrl, {
|
|
42
|
-
method
|
|
43
|
-
headers
|
|
52
|
+
method,
|
|
53
|
+
headers,
|
|
54
|
+
body,
|
|
44
55
|
});
|
|
45
56
|
if (!response.ok) {
|
|
46
57
|
let errorData = {};
|
|
@@ -51,7 +62,7 @@ class SerpexClient {
|
|
|
51
62
|
// If we can't parse the error response, use the status text
|
|
52
63
|
errorData = { error: response.statusText };
|
|
53
64
|
}
|
|
54
|
-
throw new types_1.SerpApiException(errorData.error ||
|
|
65
|
+
throw new types_1.SerpApiException(errorData.error || "API request failed", response.status, errorData);
|
|
55
66
|
}
|
|
56
67
|
return response.json();
|
|
57
68
|
}
|
|
@@ -62,23 +73,62 @@ class SerpexClient {
|
|
|
62
73
|
*/
|
|
63
74
|
async search(params) {
|
|
64
75
|
if (!params.q) {
|
|
65
|
-
throw new Error(
|
|
76
|
+
throw new Error("Query parameter (q) is required");
|
|
66
77
|
}
|
|
67
|
-
if (typeof params.q !==
|
|
68
|
-
throw new Error(
|
|
78
|
+
if (typeof params.q !== "string" || params.q.trim().length === 0) {
|
|
79
|
+
throw new Error("Query must be a non-empty string");
|
|
69
80
|
}
|
|
70
81
|
if (params.q.length > 500) {
|
|
71
|
-
throw new Error(
|
|
82
|
+
throw new Error("Query too long (max 500 characters)");
|
|
72
83
|
}
|
|
84
|
+
// Determine endpoint based on category
|
|
85
|
+
const category = params.category || "web";
|
|
86
|
+
const endpoint = category === "news" ? "/api/search/news" : "/api/search";
|
|
73
87
|
// Prepare request parameters with only supported params
|
|
74
88
|
const requestParams = {
|
|
75
89
|
q: params.q,
|
|
76
|
-
engine: params.engine ||
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
engine: params.engine || "auto", // Default to auto
|
|
91
|
+
format: params.format || "json",
|
|
92
|
+
};
|
|
93
|
+
// Add category for web search, omit for news (news endpoint doesn't need it)
|
|
94
|
+
if (category === "web") {
|
|
95
|
+
requestParams.category = "web";
|
|
96
|
+
requestParams.time_range = params.time_range || "all";
|
|
97
|
+
}
|
|
98
|
+
return this.makeRequest(endpoint, requestParams);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Extract content from web pages
|
|
102
|
+
* @param params - Extraction parameters including URLs to scrape
|
|
103
|
+
* @returns Extraction results
|
|
104
|
+
*/
|
|
105
|
+
async extract(params) {
|
|
106
|
+
if (!params.urls ||
|
|
107
|
+
!Array.isArray(params.urls) ||
|
|
108
|
+
params.urls.length === 0) {
|
|
109
|
+
throw new Error("URLs array is required and must contain at least one URL");
|
|
110
|
+
}
|
|
111
|
+
if (params.urls.length > 10) {
|
|
112
|
+
throw new Error("Maximum 10 URLs allowed per request");
|
|
113
|
+
}
|
|
114
|
+
// Validate URLs
|
|
115
|
+
const invalidUrls = params.urls.filter((url) => {
|
|
116
|
+
try {
|
|
117
|
+
new URL(url);
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
if (invalidUrls.length > 0) {
|
|
125
|
+
throw new Error(`Invalid URLs provided: ${invalidUrls.join(", ")}`);
|
|
126
|
+
}
|
|
127
|
+
// Prepare request parameters
|
|
128
|
+
const requestParams = {
|
|
129
|
+
urls: params.urls,
|
|
80
130
|
};
|
|
81
|
-
return this.makeRequest(
|
|
131
|
+
return this.makeRequest("/api/crawl", requestParams, "POST");
|
|
82
132
|
}
|
|
83
133
|
}
|
|
84
134
|
exports.SerpexClient = SerpexClient;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAMiB;AAOf,iGARA,wBAAgB,OAQA;AAGlB,MAAa,YAAY;IAIvB;;;;OAIG;IACH,YAAY,MAAc,EAAE,UAAkB,wBAAwB;QACpE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,wBAAwB;IACrE,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,WAAW,CACvB,QAAgB,EAChB,SAA8B,EAAE,EAChC,SAAiB,KAAK;QAEtB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,QAAQ,EAAE,CAAC;QACzC,MAAM,OAAO,GAA2B;YACtC,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;YACtC,cAAc,EAAE,kBAAkB;SACnC,CAAC;QAEF,IAAI,QAAQ,GAAG,GAAG,CAAC;QACnB,IAAI,IAAwB,CAAC;QAE7B,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACtB,8CAA8C;YAC9C,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CA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AC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,MAAqB;QACjC,IACE,CAAC,MAAM,CAAC,IAAI;YACZ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EACxB,CAAC;YACD,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QAED,gBAAgB;QAChB,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7C,IAAI,CAAC;gBACH,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;gBACb,OAAO,KAAK,CAAC;YACf,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,0BAA0B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,6BAA6B;QAC7B,MAAM,aAAa,GAAwB;YACzC,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC;QAEF,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACF;AAhKD,oCAgKC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface SearchMetadata {
|
|
|
14
14
|
response_time: number;
|
|
15
15
|
timestamp: string;
|
|
16
16
|
credits_used: number;
|
|
17
|
+
category?: string;
|
|
17
18
|
}
|
|
18
19
|
export interface SearchResponse {
|
|
19
20
|
metadata: SearchMetadata;
|
|
@@ -26,12 +27,39 @@ export interface SearchResponse {
|
|
|
26
27
|
infoboxes: any[];
|
|
27
28
|
suggestions: string[];
|
|
28
29
|
}
|
|
30
|
+
export interface ExtractResult {
|
|
31
|
+
url: string;
|
|
32
|
+
success: boolean;
|
|
33
|
+
markdown?: string;
|
|
34
|
+
error?: string;
|
|
35
|
+
error_type?: string;
|
|
36
|
+
status_code?: number;
|
|
37
|
+
crawled_at?: string;
|
|
38
|
+
extraction_mode?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface ExtractMetadata {
|
|
41
|
+
total_urls: number;
|
|
42
|
+
processed_urls: number;
|
|
43
|
+
successful_crawls: number;
|
|
44
|
+
failed_crawls: number;
|
|
45
|
+
credits_used: number;
|
|
46
|
+
response_time: number;
|
|
47
|
+
timestamp: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ExtractResponse {
|
|
50
|
+
success: boolean;
|
|
51
|
+
results: ExtractResult[];
|
|
52
|
+
metadata: ExtractMetadata;
|
|
53
|
+
}
|
|
54
|
+
export interface ExtractParams {
|
|
55
|
+
urls: string[];
|
|
56
|
+
}
|
|
29
57
|
export interface SearchParams {
|
|
30
58
|
q: string;
|
|
31
|
-
engine?:
|
|
32
|
-
category?:
|
|
33
|
-
time_range?:
|
|
34
|
-
format?:
|
|
59
|
+
engine?: "auto" | "google" | "bing" | "duckduckgo" | "brave" | "yahoo" | "yandex";
|
|
60
|
+
category?: "web" | "news";
|
|
61
|
+
time_range?: "all" | "day" | "week" | "month" | "year";
|
|
62
|
+
format?: "json" | "csv" | "rss";
|
|
35
63
|
}
|
|
36
64
|
export interface SerpApiError {
|
|
37
65
|
error: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM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Y;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,OAAO,CAAC,EAAE,GAAG,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAMhE"}
|
package/dist/types.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.SerpApiException = void 0;
|
|
|
6
6
|
class SerpApiException extends Error {
|
|
7
7
|
constructor(message, statusCode, details) {
|
|
8
8
|
super(message);
|
|
9
|
-
this.name =
|
|
9
|
+
this.name = "SerpApiException";
|
|
10
10
|
this.statusCode = statusCode;
|
|
11
11
|
this.details = details;
|
|
12
12
|
}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,qCAAqC;AACrC,uBAAuB;;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,qCAAqC;AACrC,uBAAuB;;;AAkGvB,MAAa,gBAAiB,SAAQ,KAAK;IAIzC,YAAY,OAAe,EAAE,UAAmB,EAAE,OAAa;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAVD,4CAUC"}
|