Degoog Search engines
Build your own custom search backends for web, images, videos or anything you can think of.
Where engines live
You can drop your custom engines right into
data/engines/ or whatever you set
DEGOOG_ENGINES_DIR to. Each engine is just a file or folder with
an entry file that exports an object or class containing a
name and executeSearch.
Compatibility layers
Compatibility layers let Degoog load engines written for another search-engine runtime and expose them as normal Degoog engines. These engines still run through Degoog's engine registry, settings list, bang shortcuts, configured transports, and result pipeline.
Compatibility engines are marked in Settings then Engines with a small badge
showing the layer name, for example searx or 4get.
SearXNG Python engines
Degoog can run SearXNG-style Python engine files as normal Degoog engines. It does not run a SearXNG instance. Degoog asks the Python engine to build the request and parse the response, and performs every HTTP fetch itself through its own transports, proxies and timeouts.
Installing them
Go to Settings then Engines and use
Add from SearXNG. The modal lists the
80 engines currently verified to return results through the
layer. Installing pulls the file from upstream into
data/searx/engines/ and refreshes the engine list straight away,
so no restart is needed.
Files can also be dropped into data/searx/engines/ by hand, or
into DEGOOG_SEARX_ENGINES_DIR when that environment variable is
set. A hand-dropped file needs a restart, and it still has to be on the
verified list to load.
The filename becomes the bang shortcut, so ebay.py becomes
!ebay.
Shared files
Some SearXNG engines are built on top of another engine's code.
google_cse.py imports from google.py, and
apple_maps.py reaches into OpenStreetMap, Wikidata and Wikipedia.
Degoog resolves these automatically: the install modal shows a
+N shared files badge, asks for confirmation, and downloads
everything the engine needs alongside it.
Shared files that are not themselves offered as engines (bing,
google, json_engine, openstreetmap,
wikidata, wikipedia, yahoo) are loaded
as libraries only. They never appear as engines, never run searches, and are
removed again once no installed engine depends on them.
What behaves exactly like a native engine
SearXNG engines are registered in the same list as everything else, so the following work with no special handling:
- Score and result aggregation. They run through the identical scoring and de-duplication pipeline, so a custom score weights them the same way it weights a store engine.
-
Safe Search. Each one gets the same
safeSearchdropdown described below, defaulting tomoderatefor image and video engines andofffor the rest. -
Proxies and VPN routing. Every outbound request goes
through
context.fetch, including the extra token and metadata calls some engines make while building a request. Global proxies and per-engine proxy overrides both apply. - Transports, timeouts and custom user agents, plus the engine type override, enable and disable toggles, and bang shortcuts.
- Paging. Engines that declare no paging support are skipped past page one rather than repeating their first page.
- Time filters. Sent only to engines that declare support. A custom date range collapses onto the nearest bucket SearXNG understands (day, week, month or year).
Known trade-offs
This is a compatibility layer over code written for a different application, so it is not a perfect match:
- Image filters beyond Safe Search (size, colour, type, layout) are not translated. A SearXNG image engine drops out of the results while one of those filters is active, rather than returning unfiltered images.
- Failure reporting is coarser. HTTP blocks and rate limits are classified correctly, but an error raised inside the Python parser is reported as a generic network failure.
- Upstream bugs come along for the ride. These files track SearXNG's master branch and are not patched by Degoog. An engine can break when the site it scrapes changes.
- Each search spawns a short-lived Python process, so these engines carry slightly more overhead than a native one.
Engines that fail to load are logged at boot with the underlying Python error, separately from the list of engines skipped on purpose.
4get PHP scrapers
The 4get layer runs a scraper from lolcat's 4get as a normal Degoog engine, one short-lived PHP process per call. It needs PHP 8.1 or newer with sodium and mbstring. It does not need ext-curl or APCu, and the shipped image has neither.
4get scrapers work differently from SearXNG engines, and the layer is built
around that difference. A SearXNG engine builds a request and parses a
response, and never touches the network. A 4get scraper calls
curl_init() itself, halfway through its own logic.
Degoog does not patch the scraper. It loads the file under a private PHP
namespace, where an unqualified curl_init() resolves to Degoog's
own function before PHP's. Those shims hand the request back over the bridge,
and Degoog performs the fetch through the engine's configured transport. The
file on disk stays exactly as upstream wrote it, which is what keeps
Update a plain re-download.
The same trick covers paging. 4get encrypts its next-page state into APCu,
which dies with the process, so apcu_* is shimmed onto Degoog's
cache. The scraper's own token minting then works untouched and a token
survives into the next process.
Before you add a scraper to the catalogue:
- Unqualified function calls fall back to the global namespace, but class names do not. The staging prelude imports the built-ins the scrapers use. A scraper reaching for a class nobody imported fails to load, and says so.
-
curl_multi_*is not bridged. A scraper using it throws rather than quietly returning nothing.
Adding a layer
Layers are registered in
src/server/extensions/compatibility-layer/registry.ts. A new one
is a single CompatLayerDef: an id, a label, the server setting
key that turns it on, the note keys the UI lists, and functions to load
engines, list the catalogue, install, update, uninstall, and take the
install lock. Everything else already iterates the registry. The engine
loader, the /api/compat/:layer/* routes, the server settings
toggles, and the Engines tab section pick a new layer up without changes.
Both runners share
compatibility-layer/rpc.ts, which speaks line-delimited JSON over
stdin and stdout and serves fetch and cache calls
back from the child process. A new runtime needs a binary, its flags, and a
script that reads one line, does the work, prints one envelope and exits.
Engine contract
What you need:
- name: The display name shown in Settings then Engines.
-
executeSearch(query, page?, timeFilter?, context)
(async): This needs to return a Promise that resolves to an array of
results. Each result is an object holding a
title,url,snippet,source, and optionally athumbnail,durationandpublishedAt. Make sure you usecontext.fetchfor all your outbound HTTP requests so your engine respects any proxy settings the user has configured.
publishedAt is a YYYY-MM-DD string and it is worth
setting when the page you are scraping gives you a real date. If you leave it
out, Degoog looks for a date at the start of the snippet during the merge,
which covers the common
12 Jan 2024 - some text and 3 days ago - some text
shapes, lifts it into publishedAt and takes it off the front of
the snippet. It only lifts ISO dates, dates with a month name, and
"N days ago" style dates. Numeric forms like 01/12/2024 stay in
the snippet, because Degoog can't tell whether the site meant January or
December. Anything you set yourself wins over the guess.
Optional extras:
-
bangShortcut: Lets users type a shortcut like
!shortcut queryorquery !shortcutto search only this engine (like settingbangShortcut: "ecosia"so users can type!ecosia linux). -
settingsSchema and configure(settings):
These work just like they do for plugins. You will get a Configure button in
Settings then Engines, and the values are securely saved in
data/plugin-settings.json.
Your SettingField shape needs a key, label, and
type (which can be text, password, url, toggle, textarea, select,
or urllist). You can also add optional properties like required,
placeholder, description, secret,
options (if using select), and default.
If you have sensitive fields like API keys or tokens, mark them with
secret: true. The UI will never expose the saved value to the
user and will just show a Set or Not set indicator
instead. When saving, if the field value equals the special
"__SET__" string, the existing stored value stays put. This
ensures a page reload never wipes out a key you already entered.
HTTP method
Your engines are completely free to use more than just GET requests. Because
you control the fetch call inside
executeSearch, you can use any method like POST and set whatever
headers or body your API needs. Here is what a GraphQL engine using POST looks
like:
async executeSearch(query, page = 1, _timeFilter, context) {
const doFetch = context?.fetch ?? fetch;
const response = await doFetch("https://graphql.example.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query: MY_QUERY, variables: { search: query, page } }),
});
context?.sentinel?.(response, this.name);
const data = await response.json();
// parse and return array of { title, url, snippet, source }
}
Search types
Export a type to declare which tab(s) your engine belongs to. The
default is "web". Any other string automatically creates a
dedicated tab on the search results page, all engines sharing that type run
together when the tab is selected.
type can be a single string or an array of strings. When an array
is used, the engine participates in every listed tab simultaneously.
export const type = "books" // creates a Books tab
export const type = ["web", "karakeep"] // shows in Web tab AND Karakeep tab
Users can also override the type from the engine's Advanced settings using the
Engine type override field. Comma-separated values are
supported for multiple types, e.g. web,karakeep. A runtime
override always takes precedence over the exported type.
Image filters
Image engines (engines whose type includes "images")
can declare exactly which filters they support by exporting a
filters object. Each key is a filter group and each value is the
list of option values your engine actually translates into an upstream
request. degoog renders the image filter bar from the
union of the declared filters across every
enabled image engine, so users only ever see options that will really
take effect.
Exclusion: when a filter is active, any engine that does not
declare that exact value is dropped from that search (rather than
returning unfiltered results that pollute the grid). So if the user picks
color: red, only engines that list red under
color run; everything else sits that search out. Declare a group
honestly, only list values you map. This is why an engine that exports no
filters at all is excluded the moment any filter is active.
Requires degoog 0.23.0 or newer. Set
minDegoogVersion accordingly in your store manifest.
export const type = "images"
export const filters = {
size: ["small", "medium", "large", "wallpaper"],
color: ["red", "blue", "green", "transparent"],
type: ["photo", "clipart", "lineart", "animated"],
layout: ["square", "wide", "tall"],
nsfw: ["on", "moderate", "off"],
}
The recognised groups are size, color,
type, layout and nsfw (shown in the UI
as Safe mode, defaulting to moderate). Only
declare the values you map; e.g. an engine that supports nothing but a mature
toggle can export { nsfw: ["off"] }.
transparent is just another value. Some engines treat it as a
colour (Google), others as a type (Bing, DuckDuckGo). Put it under whichever
group your engine implements it in, and degoog will show it there. If two
enabled engines place it in different groups, it appears in both
dropdowns, and each engine applies the one it understands.
The user's selection arrives on context.imageFilter as a plain
object keyed by group, e.g. { color: "red", nsfw: "moderate" }.
Read only the keys you declared; anything you do not map is safely ignored.
Image input
Engines search with text by default. Export input = "image" to
make an engine that searches with a picture instead, a reverse image search
for example. As soon as one enabled engine takes an image, the search bar
accepts one: dropped, pasted or picked with the camera button.
export const type = "images"
export const input = "image"
An image engine only runs when the search has an image, and never for a text
search. The picture arrives on context.image. Any words the user
typed next to it arrive as the normal query, which can be an
empty string.
| Field | What it is |
|---|---|
context.image.bytes |
The image as a Uint8Array. The browser resizes it to 1024 pixels on the longest side before sending it. |
context.image.mime |
image/jpeg, image/png or image/webp, read from the bytes. |
context.image.base64 |
The same bytes as base64, without a data: prefix. |
context.image.hash |
SHA-256 of the bytes. degoog already puts it in the cache key, so you don't need to. |
Upload it with context.fetch like any other request, so proxies
and the user's transport choice still apply. body takes a string
or a Uint8Array, so a multipart upload looks like this:
const boundary = `----degoog${crypto.randomUUID()}`;
const head = `--${boundary}\r\nContent-Disposition: form-data; name="file"; filename="image.jpg"\r\nContent-Type: ${context.image.mime}\r\n\r\n`;
const tail = `\r\n--${boundary}--\r\n`;
const enc = new TextEncoder();
const body = new Uint8Array([...enc.encode(head), ...context.image.bytes, ...enc.encode(tail)]);
const response = await context.fetch("https://example.com/upload", {
method: "POST",
headers: { "Content-Type": `multipart/form-data; boundary=${boundary}` },
body,
});
The Fetch and Curl Impersonate transports carry binary bodies. Transports
that drive a browser or a solver service may not, so pick a default
outgoingTransport that does.
An image engine sends the user's picture to whoever runs the upstream site. Say so in its settings and README, and leave it off until the user turns it on.
Language & time filters
When someone selects a language or time filter in the UI, those values get
passed to every engine through the
context argument. You do not have to read them if you do not want
to. Engines that ignore these will just return unfiltered results.
| Field | Type | Description |
|---|---|---|
context.lang |
string | undefined |
The ISO 639 1 language code chosen by the user (like
"en", "de", or "it"). If it is
undefined, no language filter was selected.
|
context.buildAcceptLanguage() |
() => string |
Returns a ready to use Accept-Language header value derived
from context.lang. It safely falls back to
"en,en-US;q=0.9" when no language is set so you can pass it
directly to your fetch headers.
|
context.dateFrom |
string | undefined |
The start of a custom date range formatted as
YYYY-MM-DD. This is only set when the timeFilter is custom.
|
context.dateTo |
string | undefined |
The end of a custom date range formatted as
YYYY-MM-DD. This is only set when the timeFilter is custom.
|
context.extractImageUrl($el, baseUrl?, selectors?)
|
($el, baseUrl?, selectors?) => string
|
Easily extract an article image URL from a cheerio element. It checks
all the common attributes like src and
data src, normalizes URLs, and resolves relative paths
against your baseUrl. It even skips tiny images and
favicons. You can pass selectors to target a specific
thumbnail container first.
|
context.signProxyUrl(url) |
(url: string) => string |
Returns a signed /api/proxy/image URL for the given
external image URL. Use this when you include thumbnails in your results
so they load correctly regardless of the outgoing allowlist
configuration.
|
context.apiBase |
string | undefined |
The base path of your engine's own routes, for example
/api/engine/my-engine. Only set when your engine exports
routes. See Engine routes.
|
context.routeUrl(path) |
(path: string) => string |
Builds the URL of one of your engine's routes on this instance, for
example context.routeUrl("/thumb?id=42"). Use it for
thumbnails your engine serves itself; they go through the image proxy
like any other thumbnail. Only set when your engine exports
routes.
|
context.sentinel(response, name?) |
(response: { ok, status }, name?: string) => void
|
Call this right after every doFetch in your engine. If the
upstream returned a non-OK status (403, 429, 5xx, ...) it throws a
structured SentinelBreach with a status of
"blocked", "rate_limited" or
"network" that the orchestrator logs and surfaces back to
the UI as a real "engine blocked" signal instead of a silent 0 results.
Always prefer this to if (!response.ok) return [];.
|
context.engineError(status, message, opts?) |
(status, message, opts?: { httpStatus?, engine? }) => Error
|
Build the same structured SentinelBreach manually when you
detect a soft block (Cloudflare challenge page, consent interstitial,
captcha HTML, empty JSON envelope from a rate-limited API, ...). Valid
statuses: "blocked", "rate_limited",
"captcha", "interstitial",
"parse_error", "timeout",
"network".
|
context.emit(results, progress?) |
(results: SearchResult[], progress?: { expected?: number }) => void
|
Sends results to the page before executeSearch returns.
Each call adds to what you already sent. See
Emitting results.
undefined on degoog versions without it, so call it as
context?.emit?.(...).
|
Surfacing upstream failures
Engines used to silently return [] on a 403 or 429, which made
"engine got walled" indistinguishable from "no results for this query". Don't
do that anymore. Two rules:
-
After every
const response = await doFetch(...), callcontext?.sentinel?.(response, this.name);before reading the body. This converts non-OK HTTP into a structured throw the orchestrator understands. -
If you have an outer
try / catchthat returns[]on any error, re-throw structured engine errors so they reach the orchestrator:
Without the re-throw, your catch swallows the new signal and the UI is back to showing 0 results with no context.} catch (e) { if (e?.name === "SentinelBreach") throw e; return []; }
For soft blocks you detect yourself (Cloudflare challenge HTML, JavaScript consent interstitial, empty API envelope from a rate-limited backend, ...) build the error explicitly:
const html = await response.text();
if (html.includes("cf-challenge")) {
throw context.engineError(
"captcha",
`${this.name} hit a Cloudflare challenge`,
{ engine: this.name },
);
}
The timeFilter parameter passed to
executeSearch will be one of these options: "any",
"hour", "day", "week",
"month", "year", or "custom". If it is
"custom", just read context.dateFrom and
context.dateTo.
export default class MyEngine {
name = "My Search";
async executeSearch(query, page = 1, timeFilter, context) {
const lang = context?.lang;
const acceptLang = context?.buildAcceptLanguage?.() ?? "en,en-US;q=0.9";
const doFetch = context?.fetch ?? fetch;
const params = new URLSearchParams({ q: query });
if (lang) params.set("lang", lang);
if (timeFilter === "day") params.set("when", "24h");
else if (timeFilter === "week") params.set("when", "7d");
else if (timeFilter === "custom" && context?.dateFrom) {
params.set("from", context.dateFrom);
if (context.dateTo) params.set("to", context.dateTo);
}
const res = await doFetch(`https://example.com/search?${params}`, {
headers: { "Accept-Language": acceptLang },
});
// parse and return array of { title, url, snippet, source }
}
}
Emitting results
Some engines can't hand back a full page in one go. Google and Brave now
wrap result links in redirects, and each one costs its own request to
unwrap, sometimes after a wait the engine tells you to sit through. Ten
links can take 20 seconds. Without emit, the user stares at
nothing for that whole time, then the engine hits its timeout and every
result it had already unwrapped is thrown away.
context.emit fixes that. Call it with results as soon as you
have them and they show up on the page straight away.
- Every emit adds to the ones before it. degoog drops any URL you already sent, so emitting the same result twice is harmless.
- Every emit resets the engine's timeout. An engine that keeps producing results keeps running, up to three times its timeout in total. An engine that goes quiet for a full timeout gets stopped.
- When the engine gets stopped, degoog keeps everything it emitted. That run is not cached, so the next search tries again.
-
When
executeSearchreturns, the array you return sets the final order. Anything you emitted but didn't return gets added after it. Return your full list in rank order. -
Pass
{ expected }to say how many results you're working through. The sidebar shows the engine as emitting 3/10 until it finishes. Without it, the sidebar shows emitting 3. -
Only page 1 with streaming on shows results as they arrive. The nojs page,
page 2 onwards and
GET /api/searchwait for the engine, and there an emitting engine gets its normal timeout with no extension. It still keeps whatever it emitted before the timeout.
Don't emit just because you can. If your engine gets its whole page from one request, return it like you always have. Emit when results trickle in, like unwrapping redirect links one request at a time:
async executeSearch(query, page = 1, timeFilter, context) {
const doFetch = context?.fetch ?? fetch;
const res = await doFetch(`https://example.com/search?q=${encodeURIComponent(query)}`);
context?.sentinel?.(res, this.name);
const parsed = parseResults(await res.text());
const progress = { expected: parsed.length };
const resolved = await Promise.all(
parsed.map(async (result) => {
const url = await unwrapRedirect(result.url, context);
if (url) context?.emit?.([{ ...result, url }], progress);
return { ...result, url };
}),
);
return resolved.filter((result) => result.url);
}
Pass context.signal into the requests you make while emitting.
When degoog stops the engine it aborts that signal, and anything still in
flight should stop with it.
Safe Search
Our default engines like Brave and Bing include a
Safe Search dropdown in Settings then Engines. The default
behavior stays the same where Brave defaults to moderate and the
rest default to off. Users can easily raise or lower the filter
for each engine individually.
You can add this exact same setting to your custom engines by including a
select field in your settingsSchema and applying the
value in your executeSearch function:
settingsSchema = [
{
key: "safeSearch",
label: "Safe Search",
type: "select",
options: ["off", "moderate", "strict"],
description: "Filter explicit content from search results.",
},
];
safeSearch = "moderate";
configure(settings) {
if (typeof settings.safeSearch === "string") {
this.safeSearch = settings.safeSearch;
}
}
async executeSearch(query, page = 1, timeFilter, context) {
const params = new URLSearchParams({ q: query, safesearch: this.safeSearch });
// ...
}
Proxies
When someone enables a proxy for search, your engine requests can route through it. To make sure your engine plays nicely with proxies:
-
Use
context.fetchfor every outbound HTTP request instead of the globalfetch.
export default class MyEngine {
name = "My Search";
async executeSearch(query, page = 1, _timeFilter, context) {
const url = `https://www.example.com/search?q=${encodeURIComponent(query)}`;
const doFetch = context?.fetch ?? fetch;
const response = await doFetch(url, { headers: { "User-Agent": "my-engine/1.0" } });
const html = await response.text();
// parse and return array of { title, url, snippet, source, ... }
}
}
Every engine also features an
Outgoing HTTP client control in Settings then Engines. This
setting is stored per engine and can be set to fetch, system
curl, auto, or any custom
transport you install from the Store.
You should still use context.fetch in your custom engines so this
setting applies automatically.
Every context.fetch call during one
executeSearch shares a session: the same proxy and the same
transport state, like cookies or a browser container. Send follow-up
requests, such as resolving redirect links from the results page, through
context.fetch too, so the site sees one visitor instead of
several. Pass redirect: "manual" when you only need the
Location header.
Client exposure: The network indicator on extension cards in
Settings applies to plugins only, not search engines. Your
executeSearch calls always run on the server when you use
context.fetch. If your results include thumbnail or
imageUrl fields, the search theme may load those URLs in the
user's browser. Use context.signProxyUrl(url) so images are
served through the server instead. See
Declaring client exposure
for how plugins declare isClientExposed.
Set needsAppRestart = true if your engine cannot work correctly
until the Degoog server process restarts, for example because it registers
boot-time server behavior. When installed or updated via the Store, Degoog
will show a restart required warning on the extension and in the admin Server
tab until the instance owner restarts.
export const needsAppRestart = true;
Set challenges = ["anubis"] if the site puts an
Anubis
proof-of-work page in front of its results. When context.fetch
gets an Anubis page back, Degoog solves it, sends the pass request with the
cookies the page set, and repeats your request with the token it gets. It
keeps that token per site and transport, so every engine on the same site
shares one solve. Your engine sees the real page, unless the transport
handles challenges itself.
This works on transports that return response cookies or keep their own
cookie jar, such as fetch and curl-impersonate. The
plain curl transport drops cookies, so the search fails with an
interstitial error. Transports that set
handlesChallenges, like 4play, get the page as-is, because their
browser gets through it without help. Degoog also refuses challenges above
DEGOOG_ANUBIS_MAX_DIFFICULTY.
challenges = ["anubis"];
Engine routes
An engine can serve its own HTTP endpoints, the same way
plugin routes do. This is useful
when your results point at something the image proxy cannot fetch, such as
thumbnails that need an API key or that live on a private network. Export
routes as an array of { method, path, handler },
either on your engine object or class, or as a named export next to it.
method is get, post, put,
delete or patch, and handler(req)
receives the standard Request and returns a
Response.
Routes are served under /api/engine/<folderName>/, separate
from plugin routes, so an engine and a plugin from the same repository never
clash. They are public, like plugin routes, and answer 403 while the engine is
disabled in Settings. Paths are matched exactly; pass parameters in the query
string.
Every result thumbnail goes through the image proxy, including the ones your
engine serves. context.routeUrl(path) returns your route's address
on this instance, and the proxy fetches it like any other image, so the browser
never talks to your route or the service behind it directly. Because the proxy
fetches from this instance, it only works when Allow local images
is on in the image proxy settings, and not when Degoog listens on a unix socket.
Validate everything your route receives: anyone who can reach the instance can
call it.
export const type = "images";
export default class MyPhotos {
name = "My photos";
bangShortcut = "photos";
routes = [
{
method: "get",
path: "/thumb",
handler: async (req) => {
const id = new URL(req.url).searchParams.get("id") ?? "";
if (!/^[0-9a-f-]{36}$/.test(id)) return new Response(null, { status: 400 });
return fetch(`${this.baseUrl}/thumbnails/${id}`, { headers: { "x-api-key": this.apiKey } });
},
},
];
async executeSearch(query, page, timeFilter, context) {
const items = await this.search(query, context);
return items.map((item) => ({
title: item.name,
url: item.link,
snippet: "",
source: this.name,
thumbnail: context.routeUrl(`/thumb?id=${item.id}`),
}));
}
}
Setup
Create your data/engines/ directory or set your
DEGOOG_ENGINES_DIR. Add a single file like
my-engine.js or a folder with an index.js file. The
engine ID is the filename or folder name with an
-engine suffix (so my-engine becomes
my-engine-engine).
How settings work
-
Declare your
settingsSchemaso the Configure button appears in Settings then Engines. -
The user saves their preferences and the values are stored in
data/plugin-settings.json. -
Your
configure(settings)function is called right after saving and every time the server restarts. -
You can just return an empty array from
executeSearchif any required settings are missing.
Examples from the official store
-
Ecosia
is a web engine using
bangShortcutandcontext.fetch. - Startpage is another web engine featuring optional Anonymous View settings.
- Internet Archive is a file type engine that works perfectly as a dependency for the File tab plugin.
If you plan on distributing your engine through the
Store, make sure to add a
screenshots/ folder inside your engine folder so the Store card
looks great.