.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 114 of file marginalia.py.

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

◆ request()

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

Definition at line 86 of file marginalia.py.

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

◆ response()

searx.engines.marginalia.response ( SXNG_Response resp)

Definition at line 97 of file marginalia.py.

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

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 36 of file marginalia.py.

◆ api_key

searx.engines.marginalia.api_key = None

Definition at line 50 of file marginalia.py.

◆ base_url

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

Definition at line 45 of file marginalia.py.

◆ categories

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

Definition at line 47 of file marginalia.py.

◆ paging

bool searx.engines.marginalia.paging = False

Definition at line 48 of file marginalia.py.

◆ results_per_page

int searx.engines.marginalia.results_per_page = 20

Definition at line 49 of file marginalia.py.

◆ safesearch

bool searx.engines.marginalia.safesearch = True

Definition at line 46 of file marginalia.py.