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

Functions

 request (str query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ["it", "packages", "cargo"]
 
bool paging = True
 
int page_size = 10
 
str search_url = "https://crates.io/api/v1/crates"
 
 linked_terms
 

Detailed Description

Cargo search on crates.io

Function Documentation

◆ request()

searx.engines.crates.request ( str query,
params )

Definition at line 35 of file crates.py.

35def request(query: str, params):
36
37 args = urlencode({"page": params["pageno"], "q": query, "per_page": page_size})
38 params["url"] = f"{search_url}?{args}"
39 return params
40
41

◆ response()

searx.engines.crates.response ( resp)

Definition at line 42 of file crates.py.

42def response(resp):
43 results = []
44
45 for package in resp.json()["crates"]:
46
47 published_date = package.get("updated_at")
48 published_date = parser.parse(published_date)
49
50 links = {}
51 for k, v in linked_terms.items():
52 l = package.get(k)
53 if l:
54 links[v] = l
55
56 results.append(
57 {
58 "template": "packages.html",
59 "url": f'https://crates.io/crates/{package["name"]}',
60 "title": package["name"],
61 "package_name": package["name"],
62 "tags": package["keywords"],
63 "content": package["description"],
64 "version": package["newest_version"] or package["max_version"] or package["max_stable_version"],
65 "publishedDate": published_date,
66 "links": links,
67 }
68 )
69
70 return results

Variable Documentation

◆ about

dict searx.engines.crates.about
Initial value:
1= {
2 "website": "https://crates.io/",
3 "wikidata_id": None,
4 "official_api_documentation": "https://crates.io/data-access",
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": "JSON",
8}

Definition at line 9 of file crates.py.

◆ categories

list searx.engines.crates.categories = ["it", "packages", "cargo"]

Definition at line 18 of file crates.py.

◆ linked_terms

searx.engines.crates.linked_terms
Initial value:
1= OrderedDict(
2 [
3 ("homepage", "Project homepage"),
4 ("documentation", "Documentation"),
5 ("repository", "Source code"),
6 ]
7)

Definition at line 26 of file crates.py.

◆ page_size

int searx.engines.crates.page_size = 10

Definition at line 23 of file crates.py.

◆ paging

bool searx.engines.crates.paging = True

Definition at line 22 of file crates.py.

◆ search_url

str searx.engines.crates.search_url = "https://crates.io/api/v1/crates"

Definition at line 24 of file crates.py.