Issue
I'm looking for a way to query the npm REST API to return relevant results. I want to integrate the search into my app.
F.e. If I query npm for "bootstrap" I'll receive a bunch of results, but not the twitter bootstrap package on the first page:
Request
curl https://npmsearch.com/query?q=bootstrap&fields=name,description,rating,version
Result
{"results":[{"name":["apta-bootstrap"],"version":["1.0.0"],"description":["apta bootstrap assets"]},{"name":["ender-bootstrap"],"version":["2.2.1"],"description":["Ender version of Twitter's Bootstrap JS (all plugins)"]},{"name":["bootstrap-extends"],"version":["1.0.1"],"description":["Useful extensions for Bootstrap 3"]},{"name":["bootstrap-submenu-hover"],"version":["2.0.8"],"description":["Bootstrap Sub-Menus"]},{"name":["bootstrap-submenu"],"version":["2.0.4"],"description":["Bootstrap Sub-Menus"]},{"name":["bootstrap-toggle-react"],"version":["0.1.6"],"description":["Bootstrap Toggle is a react component providing a toggle, based on www.bootstraptoggle.com"]},{"name":["bootstrap-layout-scrollable"],"version":["1.1.0"],"description":["Bootstrap Layout integration with Simplebar.js"]},{"name":["mithril-admin-bootstrap"],"version":["0.0.2"],"description":["Twitter Bootstrap plugin for mithril-admin"]},{"name":["bootstrap-checkbox"],"version":["1.4.0"],"description":["A checkbox component based on Bootstrap framework"]},{"name":["npmdoc-bootstrap-notify"],"version":["0.0.2"],"description":["#### api documentation for [bootstrap-notify (v3.1.3)](http://bootstrap-notify.remabledesigns.com/) [![npm package](https://img.shields.io/npm/v/npmdoc-bootstrap-notify.svg?style=flat-square)](https://www.npmjs.org/package/npmdoc-bootstrap-notify) [![tr"]}],"total":13546,"from":0}
How could I improve the practicality of the NPM search?
yarnpkg.com has done a good job providing a cool search, however the search doesn't seem to be intended to be accessed publically, i.e. https://yarnpkg.com/en/packages?q=bootstrap&p=1
Do you have any suggestions?
Thanks.
Solution
UPDATE: Thanks to Joshua Terrill's comment, the new correct URL has been updated.
To query npm package information, npmjs.com's search URL can be used:
https://registry.npmjs.com/-/v1/search?text=<search keyword>
For Bootstrap, it is:
https://registry.npmjs.com/-/v1/search?text=bootstrap
The twitter Bootstrap would be the top result.
Answered By - shaochuancs Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.