qwksearch-api-client 0.0.6 → 0.0.8

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 +445 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,445 @@
1
+ # QwkSearch API Client
2
+
3
+ <p align="center">
4
+ <img src="https://qwksearch.com/icons/qwksearch-logo.png" alt="QwkSearch Logo" width="200"/>
5
+ </p>
6
+
7
+ <p align="center">
8
+ <strong>Search, extract, vectorize and outline a topic base with AI Research Agent</strong>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://qwksearch.com">Demo</a> •
13
+ <a href="https://airesearch.js.org">Documentation</a> •
14
+ <a href="https://github.com/vtempest/ai-research-agent">GitHub</a>
15
+ </p>
16
+
17
+ ## Overview
18
+
19
+ QwkSearch API provides three core services for AI-powered research and content analysis:
20
+
21
+ 1. **Content Extraction** - Extract structured content and citations from any URL
22
+ 2. **Language Generation** - Generate AI responses using multiple language model providers
23
+ 3. **Web Search** - Search the web using SearXNG metasearch engine across 100+ sources
24
+
25
+ ## Base URL
26
+
27
+ ```
28
+ https://qwksearch.com/api
29
+ ```
30
+
31
+ ## API Endpoints
32
+
33
+ ### 1. Extract Content (`/extract`)
34
+
35
+ Extract structured content, citations, and metadata from any URL including articles, PDFs, and YouTube videos.
36
+
37
+ #### Features
38
+
39
+ - **Main Content Detection**: Combines Mozilla Readability and Postlight Mercury algorithms with 100+ custom adapters
40
+ - **HTML Standardization**: Transforms complex HTML into simplified reading-mode format
41
+ - **YouTube Transcripts**: Retrieves complete video transcripts with timestamps
42
+ - **PDF Processing**: Extracts formatted text and infers heading hierarchy
43
+ - **Citation Extraction**: Identifies author names, publication dates, sources, and titles
44
+ - **Author Formatting**: Validates against 90,000+ name database for proper citation formatting
45
+
46
+ #### Request
47
+
48
+ ```http
49
+ GET /extract?url={url}&images={boolean}&links={boolean}
50
+ ```
51
+
52
+ **Parameters:**
53
+
54
+ | Parameter | Type | Required | Default | Description |
55
+ |-----------|------|----------|---------|-------------|
56
+ | `url` | string (uri) | Yes | - | URL to extract content from |
57
+ | `images` | boolean | No | true | Include images in output |
58
+ | `links` | boolean | No | true | Include hyperlinks in output |
59
+ | `formatting` | boolean | No | true | Preserve text formatting |
60
+ | `absoluteURLs` | boolean | No | true | Convert relative URLs to absolute |
61
+ | `timeout` | integer | No | 5 | HTTP request timeout (1-30 seconds) |
62
+
63
+ #### Response
64
+
65
+ **200 OK**
66
+
67
+ ```json
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
+ ```
82
+
83
+ #### Example Usage
84
+
85
+ ```javascript
86
+ import * as qwk from 'qwksearch-api-client';
87
+
88
+ // Basic extraction
89
+ const data = await qwk.extractContent({
90
+ query: {
91
+ url: 'https://example.com/article'
92
+ }
93
+ });
94
+ console.log(data.title, data.html, data.cite);
95
+
96
+ // With options
97
+ const youtubeContent = await qwk.extractContent({
98
+ query: {
99
+ url: 'https://youtube.com/watch?v=example',
100
+ images: false,
101
+ timeout: 10
102
+ }
103
+ });
104
+
105
+ // Extract PDF content
106
+ const pdfContent = await qwk.extractContent({
107
+ query: {
108
+ url: 'https://example.com/article.pdf',
109
+ images: true,
110
+ links: true
111
+ }
112
+ });
113
+ console.log(`Title: ${pdfContent.title}`);
114
+ console.log(`Citation: ${pdfContent.cite}`);
115
+ console.log(`Words: ${pdfContent.word_count}`);
116
+ ```
117
+
118
+ ---
119
+
120
+ ### 2. Generate Language (`/agents`)
121
+
122
+ Generate AI responses using various language model providers with pre-built agent templates.
123
+
124
+ #### Language Intelligence Providers (LIPs)
125
+
126
+ | Provider | Model Families | Cost (1M Output) | Valuation |
127
+ |----------|----------------|------------------|-----------|
128
+ | **Groq** | Llama, DeepSeek, Gemini, Mistral | $0.79 | $2.8B |
129
+ | **Ollama** | llama, mistral, mixtral, gemma, qwen, deepseek | $0 (local) | - |
130
+ | **OpenAI** | o1, o4, gpt-4, gpt-4-turbo, gpt-4-omni | $8.00 | $300B |
131
+ | **Anthropic** | Claude Sonnet, Opus, Haiku | $15.00 | $61.5B |
132
+ | **TogetherAI** | Llama, Mistral, Qwen, DeepSeek | $0.90 | $3.3B |
133
+ | **Perplexity** | Sonar, Sonar Deep Research | $15.00 | $18B |
134
+ | **XAI** | Grok, Grok Vision | $15.00 | $80B |
135
+ | **Google** | Gemini | $10.00 | - |
136
+ | **Cloudflare** | Llama, Gemma, Mistral, Phi, Qwen | $2.25 | $62.3B |
137
+
138
+ #### Agent Templates
139
+
140
+ | Agent | Context Variables | Description |
141
+ |-------|------------------|-------------|
142
+ | `question` | query, chat_history | Answer questions with conversation context |
143
+ | `summarize-bullets` | article | Create bullet-point summaries |
144
+ | `summarize` | article | Generate narrative summaries |
145
+ | `suggest-followups` | chat_history, article | Suggest follow-up questions (returns string[]) |
146
+ | `answer-cite-sources` | context, chat_history, query | Answer with source citations |
147
+ | `query-resolution` | chat_history, query | Resolve ambiguous queries |
148
+ | `knowledge-graph-nodes` | query, article | Extract knowledge graph nodes |
149
+ | `summary-longtext` | summaries | Summarize multiple summaries |
150
+
151
+ #### Request
152
+
153
+ ```http
154
+ POST /agents
155
+ Content-Type: application/json
156
+
157
+ {
158
+ "provider": "groq",
159
+ "key": "your-api-key",
160
+ "agent": "question",
161
+ "model": "llama-3.3-70b-versatile",
162
+ "query": "What is quantum computing?",
163
+ "temperature": 1.0,
164
+ "html": true
165
+ }
166
+ ```
167
+
168
+ **Body Parameters:**
169
+
170
+ | Parameter | Type | Required | Default | Description |
171
+ |-----------|------|----------|---------|-------------|
172
+ | `provider` | string | Yes | - | LIP provider: groq, openai, anthropic, together, xai, google, perplexity, ollama, cloudflare |
173
+ | `key` | string | Yes | - | API key for the provider |
174
+ | `agent` | string | No | question | Agent template name |
175
+ | `model` | string | No | llama-4-maverick-17b | Model name for the provider |
176
+ | `html` | boolean | No | true | Format response as HTML (true) or Markdown (false) |
177
+ | `temperature` | number | No | 1.0 | 0-1: deterministic, 1-2: creative |
178
+ | `query` | string | No | - | Query text for certain agents |
179
+ | `chat_history` | string | No | - | Conversation history for certain agents |
180
+ | `article` | string | No | - | Article text for summarization agents |
181
+
182
+ #### Response
183
+
184
+ **200 OK**
185
+
186
+ ```json
187
+ {
188
+ "content": "Generated response in HTML or Markdown format",
189
+ "extract": {
190
+ "structured": "data"
191
+ }
192
+ }
193
+ ```
194
+
195
+ #### Example Usage
196
+
197
+ ```javascript
198
+ import * as qwk from 'qwksearch-api-client';
199
+
200
+ // Question answering
201
+ const response = await qwk.generateLanguage({
202
+ body: {
203
+ provider: 'groq',
204
+ key: process.env.GROQ_API_KEY,
205
+ agent: 'question',
206
+ query: 'Explain neural networks',
207
+ temperature: 0.7
208
+ }
209
+ });
210
+
211
+ const { content } = response;
212
+ console.log(content);
213
+
214
+ // Summarize article
215
+ const summary = await qwk.generateLanguage({
216
+ body: {
217
+ provider: 'anthropic',
218
+ key: process.env.ANTHROPIC_API_KEY,
219
+ agent: 'summarize-bullets',
220
+ article: articleText,
221
+ html: false // Get Markdown
222
+ }
223
+ });
224
+
225
+ // Answer with citations
226
+ const answer = await qwk.generateLanguage({
227
+ body: {
228
+ provider: 'openai',
229
+ key: process.env.OPENAI_API_KEY,
230
+ agent: 'answer-cite-sources',
231
+ query: 'What causes climate change?',
232
+ context: 'Scientific articles about greenhouse gases...',
233
+ temperature: 0.5
234
+ }
235
+ });
236
+ console.log(answer.content);
237
+ ```
238
+
239
+ ---
240
+
241
+ ### 3. Search Web (`/search`)
242
+
243
+ Search the web using SearXNG metasearch engine aggregating 100+ search sources.
244
+
245
+ #### Features
246
+
247
+ - **Privacy-Focused**: No tracking or personal data collection
248
+ - **Multiple Categories**: General, news, videos, images, science, files, IT
249
+ - **Recency Filters**: Filter by day, week, month, year
250
+ - **Multi-Language**: Support for various languages
251
+ - **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
+ - Search index exceeds 100,000,000 GB covering 130 trillion pages
257
+ - Uses 200+ ranking factors including keywords, backlinks, page speed
258
+ - Top organic result gets ~22% of clicks
259
+
260
+ #### Request
261
+
262
+ ```http
263
+ GET /search?q={query}&cat={category}&recency={filter}&lang={language}
264
+ ```
265
+
266
+ **Parameters:**
267
+
268
+ | Parameter | Type | Required | Default | Description |
269
+ |-----------|------|----------|---------|-------------|
270
+ | `q` | string | Yes | - | Search query string |
271
+ | `cat` | string | No | general | Category: general, news, videos, images, science, files, it |
272
+ | `recency` | string | No | all | Time filter: all, day, week, month, year |
273
+ | `safesearch` | boolean | No | false | Block adult content |
274
+ | `public` | boolean | No | false | Use public server instances |
275
+ | `page` | integer | No | 1 | Pagination for results |
276
+ | `lang` | string | No | en-US | Language code |
277
+
278
+ #### Response
279
+
280
+ **200 OK**
281
+
282
+ ```json
283
+ {
284
+ "results": [
285
+ {
286
+ "title": "Search result title",
287
+ "url": "https://example.com/page",
288
+ "snippet": "Text snippet around the query...",
289
+ "domain": "example.com",
290
+ "favicon": "https://example.com/favicon.ico",
291
+ "path": "/page",
292
+ "engines": "google,bing"
293
+ }
294
+ ]
295
+ }
296
+ ```
297
+
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
+ ## Installation
351
+
352
+ ### NPM Package
353
+
354
+ ```bash
355
+ npm install qwksearch-api-client
356
+ ```
357
+
358
+ ### Python Package
359
+
360
+ ```bash
361
+ pip install qwksearch-api-client
362
+ ```
363
+
364
+ ---
365
+
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
+
428
+
429
+ ## Links
430
+
431
+ - **Documentation**: [airesearch.js.org](https://airesearch.js.org/)
432
+ - **Demo**: [qwksearch.com](https://qwksearch.com/)
433
+ - **GitHub**: [github.com/vtempest/ai-research-agent](https://github.com/vtempest/ai-research-agent)
434
+ - **OpenAPI Spec**: [View Full Specification](./qwksearch-openapi.yml)
435
+
436
+ - [LLM Training Example](https://github.com/vtempest/ai-research-agent/blob/master/packages/neural-net/src/train/predict-next-word.js)
437
+ - [LangChain ReactAgent Tools](https://medium.com/@terrycho/how-langchain-agent-works-internally-trace-by-using-langsmith-df23766e7fb4)
438
+ - [Hugging Face Tutorials](https://huggingface.co/learn)
439
+ - [OpenAI Cookbook](https://cookbook.openai.com)
440
+ - [Transformer Overview](https://jalammar.github.io/illustrated-transformer/)
441
+ - [Building Transformer Guide](https://www.datacamp.com/tutorial/building-a-transformer-with-py-torch)
442
+ - [PyTorch Overview](https://www.learnpytorch.io/pytorch_cheatsheet/)
443
+ - [SearXNG Overview](https://medium.com/@elmo92/search-in-peace-with-searxng-an-alternative-search-engine-that-keeps-your-searches-private-accd8cddd6fc)
444
+
445
+ ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwksearch-api-client",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "QwkSearch API Client - Generated from openapi-docs.yml",
5
5
  "type": "module",
6
6
  "main": "./dist/api-client.js",