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

Functions

 request (str query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['it', 'packages']
 
bool paging = True
 
int page_size = 25
 
str search_api = "https://api.npms.io/v2/search?"
 

Detailed Description

npms.io

Function Documentation

◆ request()

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

Definition at line 28 of file npm.py.

28def request(query: str, params):
29
30 args = urlencode(
31 {
32 'from': (params["pageno"] - 1) * page_size,
33 'q': query,
34 'size': page_size,
35 }
36 )
37 params['url'] = search_api + args
38 return params
39
40

◆ response()

searx.engines.npm.response ( resp)

Definition at line 41 of file npm.py.

41def response(resp):
42 results = []
43 content = resp.json()
44 for entry in content["results"]:
45 package = entry["package"]
46 publishedDate = package.get("date")
47 if publishedDate:
48 publishedDate = parser.parse(publishedDate)
49 tags = list(entry.get("flags", {}).keys()) + package.get("keywords", [])
50 results.append(
51 {
52 "template": "packages.html",
53 "url": package["links"]["npm"],
54 "title": package["name"],
55 'package_name': package["name"],
56 "content": package.get("description", ""),
57 "version": package.get("version"),
58 "maintainer": package.get("author", {}).get("name"),
59 'publishedDate': publishedDate,
60 "tags": tags,
61 "homepage": package["links"].get("homepage"),
62 "source_code_url": package["links"].get("repository"),
63 }
64 )
65
66 return results

Variable Documentation

◆ about

dict searx.engines.npm.about
Initial value:
1= {
2 "website": "https://npms.io/",
3 "wikidata_id": "Q7067518",
4 "official_api_documentation": "https://api-docs.npms.io/",
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": "JSON",
8}

Definition at line 10 of file npm.py.

◆ categories

list searx.engines.npm.categories = ['it', 'packages']

Definition at line 19 of file npm.py.

◆ page_size

int searx.engines.npm.page_size = 25

Definition at line 24 of file npm.py.

◆ paging

bool searx.engines.npm.paging = True

Definition at line 23 of file npm.py.

◆ search_api

str searx.engines.npm.search_api = "https://api.npms.io/v2/search?"

Definition at line 25 of file npm.py.