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

Functions

bool setup (dict[str, t.Any] engine_settings)
None request (str query, "OnlineParams" params)
EngineResults response ("SXNG_Response" resp)

Variables

dict about
list categories = ["science", "scientific publications"]
bool paging = True
int nb_per_page = 10
str api_key = ""
str base_url = "https://api.springernature.com/meta/v2/json"

Detailed Description

`Springer Nature`_ is a global publisher dedicated to providing service to
research community with official Springer-API_ (API-Playground_).

.. note::

   The Springer engine requires an API key, which can be obtained via the
   `Springer subscription`_.

Since the search term is passed 1:1 to the API, SearXNG users can use the
`Supported Query Parameters`_.

- ``!springer (doi:10.1007/s10948-025-07019-1 OR doi:10.1007/s10948-025-07035-1)``
- ``!springer keyword:ybco``

However, please note that the available options depend on the subscription type.

For example, the ``year:`` filter requires a *Premium Plan* subscription.

- ``!springer keyword:ybco year:2024``

The engine uses the REST Meta-API_ `v2` endpoint, but there is also a `Python
API Wrapper`_.

.. _Python API Wrapper: https://pypi.org/project/springernature-api-client/
.. _Springer Nature: https://www.springernature.com/
.. _Springer subscription:  https://dev.springernature.com/subscription/
.. _Springer-API: https://dev.springernature.com/docs/introduction/
.. _API-Playground: https://dev.springernature.com/docs/live-documentation/
.. _Meta-API: https://dev.springernature.com/docs/api-endpoints/meta-api/
.. _Supported Query Parameters: https://dev.springernature.com/docs/supported-query-params/


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

The engine has the following additional settings:

- :py:obj:`api_key`

.. code:: yaml

  - name: springer nature
    api_key: "..."
    inactive: false


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

Function Documentation

◆ request()

None searx.engines.springer.request ( str query,
"OnlineParams" params )

Definition at line 108 of file springer.py.

108def request(query: str, params: "OnlineParams") -> None:
109 args = {
110 "api_key": api_key,
111 "q": query,
112 "s": nb_per_page * (params["pageno"] - 1),
113 "p": nb_per_page,
114 }
115 params["url"] = f"{base_url}?{urlencode(args)}"
116 # For example, the ``year:`` filter requires a *Premium Plan* subscription.
117 params["raise_for_httperror"] = False
118
119

◆ response()

EngineResults searx.engines.springer.response ( "SXNG_Response" resp)

Definition at line 120 of file springer.py.

120def response(resp: "SXNG_Response") -> EngineResults:
121
122 res = EngineResults()
123 json_data = resp.json()
124
125 if (
126 resp.status_code == 403
127 and json_data["status"].lower() == "fail"
128 and "premium feature" in json_data["message"].lower()
129 ):
130 return res
131 raise_for_httperror(resp)
132
133 def field(k: str) -> str:
134 return str(record.get(k, ""))
135
136 for record in json_data["records"]:
137 published = datetime.strptime(record["publicationDate"], "%Y-%m-%d")
138 authors: list[str] = [" ".join(author["creator"].split(", ")[::-1]) for author in record["creators"]]
139
140 pdf_url = ""
141 html_url = ""
142 url_list: list[dict[str, str]] = record["url"]
143
144 for item in url_list:
145 if item["platform"] != "web":
146 continue
147 val = item["value"].replace("http://", "https://", 1)
148 if item["format"] == "html":
149 html_url = val
150 elif item["format"] == "pdf":
151 pdf_url = val
152
153 paper = res.types.Paper(
154 url=html_url,
155 # html_url=html_url,
156 pdf_url=pdf_url,
157 title=field("title"),
158 content=field("abstract"),
159 comments=field("publicationName"),
160 tags=record.get("keyword", []),
161 publishedDate=published,
162 type=field("contentType"),
163 authors=authors,
164 publisher=field("publisher"),
165 journal=field("publicationName"),
166 volume=field("volume"),
167 pages="-".join([x for x in [field("startingPage"), field("endingPage")] if x]),
168 number=field("number"),
169 doi=field("doi"),
170 issn=[x for x in [field("issn")] if x],
171 isbn=[x for x in [field("isbn")] if x],
172 )
173 res.add(paper)
174
175 return res

◆ setup()

bool searx.engines.springer.setup ( dict[str, t.Any] engine_settings)
Initialization of the Springer engine, checks whether the
:py:obj:`api_key` is set, otherwise the engine is inactive.

Definition at line 94 of file springer.py.

94def setup(engine_settings: dict[str, t.Any]) -> bool:
95 """Initialization of the Springer engine, checks whether the
96 :py:obj:`api_key` is set, otherwise the engine is inactive.
97 """
98 key: str = engine_settings.get("api_key", "")
99 try:
100 # Springer's API key is a hex value
101 int(key, 16)
102 return True
103 except ValueError:
104 logger.error("Springer's API key is not set or invalid.")
105 return False
106
107

Variable Documentation

◆ about

dict searx.engines.springer.about
Initial value:
1= {
2 "website": "https://www.springernature.com/",
3 "wikidata_id": "Q21096327",
4 "official_api_documentation": "https://dev.springernature.com/docs/live-documentation/",
5 "use_official_api": True,
6 "require_api_key": True,
7 "results": "JSON",
8}

Definition at line 65 of file springer.py.

◆ api_key

str searx.engines.springer.api_key = ""

Definition at line 85 of file springer.py.

◆ base_url

str searx.engines.springer.base_url = "https://api.springernature.com/meta/v2/json"

Definition at line 88 of file springer.py.

◆ categories

list searx.engines.springer.categories = ["science", "scientific publications"]

Definition at line 74 of file springer.py.

◆ nb_per_page

int searx.engines.springer.nb_per_page = 10

Definition at line 77 of file springer.py.

◆ paging

bool searx.engines.springer.paging = True

Definition at line 76 of file springer.py.