qwksearch-api-client 0.0.7 → 0.0.9
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 → README.md} +54 -48
- package/package.json +1 -1
package/{readme.md → README.md}
RENAMED
|
@@ -298,48 +298,51 @@ GET /search?q={query}&cat={category}&recency={filter}&lang={language}
|
|
|
298
298
|
#### Example Usage
|
|
299
299
|
|
|
300
300
|
```javascript
|
|
301
|
+
import * as qwk from 'qwksearch-api-client';
|
|
302
|
+
|
|
301
303
|
// Basic search
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
+
const searchResults = await qwk.searchWeb({
|
|
305
|
+
query: {
|
|
306
|
+
q: 'quantum computing'
|
|
307
|
+
}
|
|
308
|
+
});
|
|
304
309
|
|
|
305
|
-
results.forEach(result => {
|
|
310
|
+
searchResults.results.forEach(result => {
|
|
306
311
|
console.log(result.title, result.url);
|
|
307
312
|
});
|
|
308
313
|
|
|
309
314
|
// Advanced search
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
```python
|
|
322
|
-
# Python example
|
|
323
|
-
import requests
|
|
324
|
-
|
|
325
|
-
# News search
|
|
326
|
-
response = requests.get('https://qwksearch.com/api/search', params={
|
|
327
|
-
'q': 'artificial intelligence',
|
|
328
|
-
'cat': 'news',
|
|
329
|
-
'recency': 'week',
|
|
330
|
-
'page': 1
|
|
331
|
-
})
|
|
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
|
+
});
|
|
332
324
|
|
|
333
|
-
|
|
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
334
|
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
newsResults.results.forEach(item => {
|
|
336
|
+
console.log(`${item.title}\n${item.url}\n${item.snippet}\n`);
|
|
337
|
+
});
|
|
337
338
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
339
|
+
// Video search
|
|
340
|
+
const videoResults = await qwk.searchWeb({
|
|
341
|
+
query: {
|
|
342
|
+
q: 'machine learning tutorial',
|
|
343
|
+
cat: 'videos'
|
|
344
|
+
}
|
|
345
|
+
});
|
|
343
346
|
```
|
|
344
347
|
|
|
345
348
|
---
|
|
@@ -365,18 +368,16 @@ pip install qwksearch-api-client
|
|
|
365
368
|
Combine all three endpoints to create a complete research pipeline:
|
|
366
369
|
|
|
367
370
|
```javascript
|
|
368
|
-
import
|
|
369
|
-
|
|
370
|
-
const client = new QwkSearchClient({
|
|
371
|
-
groqApiKey: process.env.GROQ_API_KEY
|
|
372
|
-
});
|
|
371
|
+
import * as qwk from 'qwksearch-api-client';
|
|
373
372
|
|
|
374
373
|
async function researchTopic(topic) {
|
|
375
374
|
// 1. Search for relevant articles
|
|
376
|
-
const searchResults = await
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
375
|
+
const searchResults = await qwk.searchWeb({
|
|
376
|
+
query: {
|
|
377
|
+
q: topic,
|
|
378
|
+
cat: 'science',
|
|
379
|
+
recency: 'month'
|
|
380
|
+
}
|
|
380
381
|
});
|
|
381
382
|
|
|
382
383
|
console.log(`Found ${searchResults.results.length} results`);
|
|
@@ -384,8 +385,10 @@ async function researchTopic(topic) {
|
|
|
384
385
|
// 2. Extract content from top 3 results
|
|
385
386
|
const articles = await Promise.all(
|
|
386
387
|
searchResults.results.slice(0, 3).map(async (result) => {
|
|
387
|
-
const content = await
|
|
388
|
-
|
|
388
|
+
const content = await qwk.extractContent({
|
|
389
|
+
query: {
|
|
390
|
+
url: result.url
|
|
391
|
+
}
|
|
389
392
|
});
|
|
390
393
|
return content;
|
|
391
394
|
})
|
|
@@ -396,10 +399,13 @@ async function researchTopic(topic) {
|
|
|
396
399
|
.map(a => `${a.title}\n\n${a.html}`)
|
|
397
400
|
.join('\n\n---\n\n');
|
|
398
401
|
|
|
399
|
-
const summary = await
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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
|
+
}
|
|
403
409
|
});
|
|
404
410
|
|
|
405
411
|
return {
|