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

Functions

 init (_)
 
 request (query, params)
 
 response (resp)
 

Variables

dict about
 
str base_url = 'https://api.adsabs.harvard.edu/v1/search'
 
str result_base_url = 'https://ui.adsabs.harvard.edu/abs/'
 
int rows = 10
 
str sort = ''
 
list field_list = ['bibcode', 'author', 'title', 'abstract', 'doi', 'date']
 
str default_fields = ''
 
str query_fields = ''
 
bool paging = True
 
str api_key = 'unset'
 

Detailed Description

.. sidebar:: info

The Astrophysics Data System (ADS) is a digital library portal for researchers in astronomy and physics,
operated by the Smithsonian Astrophysical Observatory (SAO) under a NASA grant.
The engine is adapted from the solr engine.

Function Documentation

◆ init()

searx.engines.astrophysics_data_system.init ( _)

Definition at line 37 of file astrophysics_data_system.py.

37def init(_):
38 if api_key == 'unset':
39 raise SearxEngineAPIException('missing ADS API key')
40
41

◆ request()

searx.engines.astrophysics_data_system.request ( query,
params )

Definition at line 42 of file astrophysics_data_system.py.

42def request(query, params):
43 query_params = {'q': query, 'rows': rows}
44 if field_list:
45 query_params['fl'] = ','.join(field_list)
46 if query_fields:
47 query_params['qf'] = ','.join(query_fields)
48 if default_fields:
49 query_params['df'] = default_fields
50 if sort:
51 query_params['sort'] = sort
52
53 query_params['start'] = rows * (params['pageno'] - 1)
54
55 params['headers']['Authorization'] = f'Bearer {api_key}'
56 params['url'] = f"{base_url}/query?{urlencode(query_params)}"
57
58 return params
59
60

◆ response()

searx.engines.astrophysics_data_system.response ( resp)

Definition at line 61 of file astrophysics_data_system.py.

61def response(resp):
62 try:
63 resp_json = loads(resp.text)
64 except Exception as e:
65 raise SearxEngineAPIException("failed to parse response") from e
66
67 if 'error' in resp_json:
68 raise SearxEngineAPIException(resp_json['error']['msg'])
69
70 resp_json = resp_json["response"]
71 result_len = resp_json["numFound"]
72 results = []
73
74 for res in resp_json["docs"]:
75 author = res.get("author")
76
77 if author:
78 author = author[0] + ' et al.'
79
80 results.append(
81 {
82 'url': result_base_url + res.get("bibcode") + "/",
83 'title': res.get("title")[0],
84 'author': author,
85 'content': res.get("abstract"),
86 'doi': res.get("doi"),
87 'publishedDate': datetime.fromisoformat(res.get("date")),
88 }
89 )
90
91 results.append({'number_of_results': result_len})
92
93 return results

Variable Documentation

◆ about

dict searx.engines.astrophysics_data_system.about
Initial value:
1= {
2 "website": 'https://ui.adsabs.harvard.edu/',
3 "wikidata_id": 'Q752099',
4 "official_api_documentation": 'https://ui.adsabs.harvard.edu/help/api/api-docs.html',
5 "use_official_api": True,
6 "require_api_key": True,
7 "results": 'JSON',
8}

Definition at line 17 of file astrophysics_data_system.py.

◆ api_key

str searx.engines.astrophysics_data_system.api_key = 'unset'

Definition at line 34 of file astrophysics_data_system.py.

◆ base_url

str searx.engines.astrophysics_data_system.base_url = 'https://api.adsabs.harvard.edu/v1/search'

Definition at line 26 of file astrophysics_data_system.py.

◆ default_fields

str searx.engines.astrophysics_data_system.default_fields = ''

Definition at line 31 of file astrophysics_data_system.py.

◆ field_list

list searx.engines.astrophysics_data_system.field_list = ['bibcode', 'author', 'title', 'abstract', 'doi', 'date']

Definition at line 30 of file astrophysics_data_system.py.

◆ paging

bool searx.engines.astrophysics_data_system.paging = True

Definition at line 33 of file astrophysics_data_system.py.

◆ query_fields

str searx.engines.astrophysics_data_system.query_fields = ''

Definition at line 32 of file astrophysics_data_system.py.

◆ result_base_url

str searx.engines.astrophysics_data_system.result_base_url = 'https://ui.adsabs.harvard.edu/abs/'

Definition at line 27 of file astrophysics_data_system.py.

◆ rows

int searx.engines.astrophysics_data_system.rows = 10

Definition at line 28 of file astrophysics_data_system.py.

◆ sort

str searx.engines.astrophysics_data_system.sort = ''

Definition at line 29 of file astrophysics_data_system.py.