search-web-api 1.0.13

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 (111) hide show
  1. package/README.md +307 -0
  2. package/demo/index.ts +38 -0
  3. package/demo/openapi.ts +402 -0
  4. package/demo/routes/autocomplete.ts +124 -0
  5. package/demo/routes/search.ts +61 -0
  6. package/docs/AUTOCOMPLETE.md +296 -0
  7. package/docs/CATEGORY_SEARCH.md +265 -0
  8. package/package.json +32 -0
  9. package/src/autocomplete/autocomplete-ai-next-word-predictor.ts +47 -0
  10. package/src/autocomplete/autocomplete-search-engine-backends.ts +231 -0
  11. package/src/category-registry.ts +6 -0
  12. package/src/config/search-engine-constants.ts +216 -0
  13. package/src/constants.ts +6 -0
  14. package/src/engine-descriptions.ts +7 -0
  15. package/src/engine-status.ts +7 -0
  16. package/src/engine.ts +6 -0
  17. package/src/registry/search-engine-category-registry.ts +200 -0
  18. package/src/registry/search-engine-descriptions.ts +121 -0
  19. package/src/registry/search-engine-status-tracker.ts +240 -0
  20. package/src/result-container.ts +8 -0
  21. package/src/search/search-engines-registry-list.ts +205 -0
  22. package/src/search/search-query-executor.ts +168 -0
  23. package/src/search/search-result-container.ts +421 -0
  24. package/src/search-web-types.ts +7 -0
  25. package/src/search.ts +10 -0
  26. package/src/sources/academic/arxiv.ts +72 -0
  27. package/src/sources/academic/core.ts +65 -0
  28. package/src/sources/academic/crossref.ts +75 -0
  29. package/src/sources/academic/doaj.ts +63 -0
  30. package/src/sources/academic/google_scholar.ts +53 -0
  31. package/src/sources/academic/openalex.ts +75 -0
  32. package/src/sources/academic/pubmed.ts +96 -0
  33. package/src/sources/academic/semantic_scholar.ts +77 -0
  34. package/src/sources/academic/wikidata.ts +44 -0
  35. package/src/sources/general/baidu.ts +59 -0
  36. package/src/sources/general/bing.ts +30 -0
  37. package/src/sources/general/brave.ts +54 -0
  38. package/src/sources/general/duckduckgo.ts +49 -0
  39. package/src/sources/general/google.ts +68 -0
  40. package/src/sources/general/mojeek.ts +56 -0
  41. package/src/sources/general/qwant.ts +37 -0
  42. package/src/sources/general/startpage.ts +44 -0
  43. package/src/sources/general/yahoo.ts +41 -0
  44. package/src/sources/general/yandex.ts +56 -0
  45. package/src/sources/images/bing_images.ts +68 -0
  46. package/src/sources/images/deviantart.ts +71 -0
  47. package/src/sources/images/flickr.ts +132 -0
  48. package/src/sources/images/google_images.ts +101 -0
  49. package/src/sources/images/imgur.ts +58 -0
  50. package/src/sources/images/openclipart.ts +52 -0
  51. package/src/sources/images/pixabay.ts +56 -0
  52. package/src/sources/images/unsplash.ts +38 -0
  53. package/src/sources/images/wallhaven.ts +50 -0
  54. package/src/sources/it/crates.ts +41 -0
  55. package/src/sources/it/dockerhub.ts +47 -0
  56. package/src/sources/it/github.ts +37 -0
  57. package/src/sources/it/gitlab.ts +55 -0
  58. package/src/sources/it/npm.ts +36 -0
  59. package/src/sources/it/packagist.ts +43 -0
  60. package/src/sources/it/pypi.ts +30 -0
  61. package/src/sources/it/rubygems.ts +43 -0
  62. package/src/sources/it/stackoverflow.ts +39 -0
  63. package/src/sources/maps/apple_maps.ts +105 -0
  64. package/src/sources/maps/openstreetmap.ts +34 -0
  65. package/src/sources/maps/photon.ts +77 -0
  66. package/src/sources/news/bing_news.ts +95 -0
  67. package/src/sources/news/google_news.ts +80 -0
  68. package/src/sources/news/hackernews.ts +94 -0
  69. package/src/sources/news/yahoo_news.ts +77 -0
  70. package/src/sources/shopping/ebay.ts +96 -0
  71. package/src/sources/social/mastodon.ts +46 -0
  72. package/src/sources/social/medium.ts +52 -0
  73. package/src/sources/social/reddit.ts +48 -0
  74. package/src/sources/social/soundcloud.ts +64 -0
  75. package/src/sources/social/twitter.ts +56 -0
  76. package/src/sources/specialized/annas_archive.ts +97 -0
  77. package/src/sources/specialized/archive.ts +48 -0
  78. package/src/sources/specialized/genius.ts +43 -0
  79. package/src/sources/specialized/goodreads.ts +62 -0
  80. package/src/sources/specialized/imdb.ts +55 -0
  81. package/src/sources/specialized/openlibrary.ts +59 -0
  82. package/src/sources/specialized/wikipedia.ts +37 -0
  83. package/src/sources/specialized/wttr.ts +98 -0
  84. package/src/sources/torrents/1337x.ts +43 -0
  85. package/src/sources/torrents/eztv.ts +47 -0
  86. package/src/sources/torrents/kickass.ts +63 -0
  87. package/src/sources/torrents/nyaa.ts +53 -0
  88. package/src/sources/torrents/solidtorrents.ts +68 -0
  89. package/src/sources/torrents/thepiratebay.ts +57 -0
  90. package/src/sources/torrents/yts.ts +54 -0
  91. package/src/sources/videos/bing_videos.ts +91 -0
  92. package/src/sources/videos/dailymotion.ts +101 -0
  93. package/src/sources/videos/invidious.ts +86 -0
  94. package/src/sources/videos/peertube.ts +76 -0
  95. package/src/sources/videos/vimeo.ts +67 -0
  96. package/src/sources/videos/youtube.ts +78 -0
  97. package/src/suggest-next-words/autocomplete-ai.ts +38 -0
  98. package/src/suggest-next-words/autocomplete-search-engines.ts +384 -0
  99. package/src/suggest-next-words/misspelled-typos-8k.json +1 -0
  100. package/src/types/search-engine-interface.ts +27 -0
  101. package/src/types/search-result-types.ts +405 -0
  102. package/test/api.test.ts +128 -0
  103. package/test/autocomplete-ai.test.ts +20 -0
  104. package/test/autocomplete-engines.test.ts +131 -0
  105. package/test/engine-health-suite.test.ts +350 -0
  106. package/test/search.test.ts +69 -0
  107. package/test/sources-unit.test.ts +1152 -0
  108. package/test/sources.test.ts +182 -0
  109. package/test/test-utils.ts +81 -0
  110. package/tsconfig.json +16 -0
  111. package/vitest.config.ts +20 -0
