qwksearch-api-client 0.0.9 → 0.0.10
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 +58 -175
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ QwkSearch API provides three core services for AI-powered research and content a
|
|
|
20
20
|
|
|
21
21
|
1. **Content Extraction** - Extract structured content and citations from any URL
|
|
22
22
|
2. **Language Generation** - Generate AI responses using multiple language model providers
|
|
23
|
-
3. **Web Search** - Search the web using
|
|
23
|
+
3. **Web Search** - Search the web using metasearch engine across 100+ sources
|
|
24
24
|
|
|
25
25
|
## Base URL
|
|
26
26
|
|
|
@@ -60,59 +60,66 @@ GET /extract?url={url}&images={boolean}&links={boolean}
|
|
|
60
60
|
| `absoluteURLs` | boolean | No | true | Convert relative URLs to absolute |
|
|
61
61
|
| `timeout` | integer | No | 5 | HTTP request timeout (1-30 seconds) |
|
|
62
62
|
|
|
63
|
-
#### Response
|
|
64
63
|
|
|
65
|
-
**200 OK**
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
"title": "Article or video title",
|
|
70
|
-
"html": "Simplified HTML content with standardized structure",
|
|
71
|
-
"cite": "Author Last, F. I. (2024). Title. Source.",
|
|
72
|
-
"author_cite": "Last, First Middle",
|
|
73
|
-
"author_short": "Last",
|
|
74
|
-
"author_type": "single|two-author|more-than-two|organization",
|
|
75
|
-
"author": "Original author string from source",
|
|
76
|
-
"date": "2024-01-15",
|
|
77
|
-
"source": "Publishing organization/site name",
|
|
78
|
-
"word_count": 1234,
|
|
79
|
-
"url": "https://canonical-url.com"
|
|
80
|
-
}
|
|
81
|
-
```
|
|
65
|
+
## Complete Example: Research Pipeline
|
|
82
66
|
|
|
83
|
-
|
|
67
|
+
Combine all three endpoints to create a complete research pipeline:
|
|
84
68
|
|
|
85
69
|
```javascript
|
|
86
70
|
import * as qwk from 'qwksearch-api-client';
|
|
87
71
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const youtubeContent = await qwk.extractContent({
|
|
98
|
-
query: {
|
|
99
|
-
url: 'https://youtube.com/watch?v=example',
|
|
100
|
-
images: false,
|
|
101
|
-
timeout: 10
|
|
102
|
-
}
|
|
103
|
-
});
|
|
72
|
+
async function researchTopic(topic) {
|
|
73
|
+
// 1. Search for relevant articles
|
|
74
|
+
const searchResults = await qwk.searchWeb({
|
|
75
|
+
query: {
|
|
76
|
+
q: topic,
|
|
77
|
+
cat: 'science',
|
|
78
|
+
recency: 'month'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
104
81
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
82
|
+
console.log(`Found ${searchResults.results.length} results`);
|
|
83
|
+
|
|
84
|
+
// 2. Extract content from top 3 results
|
|
85
|
+
const articles = await Promise.all(
|
|
86
|
+
searchResults.results.slice(0, 3).map(async (result) => {
|
|
87
|
+
const content = await qwk.extractContent({
|
|
88
|
+
query: {
|
|
89
|
+
url: result.url
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
return content;
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
// 3. Generate summary of all articles
|
|
97
|
+
const combinedText = articles
|
|
98
|
+
.map(a => `${a.title}\n\n${a.html}`)
|
|
99
|
+
.join('\n\n---\n\n');
|
|
100
|
+
|
|
101
|
+
const summary = await qwk.writeLanguage({
|
|
102
|
+
body: {
|
|
103
|
+
provider: 'groq',
|
|
104
|
+
key: process.env.GROQ_API_KEY,
|
|
105
|
+
agent: 'summarize-bullets',
|
|
106
|
+
article: combinedText
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
searchResults: searchResults.results,
|
|
112
|
+
articles,
|
|
113
|
+
summary: summary.content
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Run the research pipeline
|
|
118
|
+
researchTopic('quantum computing applications')
|
|
119
|
+
.then(results => {
|
|
120
|
+
console.log('Research Summary:');
|
|
121
|
+
console.log(results.summary);
|
|
122
|
+
});
|
|
116
123
|
```
|
|
117
124
|
|
|
118
125
|
---
|
|
@@ -198,7 +205,7 @@ Content-Type: application/json
|
|
|
198
205
|
import * as qwk from 'qwksearch-api-client';
|
|
199
206
|
|
|
200
207
|
// Question answering
|
|
201
|
-
const response = await qwk.
|
|
208
|
+
const response = await qwk.writeLanguage({
|
|
202
209
|
body: {
|
|
203
210
|
provider: 'groq',
|
|
204
211
|
key: process.env.GROQ_API_KEY,
|
|
@@ -212,7 +219,7 @@ const { content } = response;
|
|
|
212
219
|
console.log(content);
|
|
213
220
|
|
|
214
221
|
// Summarize article
|
|
215
|
-
const summary = await qwk.
|
|
222
|
+
const summary = await qwk.writeLanguage({
|
|
216
223
|
body: {
|
|
217
224
|
provider: 'anthropic',
|
|
218
225
|
key: process.env.ANTHROPIC_API_KEY,
|
|
@@ -223,7 +230,7 @@ const summary = await qwk.generateLanguage({
|
|
|
223
230
|
});
|
|
224
231
|
|
|
225
232
|
// Answer with citations
|
|
226
|
-
const answer = await qwk.
|
|
233
|
+
const answer = await qwk.writeLanguage({
|
|
227
234
|
body: {
|
|
228
235
|
provider: 'openai',
|
|
229
236
|
key: process.env.OPENAI_API_KEY,
|
|
@@ -240,7 +247,7 @@ console.log(answer.content);
|
|
|
240
247
|
|
|
241
248
|
### 3. Search Web (`/search`)
|
|
242
249
|
|
|
243
|
-
Search the web using
|
|
250
|
+
Search the web using metasearch engine aggregating 100+ search sources.
|
|
244
251
|
|
|
245
252
|
#### Features
|
|
246
253
|
|
|
@@ -249,13 +256,8 @@ Search the web using SearXNG metasearch engine aggregating 100+ search sources.
|
|
|
249
256
|
- **Recency Filters**: Filter by day, week, month, year
|
|
250
257
|
- **Multi-Language**: Support for various languages
|
|
251
258
|
- **Diverse Sources**: Aggregates from 100+ search engines
|
|
252
|
-
|
|
253
|
-
#### Stats
|
|
254
|
-
|
|
255
|
-
- Google processes 90% of web searches: 13.6 billion daily (~5 trillion/year)
|
|
256
259
|
- Search index exceeds 100,000,000 GB covering 130 trillion pages
|
|
257
260
|
- Uses 200+ ranking factors including keywords, backlinks, page speed
|
|
258
|
-
- Top organic result gets ~22% of clicks
|
|
259
261
|
|
|
260
262
|
#### Request
|
|
261
263
|
|
|
@@ -295,58 +297,6 @@ GET /search?q={query}&cat={category}&recency={filter}&lang={language}
|
|
|
295
297
|
}
|
|
296
298
|
```
|
|
297
299
|
|
|
298
|
-
#### Example Usage
|
|
299
|
-
|
|
300
|
-
```javascript
|
|
301
|
-
import * as qwk from 'qwksearch-api-client';
|
|
302
|
-
|
|
303
|
-
// Basic search
|
|
304
|
-
const searchResults = await qwk.searchWeb({
|
|
305
|
-
query: {
|
|
306
|
-
q: 'quantum computing'
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
searchResults.results.forEach(result => {
|
|
311
|
-
console.log(result.title, result.url);
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
// Advanced search
|
|
315
|
-
const scienceResults = await qwk.searchWeb({
|
|
316
|
-
query: {
|
|
317
|
-
q: 'climate change',
|
|
318
|
-
cat: 'science',
|
|
319
|
-
recency: 'month',
|
|
320
|
-
lang: 'en-US',
|
|
321
|
-
page: 1
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
// News search
|
|
326
|
-
const newsResults = await qwk.searchWeb({
|
|
327
|
-
query: {
|
|
328
|
-
q: 'artificial intelligence',
|
|
329
|
-
cat: 'news',
|
|
330
|
-
recency: 'week',
|
|
331
|
-
page: 1
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
newsResults.results.forEach(item => {
|
|
336
|
-
console.log(`${item.title}\n${item.url}\n${item.snippet}\n`);
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
// Video search
|
|
340
|
-
const videoResults = await qwk.searchWeb({
|
|
341
|
-
query: {
|
|
342
|
-
q: 'machine learning tutorial',
|
|
343
|
-
cat: 'videos'
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
---
|
|
349
|
-
|
|
350
300
|
## Installation
|
|
351
301
|
|
|
352
302
|
### NPM Package
|
|
@@ -355,75 +305,8 @@ const videoResults = await qwk.searchWeb({
|
|
|
355
305
|
npm install qwksearch-api-client
|
|
356
306
|
```
|
|
357
307
|
|
|
358
|
-
### Python Package
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
pip install qwksearch-api-client
|
|
362
|
-
```
|
|
363
|
-
|
|
364
308
|
---
|
|
365
309
|
|
|
366
|
-
## Complete Example: Research Pipeline
|
|
367
|
-
|
|
368
|
-
Combine all three endpoints to create a complete research pipeline:
|
|
369
|
-
|
|
370
|
-
```javascript
|
|
371
|
-
import * as qwk from 'qwksearch-api-client';
|
|
372
|
-
|
|
373
|
-
async function researchTopic(topic) {
|
|
374
|
-
// 1. Search for relevant articles
|
|
375
|
-
const searchResults = await qwk.searchWeb({
|
|
376
|
-
query: {
|
|
377
|
-
q: topic,
|
|
378
|
-
cat: 'science',
|
|
379
|
-
recency: 'month'
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
console.log(`Found ${searchResults.results.length} results`);
|
|
384
|
-
|
|
385
|
-
// 2. Extract content from top 3 results
|
|
386
|
-
const articles = await Promise.all(
|
|
387
|
-
searchResults.results.slice(0, 3).map(async (result) => {
|
|
388
|
-
const content = await qwk.extractContent({
|
|
389
|
-
query: {
|
|
390
|
-
url: result.url
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
return content;
|
|
394
|
-
})
|
|
395
|
-
);
|
|
396
|
-
|
|
397
|
-
// 3. Generate summary of all articles
|
|
398
|
-
const combinedText = articles
|
|
399
|
-
.map(a => `${a.title}\n\n${a.html}`)
|
|
400
|
-
.join('\n\n---\n\n');
|
|
401
|
-
|
|
402
|
-
const summary = await qwk.generateLanguage({
|
|
403
|
-
body: {
|
|
404
|
-
provider: 'groq',
|
|
405
|
-
key: process.env.GROQ_API_KEY,
|
|
406
|
-
agent: 'summarize-bullets',
|
|
407
|
-
article: combinedText
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
return {
|
|
412
|
-
searchResults: searchResults.results,
|
|
413
|
-
articles,
|
|
414
|
-
summary: summary.content
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// Run the research pipeline
|
|
419
|
-
researchTopic('quantum computing applications')
|
|
420
|
-
.then(results => {
|
|
421
|
-
console.log('Research Summary:');
|
|
422
|
-
console.log(results.summary);
|
|
423
|
-
});
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
---
|
|
427
310
|
|
|
428
311
|
|
|
429
312
|
## Links
|
|
@@ -440,6 +323,6 @@ researchTopic('quantum computing applications')
|
|
|
440
323
|
- [Transformer Overview](https://jalammar.github.io/illustrated-transformer/)
|
|
441
324
|
- [Building Transformer Guide](https://www.datacamp.com/tutorial/building-a-transformer-with-py-torch)
|
|
442
325
|
- [PyTorch Overview](https://www.learnpytorch.io/pytorch_cheatsheet/)
|
|
443
|
-
- [SearXNG Overview](https://medium.com/@elmo92/search-in-peace-with
|
|
326
|
+
- [SearXNG Overview](https://medium.com/@elmo92/search-in-peace-with--an-alternative-search-engine-that-keeps-your-searches-private-accd8cddd6fc)
|
|
444
327
|
|
|
445
328
|
---
|