serpex 2.2.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 +166 -43
- 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 +6 -6
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);
|
|
@@ -51,19 +51,58 @@ new SerpexClient(apiKey: string, baseUrl?: string)
|
|
|
51
51
|
|
|
52
52
|
#### Methods
|
|
53
53
|
|
|
54
|
-
##### `
|
|
54
|
+
##### `extract(params: ExtractParams): Promise<ExtractResponse>`
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Extract content from web pages and convert them to LLM-ready markdown data. Accepts up to 10 URLs per request.
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
|
-
const results = await client.
|
|
60
|
-
|
|
61
|
-
engine: 'auto',
|
|
62
|
-
category: 'web',
|
|
63
|
-
time_range: 'week'
|
|
59
|
+
const results = await client.extract({
|
|
60
|
+
urls: ["https://example.com", "https://httpbin.org"],
|
|
64
61
|
});
|
|
65
62
|
```
|
|
66
63
|
|
|
64
|
+
## Extract Parameters
|
|
65
|
+
|
|
66
|
+
The `ExtractParams` interface supports extraction parameters:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
interface ExtractParams {
|
|
70
|
+
// Required: URLs to extract (max 10)
|
|
71
|
+
urls: string[];
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Extract Response Format
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
interface ExtractResponse {
|
|
79
|
+
success: boolean;
|
|
80
|
+
results: ExtractResult[];
|
|
81
|
+
metadata: ExtractMetadata;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface ExtractResult {
|
|
85
|
+
url: string;
|
|
86
|
+
success: boolean;
|
|
87
|
+
markdown?: string;
|
|
88
|
+
error?: string;
|
|
89
|
+
error_type?: string;
|
|
90
|
+
status_code?: number;
|
|
91
|
+
crawled_at?: string;
|
|
92
|
+
extraction_mode?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface ExtractMetadata {
|
|
96
|
+
total_urls: number;
|
|
97
|
+
processed_urls: number;
|
|
98
|
+
successful_crawls: number;
|
|
99
|
+
failed_crawls: number;
|
|
100
|
+
credits_used: number;
|
|
101
|
+
response_time: number;
|
|
102
|
+
timestamp: string;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
67
106
|
## Search Parameters
|
|
68
107
|
|
|
69
108
|
The `SearchParams` interface supports all search parameters:
|
|
@@ -74,19 +113,54 @@ interface SearchParams {
|
|
|
74
113
|
q: string;
|
|
75
114
|
|
|
76
115
|
// Optional: Engine selection (defaults to 'auto')
|
|
77
|
-
engine?:
|
|
116
|
+
engine?:
|
|
117
|
+
| "auto"
|
|
118
|
+
| "google"
|
|
119
|
+
| "bing"
|
|
120
|
+
| "duckduckgo"
|
|
121
|
+
| "brave"
|
|
122
|
+
| "yahoo"
|
|
123
|
+
| "yandex";
|
|
78
124
|
|
|
79
|
-
// Optional: Search category (
|
|
80
|
-
category?:
|
|
125
|
+
// Optional: Search category ('web' for general search, 'news' for news articles - always returns latest news)
|
|
126
|
+
category?: "web" | "news";
|
|
81
127
|
|
|
82
|
-
// Optional: Time range filter
|
|
83
|
-
time_range?:
|
|
128
|
+
// Optional: Time range filter (only applicable for 'web' category, ignored for 'news')
|
|
129
|
+
time_range?: "all" | "day" | "week" | "month" | "year";
|
|
84
130
|
|
|
85
131
|
// Optional: Response format
|
|
86
|
-
format?:
|
|
132
|
+
format?: "json" | "csv" | "rss";
|
|
87
133
|
}
|
|
88
134
|
```
|
|
89
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
|
+
|
|
90
164
|
## Supported Engines
|
|
91
165
|
|
|
92
166
|
- **auto**: Automatically routes to the best available search engine
|
|
@@ -133,15 +207,15 @@ interface SearchResponse {
|
|
|
133
207
|
The SDK throws `SerpApiException` for API errors:
|
|
134
208
|
|
|
135
209
|
```typescript
|
|
136
|
-
import { SerpexClient, SerpApiException } from
|
|
210
|
+
import { SerpexClient, SerpApiException } from "serpex";
|
|
137
211
|
|
|
138
212
|
try {
|
|
139
|
-
const results = await client.search({ q:
|
|
213
|
+
const results = await client.search({ q: "test query" });
|
|
140
214
|
} catch (error) {
|
|
141
215
|
if (error instanceof SerpApiException) {
|
|
142
|
-
console.log(
|
|
143
|
-
console.log(
|
|
144
|
-
console.log(
|
|
216
|
+
console.log("API Error:", error.message);
|
|
217
|
+
console.log("Status Code:", error.statusCode);
|
|
218
|
+
console.log("Details:", error.details);
|
|
145
219
|
}
|
|
146
220
|
}
|
|
147
221
|
```
|
|
@@ -149,43 +223,92 @@ try {
|
|
|
149
223
|
## Examples
|
|
150
224
|
|
|
151
225
|
### Basic Search
|
|
226
|
+
|
|
152
227
|
```typescript
|
|
153
228
|
const results = await client.search({
|
|
154
|
-
q:
|
|
229
|
+
q: "coffee shops near me",
|
|
155
230
|
});
|
|
156
231
|
```
|
|
157
232
|
|
|
158
233
|
### Advanced Search with Filters
|
|
234
|
+
|
|
159
235
|
```typescript
|
|
160
236
|
const results = await client.search({
|
|
161
|
-
q:
|
|
162
|
-
engine:
|
|
163
|
-
time_range:
|
|
164
|
-
category:
|
|
237
|
+
q: "latest AI news",
|
|
238
|
+
engine: "google",
|
|
239
|
+
time_range: "day",
|
|
240
|
+
category: "web",
|
|
165
241
|
});
|
|
166
242
|
```
|
|
167
243
|
|
|
168
|
-
###
|
|
244
|
+
### Extract Web Content to LLM-Ready Data
|
|
245
|
+
|
|
246
|
+
#### Extract from a Single URL
|
|
247
|
+
|
|
169
248
|
```typescript
|
|
170
|
-
//
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
engine: 'auto'
|
|
249
|
+
// Extract content from one website
|
|
250
|
+
const result = await client.extract({
|
|
251
|
+
urls: ["https://example.com"],
|
|
174
252
|
});
|
|
175
253
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
254
|
+
if (result.results[0].success) {
|
|
255
|
+
console.log(`✅ Extracted ${result.results[0].markdown?.length} characters`);
|
|
256
|
+
console.log(
|
|
257
|
+
"Markdown content:",
|
|
258
|
+
result.results[0].markdown?.substring(0, 200) + "..."
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
#### Extract from Multiple URLs (up to 10 at once)
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
// Extract content from multiple websites (up to 10 URLs)
|
|
267
|
+
const extractResults = await client.extract({
|
|
268
|
+
urls: ["https://example.com", "https://httpbin.org", "https://github.com"],
|
|
180
269
|
});
|
|
181
270
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
271
|
+
console.log(
|
|
272
|
+
`Successfully extracted ${extractResults.metadata.successful_crawls} pages`
|
|
273
|
+
);
|
|
274
|
+
console.log(`Total credits used: ${extractResults.metadata.credits_used}`);
|
|
275
|
+
|
|
276
|
+
extractResults.results.forEach((result) => {
|
|
277
|
+
if (result.success) {
|
|
278
|
+
console.log(`✅ ${result.url}: ${result.markdown?.length} characters`);
|
|
279
|
+
// Use result.markdown for LLM processing
|
|
280
|
+
} else {
|
|
281
|
+
console.log(`❌ ${result.url}: ${result.error}`);
|
|
282
|
+
}
|
|
186
283
|
});
|
|
187
284
|
```
|
|
188
285
|
|
|
286
|
+
#### Sample Response
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
// Example response structure
|
|
290
|
+
{
|
|
291
|
+
success: true,
|
|
292
|
+
results: [
|
|
293
|
+
{
|
|
294
|
+
url: 'https://example.com',
|
|
295
|
+
success: true,
|
|
296
|
+
markdown: '# Example Domain\n\nThis domain is for use in...',
|
|
297
|
+
status_code: 200
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
metadata: {
|
|
301
|
+
total_urls: 1,
|
|
302
|
+
processed_urls: 1,
|
|
303
|
+
successful_crawls: 1,
|
|
304
|
+
failed_crawls: 0,
|
|
305
|
+
credits_used: 3,
|
|
306
|
+
response_time: 255,
|
|
307
|
+
timestamp: '2025-11-13T10:30:00.000Z'
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
189
312
|
## License
|
|
190
313
|
|
|
191
|
-
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,GAA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AO,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,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;
|
|
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,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAA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H,MAAM,GACN,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,OAAO,GACP,OAAO,GACP,QAAQ,CAAC;IAGb,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAG1B,UAAU,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAGvD,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serpex",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Official TypeScript SDK for Serpex
|
|
3
|
+
"version": "2.4.0",
|
|
4
|
+
"description": "Official TypeScript SDK for Serpex search API - Fetch search results in JSON format",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
35
|
-
"url": "https://github.com/divyeshradadiya/
|
|
35
|
+
"url": "https://github.com/divyeshradadiya/serpex-sdk-typescript",
|
|
36
36
|
"directory": "sdk/typescript"
|
|
37
37
|
},
|
|
38
38
|
"bugs": {
|
|
39
|
-
"url": "https://github.com/divyeshradadiya/
|
|
39
|
+
"url": "https://github.com/divyeshradadiya/serpex-sdk-typescript/issues"
|
|
40
40
|
},
|
|
41
|
-
"homepage": "https://github.com/divyeshradadiya/
|
|
41
|
+
"homepage": "https://github.com/divyeshradadiya/serpex-sdk-typescript#readme",
|
|
42
42
|
"files": [
|
|
43
43
|
"dist",
|
|
44
44
|
"README.md",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
],
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/jest": "^29.5.0",
|
|
49
|
-
"@types/node": "^20.
|
|
49
|
+
"@types/node": "^20.19.25",
|
|
50
50
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
51
51
|
"@typescript-eslint/parser": "^6.0.0",
|
|
52
52
|
"eslint": "^8.0.0",
|