package/README.md ADDED
@@ -0,0 +1,307 @@
1
+ <p align="center">
2
+ <img width="300px" src="https://i.imgur.com/BmaDQeR.png" />
3
+ <br />
4
+ <a href="https://discord.gg/SJdBqBz3tV">
5
+ <img src="https://img.shields.io/discord/1110227955554209923.svg?label=Chat&logo=Discord&colorB=7289da&style=flat"
6
+ alt="Join Discord" />
7
+ </a>
8
+ <a href="https://github.com/vtempest/qwksearch-research-agent/discussions">
9
+ <img alt="GitHub Stars" src="https://img.shields.io/github/stars/vtempest/qwksearch-research-agent" /></a>
10
+ <img src="https://img.shields.io/badge/Next.js-16-black" alt="Next.js" />
11
+ <br />
12
+ <a href="https://github.com/vtempest/qwksearch-research-agent/discussions">
13
+ <img alt="GitHub Discussions"
14
+ src="https://img.shields.io/github/discussions/vtempest/qwksearch-research-agent" />
15
+ </a>
16
+ <a href="https://github.com/vtempest/qwksearch-research-agent/pulse" alt="Activity">
17
+ <img src="https://img.shields.io/github/commit-activity/m/vtempest/qwksearch-research-agent" />
18
+ </a>
19
+ <img src="https://img.shields.io/github/last-commit/vtempest/qwksearch-research-agent.svg" alt="GitHub last commit" />
20
+ <br />
21
+ <a href="https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request">
22
+ <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg"
23
+ alt="PRs Welcome" />
24
+ </a>
25
+ <a href="https://codespaces.new/vtempest/qwksearch-research-agent">
26
+ <img src="https://github.com/codespaces/badge.svg" width="150" height="20" />
27
+ </a>
28
+ </p>
29
+
30
+ # Meta-Search Web Sources API
31
+
32
+ - **Multi-engine aggregation**: 70+ major sites search sources across 10 categories
33
+ - **Smart result merging**: Intelligent deduplication and ranking
34
+ - **Weighted scoring**: Position-based algorithm with engine and category weights
35
+ - **Category-based search**: Filter by academic, news, images, videos, etc.
36
+ - **Autocomplete**: Query suggestions from 8 search engines
37
+
38
+ ## Search Site Sources
39
+
40
+ ### General Search
41
+
42
+ | Engine | Description |
43
+ | ------------- | ------------------------------------------------------------------- |
44
+ | Google | The world's most popular web search engine |
45
+ | Bing | Microsoft's web search engine for the general web |
46
+ | Brave | Privacy-focused web search integrated with the Brave browser |
47
+ | DuckDuckGo | Privacy-oriented search engine that does not track users |
48
+ | Qwant | European privacy-focused web search engine |
49
+ | Startpage | Search engine that proxies Google results with enhanced privacy |
50
+ | Yahoo | Web portal providing search, email, and news |
51
+ | Ask | Question-answering oriented web search engine |
52
+ | Wikipedia | Free, community-edited online encyclopedia |
53
+ | Wikidata | Structured, collaborative knowledge base from Wikimedia |
54
+ | Wolfram Alpha | Computational knowledge engine for factual queries and calculations |
55
+
56
+ ### News
57
+
58
+ | Engine | Description |
59
+ | --------------- | ---------------------------------------------------------------------- |
60
+ | DuckDuckGo News | Aggregated news search powered by DuckDuckGo |
61
+ | Mojeek News | News search vertical from the independent Mojeek engine |
62
+ | Bing News | News aggregation and search from Microsoft Bing |
63
+ | Brave News | Privacy-focused news search from Brave Search |
64
+ | Google News | Google's personalized news aggregation and search service |
65
+ | Qwant News | News search and headlines from Qwant |
66
+ | Yahoo News | News portal and search from Yahoo |
67
+ | Tagesschau (DE) | German-language news search for Tagesschau, a major public broadcaster |
68
+
69
+ ### Videos
70
+
71
+ | Engine | Description |
72
+ | ----------------- | ---------------------------------------------------------------------------- |
73
+ | Bing Videos | Video search vertical from Microsoft Bing |
74
+ | Brave Videos | Video search vertical of Brave Search |
75
+ | DuckDuckGo Videos | Video search results from DuckDuckGo |
76
+ | Google Videos | Video-focused search results from Google |
77
+ | Qwant Videos | Video search vertical from Qwant |
78
+ | Bilibili | Chinese video sharing and streaming platform popular for animation and games |
79
+ | Dailymotion | Global video-sharing and hosting platform |
80
+ | Invidious | Alternative, privacy-friendly front-end for YouTube content |
81
+ | Odysee | Decentralized, blockchain-based video hosting platform |
82
+ | PeerTube | Federated, open source video hosting network |
83
+ | Piped | Privacy-respecting alternative front-end for YouTube |
84
+ | Rumble | Video sharing platform focusing on independent creators |
85
+ | Vimeo | Ad-free video hosting platform used by filmmakers and businesses |
86
+ | YouTube | The largest global video sharing and streaming platform |
87
+
88
+ ### Images
89
+
90
+ | Engine | Description |
91
+ | ----------------- | -------------------------------------------------------------- |
92
+ | Bing Images | Image search engine by Microsoft Bing |
93
+ | Brave Images | Image search vertical of Brave Search |
94
+ | DuckDuckGo Images | Image search results from DuckDuckGo |
95
+ | Google Images | Google's dedicated image search service |
96
+ | Qwant Images | Image search vertical from Qwant |
97
+ | DeviantArt | Online community and gallery for digital art and illustrations |
98
+ | Flickr | Image and short video hosting platform for photographers |
99
+ | Imgur | Image hosting and sharing site popular for memes and galleries |
100
+ | Pinterest | Visual discovery and bookmarking platform centered on images |
101
+ | Unsplash | Library of freely usable, high-resolution photos |
102
+ | Wallhaven | Community-driven wallpaper and background image repository |
103
+ | Wikimedia Commons | Image search across media stored on Wikimedia Commons |
104
+
105
+ ### Science & Academic
106
+
107
+ | Engine | Description |
108
+ | ------------------------ | ------------------------------------------------------------------------ |
109
+ | arXiv | Repository of preprint research papers in physics, math, CS and more |
110
+ | Crossref | Infrastructure service providing DOIs and metadata for scholarly content |
111
+ | Google Scholar | Google's search engine for scholarly literature and citations |
112
+ | Internet Archive Scholar | Internet Archive search for digitized scholarly works |
113
+ | PubMed | Database of biomedical and life sciences literature from NCBI |
114
+ | Semantic Scholar | AI-powered literature search and discovery tool for research papers |
115
+
116
+ ### IT & Development
117
+
118
+ | Engine | Description |
119
+ | --------------------- | --------------------------------------------------------------------- |
120
+ | Alpine Linux Packages | Search index for Alpine Linux software packages |
121
+ | Crates.io | Official package registry for Rust crates |
122
+ | Docker Hub | Central repository of Docker container images |
123
+ | Hex | Package manager and repository for the Erlang and Elixir ecosystem |
124
+ | Hoogle | API search engine for Haskell libraries and functions |
125
+ | Lib.rs | Alternative index and front-end for Rust crates |
126
+ | MetaCPAN | Search engine for Perl modules hosted on CPAN |
127
+ | npm | Package registry and manager for JavaScript and Node.js |
128
+ | Packagist | Primary package repository for PHP Composer |
129
+ | pkg.go.dev | Documentation and discovery service for Go modules |
130
+ | pub.dev | Package repository for Dart and Flutter packages |
131
+ | PyPI | Python Package Index, the main repository for Python packages |
132
+ | RubyGems | Package manager and repository for Ruby gems |
133
+ | Void Linux | Package search for the Void Linux distribution |
134
+ | Ask Ubuntu | Q&A site focused on Ubuntu usage and troubleshooting |
135
+ | Stack Overflow | Question-and-answer site for programmers and software development |
136
+ | Super User | Q&A site for advanced computer users and system administration |
137
+ | Bitbucket | Git-based source code hosting and collaboration platform by Atlassian |
138
+ | Codeberg | Non-profit, open source Git hosting platform |
139
+ | Gitea | Hosted instance of the lightweight Gitea Git service |
140
+ | GitHub | Popular Git-based code hosting and collaboration platform |
141
+ | GitLab | DevOps platform offering Git hosting, CI/CD, and project management |
142
+ | SourceHut | Minimalist suite of tools for software development and mailing lists |
143
+ | Arch Linux Wiki | Extensive documentation wiki for Arch Linux and related tools |
144
+ | Gentoo | Documentation wiki for the Gentoo Linux distribution |
145
+ | MDN | Mozilla Developer Network documentation for web technologies |
146
+ | SearchCode | Search engine indexing source code across public repositories |
147
+
148
+ ### Files & Archives
149
+
150
+ | Engine | Description |
151
+ | ------------------------ | ----------------------------------------------------------------- |
152
+ | Library of Congress | Catalog and digital collections from the U.S. Library of Congress |
153
+ | Wikibooks | Wikimedia project hosting free textbooks and manuals |
154
+ | Wikisource | Wikimedia digital library of source texts and documents |
155
+ | Wikiversity | Wikimedia project for educational resources and courses |
156
+ | Wikivoyage | Free, community-created travel guide from Wikimedia |
157
+ | Google Play Movies | Google's store for purchasing and renting movies and TV series |
158
+ | MediathekViewWeb (DE) | Web interface to German public TV media libraries |
159
+ | INA (FR) | French National Audiovisual Institute archive search |
160
+ | Wikimedia Commons Videos | Search for video media stored on Wikimedia Commons |
161
+ | Wikimedia Commons Audio | Search for audio files stored on Wikimedia Commons |
162
+ | APK Mirror | Repository for Android APK files outside official app stores |
163
+ | Apple App Store | Official iOS and iPadOS app distribution platform |
164
+ | F-Droid | Catalog of free and open source Android applications |
165
+ | Google Play Apps | Official Android app store operated by Google |
166
+
167
+ ### Social Media
168
+
169
+ | Engine | Description |
170
+ | --------- | ----------------------------------------------------------------------- |
171
+ | Pinterest | Visual discovery, bookmarking, and inspiration social platform |
172
+ | Reddit | Social news aggregation and discussion website organized by communities |
173
+ | 9GAG | Humor-focused social media site for sharing memes and short posts |
174
+ | Lemmy | Post search across Lemmy, a federated link-aggregation platform |
175
+
176
+ ### Maps & Navigation
177
+
178
+ | Engine | Description |
179
+ | ------------- | ------------------------------------------------------ |
180
+ | Apple Maps | Apple's mapping and navigation service for its devices |
181
+ | OpenStreetMap | Collaborative, open data world map project |
182
+
183
+ ### Music
184
+
185
+ | Engine | Description |
186
+ | ------------- | ------------------------------------------------------------------ |
187
+ | Genius | Platform for song lyrics, annotations, and music commentary |
188
+ | Radio Browser | Directory and search engine for online radio stations |
189
+ | Bandcamp | Music platform for independent artists to sell and stream releases |
190
+ | Deezer | On-demand music streaming service |
191
+ | Mixcloud | Streaming platform for DJ mixes, radio shows, and podcasts |
192
+ | SoundCloud | Audio distribution and music sharing platform for creators |
193
+ | YouTube | Video platform heavily used for streaming music and music videos |
194
+
195
+ ## API Usage
196
+
197
+ ### Basic Search
198
+
199
+ Search across all engines:
200
+
201
+ ```bash
202
+ curl "http://localhost:3000?q=artificial+intelligence"
203
+ ```
204
+
205
+ Search specific engines:
206
+
207
+ ```bash
208
+ curl "http://localhost:3000?q=machine+learning&engines=google,duckduckgo,bing"
209
+ ```
210
+
211
+ Search by category:
212
+
213
+ ```bash
214
+ curl "http://localhost:3000?q=quantum+computing&categories=science"
215
+ ```
216
+
217
+ ### Autocomplete
218
+
219
+ Get suggestions from a single backend:
220
+
221
+ ```bash
222
+ curl "http://localhost:3000/autocomplete?q=python&backend=google"
223
+ ```
224
+
225
+ Get suggestions from multiple backends:
226
+
227
+ ```bash
228
+ curl "http://localhost:3000/autocomplete/multi?q=javascript&backends=google,duckduckgo,wikipedia"
229
+ ```
230
+
231
+ List available autocomplete backends:
232
+
233
+ ```bash
234
+ curl "http://localhost:3000/autocomplete/backends"
235
+ ```
236
+
237
+ ### API Documentation
238
+
239
+ Interactive API documentation is available at:
240
+
241
+ - Scalar UI: `http://localhost:3000/docs`
242
+ - OpenAPI JSON: `http://localhost:3000/openapi.json`
243
+
244
+ ## Architecture
245
+
246
+ ### Technology Stack
247
+
248
+ - **Runtime**: Bun (high-performance JavaScript runtime)
249
+ - **Framework**: Hono (fast, lightweight web framework)
250
+ - **HTTP Client**: grab-url (for all engine requests)
251
+ - **HTML Parser**: linkedom (DOM parsing for scrapers)
252
+ - **Language**: TypeScript
253
+
254
+ ### Ranking Algorithm
255
+
256
+ Results are scored using SearXNG's proven algorithm:
257
+
258
+ ```
259
+ score = Σ (engine_weight × category_weight × occurrences / position)
260
+ ```
261
+
262
+ **Variables:**
263
+
264
+ - `engine_weight`: Configurable per-engine multiplier (default: 1.0)
265
+ - `category_weight`: Category importance multiplier (e.g., academic: 1.3)
266
+ - `occurrences`: Number of engines that found this result
267
+ - `position`: Result position in original engine results
268
+
269
+ Customize engine importance in `app/lib/search.ts`:
270
+ Configure in `app/lib/category-registry.ts`:
271
+
272
+ **Features:**
273
+
274
+ - Deduplication by URL normalization
275
+ - Multi-engine result merging
276
+ - Category-based grouping
277
+ - Priority levels (low, normal, high)
278
+
279
+ ### Project Structure
280
+
281
+ ```
282
+ app/
283
+ ├── engines/ # Search engine implementations
284
+ │ ├── general/ # Google, Bing, DuckDuckGo, etc.
285
+ │ ├── academic/ # arXiv, Google Scholar, PubMed
286
+ │ ├── images/ # Unsplash, Flickr, Imgur
287
+ │ ├── videos/ # YouTube, Vimeo, Dailymotion
288
+ │ ├── news/ # HackerNews, Google News, Bing News
289
+ │ ├── it/ # GitHub, npm, PyPI, Stack Overflow
290
+ │ ├── social/ # Reddit, Twitter, Medium
291
+ │ ├── maps/ # OpenStreetMap, Apple Maps
292
+ │ ├── shopping/ # eBay
293
+ │ ├── torrents/ # 1337x, PirateBay, Nyaa
294
+ │ └── specialized/ # Wikipedia, IMDb, Genius
295
+ ├── lib/ # Core search logic
296
+ │ ├── search.ts # Main search orchestrator
297
+ │ ├── result-container.ts # Result merging & ranking
298
+ │ ├── category-registry.ts # Category management
299
+ │ ├── engine.ts # Engine interface
300
+ │ └── autocomplete.ts # Autocomplete backends
301
+ ├── routes/ # API routes
302
+ │ ├── search.ts
303
+ │ └── autocomplete.ts
304
+ ├── data/ # Static data
305
+ │ └── engine-descriptions.ts
306
+ └── index.ts # Main entry point
307
+ ```
package/demo/index.ts ADDED
@@ -0,0 +1,38 @@
1
+
2
+ import { Hono } from 'hono';
3
+ import { apiReference } from '@scalar/hono-api-reference';
4
+ import searchRoute from './routes/search.js';
5
+ import autocompleteRoute from './routes/autocomplete.js';
6
+ import { openAPISpec } from './openapi.js';
7
+
8
+ const app = new Hono();
9
+
10
+ // Scalar API Reference endpoint
11
+ // @ts-ignore: Type definition mismatch but runtime works
12
+ app.get('/docs', apiReference({
13
+ // @ts-ignore
14
+ spec: {
15
+ url: '/openapi.json',
16
+ }
17
+ }));
18
+
19
+ // OpenAPI JSON spec endpoint
20
+ app.get('/openapi.json', (c) => {
21
+ return c.json(openAPISpec);
22
+ });
23
+
24
+ app.route('/', searchRoute);
25
+ app.route('/autocomplete', autocompleteRoute);
26
+
27
+ app.get('/', (c) => {
28
+ return c.text('SearXNG HonoX API is running! Visit /docs for API documentation.');
29
+ });
30
+
31
+ const port = 3000;
32
+ console.log(`Server is running on port ${port}`);
33
+
34
+ // Bun's native server
35
+ export default {
36
+ port,
37
+ fetch: app.fetch,
38
+ };