qwksearch-api-client 0.0.6 → 0.0.7

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/package.json +1 -1
  2. package/readme.md +439 -0
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.7",
4
4
  "description": "QwkSearch API Client - Generated from openapi-docs.yml",
5
5
  "type": "module",
6
6
  "main": "./dist/api-client.js",
package/readme.md ADDED
@@ -0,0 +1,439 @@
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
+ // Basic search
302
+ const response = await fetch('https://qwksearch.com/api/search?q=quantum+computing');
303
+ const { results } = await response.json();
304
+
305
+ results.forEach(result => {
306
+ console.log(result.title, result.url);
307
+ });
308
+
309
+ // Advanced search
310
+ const response = await fetch('https://qwksearch.com/api/search?' + new URLSearchParams({
311
+ q: 'climate change',
312
+ cat: 'science',
313
+ recency: 'month',
314
+ lang: 'en-US',
315
+ page: 1
316
+ }));
317
+
318
+ const { results } = await response.json();
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
+ })
332
+
333
+ results = response.json()['results']
334
+
335
+ for item in results:
336
+ print(f"{item['title']}\n{item['url']}\n{item['snippet']}\n")
337
+
338
+ # Video search
339
+ videos = requests.get('https://qwksearch.com/api/search', params={
340
+ 'q': 'machine learning tutorial',
341
+ 'cat': 'videos'
342
+ }).json()['results']
343
+ ```
344
+
345
+ ---
346
+
347
+ ## Installation
348
+
349
+ ### NPM Package
350
+
351
+ ```bash
352
+ npm install qwksearch-api-client
353
+ ```
354
+
355
+ ### Python Package
356
+
357
+ ```bash
358
+ pip install qwksearch-api-client
359
+ ```
360
+
361
+ ---
362
+
363
+ ## Complete Example: Research Pipeline
364
+
365
+ Combine all three endpoints to create a complete research pipeline:
366
+
367
+ ```javascript
368
+ import { QwkSearchClient } from 'qwksearch-api-client';
369
+
370
+ const client = new QwkSearchClient({
371
+ groqApiKey: process.env.GROQ_API_KEY
372
+ });
373
+
374
+ async function researchTopic(topic) {
375
+ // 1. Search for relevant articles
376
+ const searchResults = await client.search({
377
+ q: topic,
378
+ cat: 'science',
379
+ recency: 'month'
380
+ });
381
+
382
+ console.log(`Found ${searchResults.results.length} results`);
383
+
384
+ // 2. Extract content from top 3 results
385
+ const articles = await Promise.all(
386
+ searchResults.results.slice(0, 3).map(async (result) => {
387
+ const content = await client.extract({
388
+ url: result.url
389
+ });
390
+ return content;
391
+ })
392
+ );
393
+
394
+ // 3. Generate summary of all articles
395
+ const combinedText = articles
396
+ .map(a => `${a.title}\n\n${a.html}`)
397
+ .join('\n\n---\n\n');
398
+
399
+ const summary = await client.generateLanguage({
400
+ provider: 'groq',
401
+ agent: 'summarize-bullets',
402
+ article: combinedText
403
+ });
404
+
405
+ return {
406
+ searchResults: searchResults.results,
407
+ articles,
408
+ summary: summary.content
409
+ };
410
+ }
411
+
412
+ // Run the research pipeline
413
+ researchTopic('quantum computing applications')
414
+ .then(results => {
415
+ console.log('Research Summary:');
416
+ console.log(results.summary);
417
+ });
418
+ ```
419
+
420
+ ---
421
+
422
+
423
+ ## Links
424
+
425
+ - **Documentation**: [airesearch.js.org](https://airesearch.js.org/)
426
+ - **Demo**: [qwksearch.com](https://qwksearch.com/)
427
+ - **GitHub**: [github.com/vtempest/ai-research-agent](https://github.com/vtempest/ai-research-agent)
428
+ - **OpenAPI Spec**: [View Full Specification](./qwksearch-openapi.yml)
429
+
430
+ - [LLM Training Example](https://github.com/vtempest/ai-research-agent/blob/master/packages/neural-net/src/train/predict-next-word.js)
431
+ - [LangChain ReactAgent Tools](https://medium.com/@terrycho/how-langchain-agent-works-internally-trace-by-using-langsmith-df23766e7fb4)
432
+ - [Hugging Face Tutorials](https://huggingface.co/learn)
433
+ - [OpenAI Cookbook](https://cookbook.openai.com)
434
+ - [Transformer Overview](https://jalammar.github.io/illustrated-transformer/)
435
+ - [Building Transformer Guide](https://www.datacamp.com/tutorial/building-a-transformer-with-py-torch)
436
+ - [PyTorch Overview](https://www.learnpytorch.io/pytorch_cheatsheet/)
437
+ - [SearXNG Overview](https://medium.com/@elmo92/search-in-peace-with-searxng-an-alternative-search-engine-that-keeps-your-searches-private-accd8cddd6fc)
438
+
439
+ ---