serpex 2.2.0 → 2.3.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.
Files changed (2) hide show
  1. package/README.md +105 -20
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -51,19 +51,61 @@ new SerpexClient(apiKey: string, baseUrl?: string)
51
51
 
52
52
  #### Methods
53
53
 
54
- ##### `search(params: SearchParams): Promise<SearchResponse>`
54
+ ##### `extract(params: ExtractParams): Promise<ExtractResponse>`
55
55
 
56
- Search using the SERP API with flexible parameters.
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.search({
60
- q: 'javascript frameworks',
61
- engine: 'auto',
62
- category: 'web',
63
- time_range: 'week'
59
+ const results = await client.extract({
60
+ urls: [
61
+ 'https://example.com',
62
+ 'https://httpbin.org'
63
+ ]
64
64
  });
65
65
  ```
66
66
 
67
+ ## Extract Parameters
68
+
69
+ The `ExtractParams` interface supports extraction parameters:
70
+
71
+ ```typescript
72
+ interface ExtractParams {
73
+ // Required: URLs to extract (max 10)
74
+ urls: string[];
75
+ }
76
+ ```
77
+
78
+ ## Extract Response Format
79
+
80
+ ```typescript
81
+ interface ExtractResponse {
82
+ success: boolean;
83
+ results: ExtractResult[];
84
+ metadata: ExtractMetadata;
85
+ }
86
+
87
+ interface ExtractResult {
88
+ url: string;
89
+ success: boolean;
90
+ markdown?: string;
91
+ error?: string;
92
+ error_type?: string;
93
+ status_code?: number;
94
+ crawled_at?: string;
95
+ extraction_mode?: string;
96
+ }
97
+
98
+ interface ExtractMetadata {
99
+ total_urls: number;
100
+ processed_urls: number;
101
+ successful_crawls: number;
102
+ failed_crawls: number;
103
+ credits_used: number;
104
+ response_time: number;
105
+ timestamp: string;
106
+ }
107
+ ```
108
+
67
109
  ## Search Parameters
68
110
 
69
111
  The `SearchParams` interface supports all search parameters:
@@ -165,27 +207,70 @@ const results = await client.search({
165
207
  });
166
208
  ```
167
209
 
168
- ### Using Different Engines
210
+ ### Extract Web Content to LLM-Ready Data
211
+
212
+ #### Extract from a Single URL
169
213
  ```typescript
170
- // Auto-routing (recommended)
171
- const autoResults = await client.search({
172
- q: 'typescript',
173
- engine: 'auto'
214
+ // Extract content from one website
215
+ const result = await client.extract({
216
+ urls: ['https://example.com']
174
217
  });
175
218
 
176
- // Specific engine
177
- const googleResults = await client.search({
178
- q: 'typescript',
179
- engine: 'google'
219
+ if (result.results[0].success) {
220
+ console.log(`✅ Extracted ${result.results[0].markdown?.length} characters`);
221
+ console.log('Markdown content:', result.results[0].markdown?.substring(0, 200) + '...');
222
+ }
223
+ ```
224
+
225
+ #### Extract from Multiple URLs (up to 10 at once)
226
+ ```typescript
227
+ // Extract content from multiple websites (up to 10 URLs)
228
+ const extractResults = await client.extract({
229
+ urls: [
230
+ 'https://example.com',
231
+ 'https://httpbin.org',
232
+ 'https://github.com'
233
+ ]
180
234
  });
181
235
 
182
- // Privacy-focused search
183
- const ddgResults = await client.search({
184
- q: 'typescript',
185
- engine: 'duckduckgo'
236
+ console.log(`Successfully extracted ${extractResults.metadata.successful_crawls} pages`);
237
+ console.log(`Total credits used: ${extractResults.metadata.credits_used}`);
238
+
239
+ extractResults.results.forEach(result => {
240
+ if (result.success) {
241
+ console.log(`✅ ${result.url}: ${result.markdown?.length} characters`);
242
+ // Use result.markdown for LLM processing
243
+ } else {
244
+ console.log(`❌ ${result.url}: ${result.error}`);
245
+ }
186
246
  });
187
247
  ```
188
248
 
249
+ #### Sample Response
250
+ ```typescript
251
+ // Example response structure
252
+ {
253
+ success: true,
254
+ results: [
255
+ {
256
+ url: 'https://example.com',
257
+ success: true,
258
+ markdown: '# Example Domain\n\nThis domain is for use in...',
259
+ status_code: 200
260
+ }
261
+ ],
262
+ metadata: {
263
+ total_urls: 1,
264
+ processed_urls: 1,
265
+ successful_crawls: 1,
266
+ failed_crawls: 0,
267
+ credits_used: 3,
268
+ response_time: 255,
269
+ timestamp: '2025-11-13T10:30:00.000Z'
270
+ }
271
+ }
272
+ ```
273
+
189
274
  ## License
190
275
 
191
276
  MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "serpex",
3
- "version": "2.2.0",
4
- "description": "Official TypeScript SDK for Serpex SERP API - Fetch search results in JSON format",
3
+ "version": "2.3.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/serp-frontend.git",
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/serp-frontend/issues"
39
+ "url": "https://github.com/divyeshradadiya/serpex-sdk-typescript/issues"
40
40
  },
41
- "homepage": "https://github.com/divyeshradadiya/serp-frontend#readme",
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.0.0",
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",