-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.html
More file actions
372 lines (362 loc) · 14.7 KB
/
Copy pathapi.html
File metadata and controls
372 lines (362 loc) · 14.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<!doctype html>
<html lang="en" data-theme="light">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>API reference - Degoog docs</title>
<script>
(function () {
try {
var t = localStorage.getItem("ade:theme");
if (t !== "light" && t !== "dark") {
t = window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
}
document.documentElement.setAttribute("data-theme", t);
} catch (e) {}
})();
</script>
<link
rel="icon"
href="https://github.com/fccview/degoog/raw/main/src/public/images/degoog-logo.png"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"
/>
<link rel="stylesheet" href="style.css?cache=burstthefucker" />
</head>
<body>
<div class="degoog-docs-layout">
<header class="degoog-docs-mobile-header">
<button id="degoog-docs-burger" type="button" class="degoog-docs-btn degoog-docs-btn-burger">
<i class="fa-solid fa-bars"></i>
</button>
<span class="degoog-docs-mobile-title">Degoog Docs</span>
</header>
<div class="degoog-docs-content">
<aside class="degoog-docs-sidebar">
<div class="degoog-docs-sidebar-brand">
<img
src="https://github.com/fccview/degoog/raw/main/src/public/images/degoog-logo.png"
alt="degoog logo"
class="degoog-docs-brand-img"
onerror="this.style.display = 'none'"
/>
<a href="index.html" class="degoog-docs-brand-name">Degoog Docs</a>
</div>
<div class="degoog-docs-sidebar-search">
<div class="doc-search-wrap">
<input
type="search"
id="doc-search-input"
class="degoog-docs-input doc-search"
placeholder="Search docs..."
autocomplete="off"
/>
<button
type="button"
class="doc-search-clear degoog-docs-btn"
aria-label="Clear search"
style="display: none"
>
Clear
</button>
<span class="doc-search-count"></span>
</div>
</div>
<nav class="degoog-docs-nav" aria-label="Documentation">
<a href="index.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-book-open fa-lg"></i></i
><span class="degoog-docs-nav-item-name">Overview</span></a
>
<a href="plugins.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-puzzle-piece fa-lg"></i
><span class="degoog-docs-nav-item-name"> Plugins</span></a
>
<a href="shortcuts.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-arrow-down-a-z fa-lg"></i></i
><span class="degoog-docs-nav-item-name"> Shortcuts</span></a
>
<a href="themes.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-palette fa-lg"></i
><span class="degoog-docs-nav-item-name"> Themes</span></a
>
<a href="engines.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-bolt fa-lg"></i
><span class="degoog-docs-nav-item-name"> Search engines</span></a
>
<a href="autocomplete.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-keyboard fa-lg"></i
><span class="degoog-docs-nav-item-name"> Autocomplete</span></a
>
<a href="transports.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-network-wired fa-lg"></i
><span class="degoog-docs-nav-item-name"> Transports</span></a
>
<a href="store.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-store fa-lg"></i
><span class="degoog-docs-nav-item-name"> Store</span></a
>
<a href="aliases.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-link fa-lg"></i
><span class="degoog-docs-nav-item-name"> Aliases</span></a
>
<a href="env.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-lock fa-lg"></i></i
><span class="degoog-docs-nav-item-name">ENV Variables</span></a
>
<a href="styling.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-swatchbook fa-lg"></i></i
><span class="degoog-docs-nav-item-name"> Styling</span></a
>
<a href="translations.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-language fa-lg"></i
><span class="degoog-docs-nav-item-name"> Translations</span></a
>
<a href="api.html" class="degoog-docs-nav-item"
><i class="fa-solid fa-code fa-lg"></i
><span class="degoog-docs-nav-item-name"> API</span></a
>
</nav>
<div class="degoog-docs-sidebar-actions">
<button
id="doc-theme-toggle"
type="button"
class="degoog-docs-btn"
aria-label="Toggle theme"
>
<i class="fa-solid fa-circle-half-stroke"></i>
</button>
</div>
</aside>
<main class="degoog-docs-main">
<div class="doc-page-header">
<h1><a href="index.html">Degoog</a> API reference</h1>
<p class="doc-page-desc">
User facing HTTP endpoints and a real life usage example.
</p>
</div>
<h2>Overview</h2>
<p>
Most of our HTTP surface is internal plumbing for the web UI. The
endpoints below are what you will likely use for making external
calls.
</p>
<p>
These endpoints live at the same host and port as your UI (<code
>http://localhost:4444</code
>
by default, or <code>DEGOOG_PORT</code>). All responses are returned
in JSON. You can configure rate limits by going to Settings then
Server, and these limits will apply to every caller.
</p>
<h2>API key protection (optional)</h2>
<p>
In Settings -> Server you can require authentication for search, search
stream, search retry, and suggest. When that is enabled for a route,
requests without valid credentials receive
<code>401</code> and a JSON body such as
<code>{"error":"Unauthorized"}</code>.
</p>
<p>
For external callers (scripts, integrations,
<code>curl</code>, Open WebUI, etc.), use the API key from the same
settings screen (the 64-character hexadecimal value) as a Bearer token.
The server compares it to the stored secret; only that exact key is
accepted.
</p>
<pre><code>curl -H "Authorization: Bearer YOUR_API_KEY_HERE" \
"http://localhost:4444/api/search?q=hello"</code></pre>
<p>
The in-browser UI does not rely on this header; it uses a separate
short-lived nonce supplied with the page when protection is on.
</p>
<h2><code>GET /api/search</code></h2>
<p>Run a metasearch and get merged and scored results.</p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>q</code></td>
<td>Required. Your search query.</td>
</tr>
<tr>
<td><code>type</code></td>
<td>
<code>web</code> (default) | <code>images</code> |
<code>videos</code> | <code>news</code>.
</td>
</tr>
<tr>
<td><code>page</code></td>
<td>Starts at 1. Restricted to a maximum of 10.</td>
</tr>
<tr>
<td><code>time</code></td>
<td>
<code>any</code> | <code>hour</code> | <code>day</code> |
<code>week</code> | <code>month</code> | <code>year</code> |
<code>custom</code>. For <code>custom</code>, pass
<code>dateFrom</code> and <code>dateTo</code> (using the
standard <code>YYYY MM DD</code> format).
</td>
</tr>
<tr>
<td><code>lang</code></td>
<td>
ISO 639 1 language code. This overrides
<code>DEGOOG_DEFAULT_SEARCH_LANGUAGE</code> for your current
request.
</td>
</tr>
</tbody>
</table>
<pre><code>curl "http://localhost:4444/api/search?q=rust+lifetimes"</code></pre>
<p>Response:</p>
<pre><code>{
"results": [
{
"title": "...",
"url": "https://...",
"snippet": "...",
"source": "brave",
"score": 92,
"sources": ["brave", "duckduckgo"]
}
],
"query": "rust lifetimes",
"totalTime": 812,
"type": "web",
"engineTimings": [{ "name": "Google", "time": 540, "resultCount": 10 }],
"relatedSearches": ["rust lifetime elision", "..."]
}</code></pre>
<h2><code>POST /api/search</code></h2>
<p>
This works exactly like the GET version but accepts a JSON body. You
should use this when you have a long list of engines to query.
</p>
<pre><code>curl -X POST http://localhost:4444/api/search \
-H "Content-Type: application/json" \
-d '{
"query": "rust lifetimes",
"type": "web",
"page": 1,
"lang": "en",
"engines": ["brave", "duckduckgo"]
}'</code></pre>
<h2><code>GET /api/search/stream</code></h2>
<p>
This is the Server Sent Events variant. It uses the exact same query
parameters as
<code>GET /api/search</code> and emits two events:
</p>
<ul>
<li>
<code>engine-result</code> fires as each engine returns. The
<code>results</code> field contains the running merged list, so
you can simply keep the last one if you are a lazy consumer.
</li>
<li>
<code>done</code> is the final event containing
<code>totalTime</code>, <code>engineTimings</code>, and
<code>relatedSearches</code>.
</li>
</ul>
<pre><code>curl -N "http://localhost:4444/api/search/stream?q=hello"</code></pre>
<h2><code>GET /api/suggest?q=...</code></h2>
<p>
Fetches autocomplete suggestions merged from Google and DuckDuckGo.
This returns an array of strings.
</p>
<h2><code>GET /api/lucky?q=...</code></h2>
<p>
Runs a web search and sends a <code>302</code> redirect directly to
the URL of the first result.
</p>
<h2><code>GET /api/extensions</code></h2>
<p>
Lists the extensions installed on your instance, grouped by kind:
<code>engines</code>, <code>plugins</code>, <code>themes</code>,
<code>transports</code>, and <code>autocomplete</code>. Each item
includes its <code>id</code>, which is the same id you pass to the
<code>engines</code> field of <code>/api/search</code>.
</p>
<p>
Pass <code>?type=</code> to fetch a single kind. Accepted values are
<code>engine</code>, <code>plugin</code>, <code>theme</code>,
<code>transport</code>, and <code>autocomplete</code>. The response
keeps the same shape, with only the matching group present. Handy for
discovering valid engine ids before restricting a search (for
example from the
<a href="https://github.com/degoog-org/degoog/tree/main/mcp">degoog-mcp</a>
sidecar). An unknown type returns <code>400</code>.
</p>
<pre><code>curl "http://localhost:4444/api/extensions?type=engine"</code></pre>
<pre><code>{
"engines": [
{ "id": "brave", "displayName": "Brave", "...": "..." },
{ "id": "duckduckgo", "displayName": "DuckDuckGo", "...": "..." }
]
}</code></pre>
<h2><code>GET /opensearch.xml</code></h2>
<p>
OpenSearch descriptor that allows browsers to install Degoog as a
search engine.
</p>
<h2>
Tip: wiring Degoog into
<a href="https://github.com/open-webui/open-webui">Open WebUI</a>
</h2>
<p>
Degoog is completely SearXNG compatible for the built in web search
inside Open WebUI, meaning you will not need any custom tools.
</p>
<ol>
<li>Open WebUI and go to your <strong>Admin Panel</strong>.</li>
<li>Navigate to <strong>Settings</strong>.</li>
<li>Select <strong>Web Search</strong> and enable it.</li>
<li>
Set your <strong>Web Search Engine</strong> to
<code>searxng</code>.
</li>
<li>
Set the <strong>SearxNG Query URL</strong> to your Degoog instance
URL followed by <code>/api/search</code>, like this:
<code>http://127.0.0.1:4444/api/search</code>.
</li>
</ol>
<p>
Just remember to replace <code>http://127.0.0.1:4444</code> with
your actual Degoog address.
</p>
<p>
If you enabled API key protection for search, configure your client to
send <code>Authorization: Bearer …</code> with your instance key as
described above (Open WebUI must support custom headers for the search
URL if you use that mode).
</p>
</main>
</div>
<div id="degoog-docs-backdrop" class="degoog-docs-backdrop"></div>
</div>
<script
src="https://code.jquery.com/jquery-4.0.0.min.js"
crossorigin="anonymous"
></script>
<script src="docs.js"></script>
<script src="docs-ui.js"></script>
</body>
</html>