.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.marginalia Namespace Reference

Classes

class  ApiSearchResult
class  ApiSearchResults

Functions

 request (str query, dict[str, t.Any] params)
 response (SXNG_Response resp)
 init (dict[str, t.Any] engine_settings)

Variables

dict about
str base_url = "https://api.marginalia.nu"
bool safesearch = True
list categories = ["general"]
bool paging = False
int results_per_page = 20
 api_key = None

Detailed Description

`Marginalia Search`_ is an independent open source Internet search engine
operating out of Sweden. It is principally developed and operated by Viktor
Lofgren .

.. _Marginalia Search:
   https://about.marginalia-search.com/

Configuration
=============

The engine has the following required settings:

- :py:obj:`api_key`

You can configure a Marginalia engine by:

.. code:: yaml

   - name: marginalia
     engine: marginalia
     shortcut: mar
     api_key: ...

Implementations
===============

Function Documentation

◆ init()

searx.engines.marginalia.init ( dict[str, t.Any] engine_settings)

Definition at line 115 of file marginalia.py.

115def init(engine_settings: dict[str, t.Any]):
116
117 _api_key = engine_settings.get("api_key")
118 if not _api_key:
119 logger.error("missing api_key: see https://about.marginalia-search.com/article/api")
120 return False
121
122 if _api_key == "public":
123 logger.error("invalid api_key (%s): see https://about.marginalia-search.com/article/api", api_key)
124
125 return True

◆ request()

searx.engines.marginalia.request ( str query,
dict[str, t.Any] params )

Definition at line 87 of file marginalia.py.

87def request(query: str, params: dict[str, t.Any]):
88
89 query_params = {
90 "count": results_per_page,
91 "nsfw": min(params["safesearch"], 1),
92 }
93
94 params["url"] = f"{base_url}/{api_key}/search/{quote_plus(query)}?{urlencode(query_params)}"
95 params["headers"]["User-Agent"] = searxng_useragent()
96
97

◆ response()

searx.engines.marginalia.response ( SXNG_Response resp)

Definition at line 98 of file marginalia.py.

98def response(resp: SXNG_Response):
99
100 res = EngineResults()
101 resp_json: ApiSearchResults = resp.json() # type: ignore
102
103 for item in resp_json.get("results", []):
104 res.add(
105 res.types.MainResult(
106 title=item["title"],
107 url=item["url"],
108 content=item.get("description", ""),
109 )
110 )
111
112 return res
113
114

Variable Documentation

◆ about

dict searx.engines.marginalia.about
Initial value:
1= {
2 "website": "https://marginalia.nu",
3 "wikidata_id": None,
4 "official_api_documentation": "https://about.marginalia-search.com/article/api/",
5 "use_official_api": True,
6 "require_api_key": True,
7 "results": "JSON",
8}

Definition at line 37 of file marginalia.py.

◆ api_key

searx.engines.marginalia.api_key = None

Definition at line 51 of file marginalia.py.

◆ base_url

str searx.engines.marginalia.base_url = "https://api.marginalia.nu"

Definition at line 46 of file marginalia.py.

◆ categories

list searx.engines.marginalia.categories = ["general"]

Definition at line 48 of file marginalia.py.

◆ paging

bool searx.engines.marginalia.paging = False

Definition at line 49 of file marginalia.py.

◆ results_per_page

int searx.engines.marginalia.results_per_page = 20

Definition at line 50 of file marginalia.py.

◆ safesearch

bool searx.engines.marginalia.safesearch = True

Definition at line 47 of file marginalia.py.