我正在寻找一种方法来查询npm REST API以返回相关结果。我想将搜索集成到我的应用程序中。
例如,如果我在npm中查询“bootstrap”,我会收到一堆结果,但不是第一页上的twitter bootstrap包:
请求
{"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}
结果
{"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}
个
如何提高NPM搜索的实用性?
yarnpkg.com 提供了一个很酷的搜索,但是这个搜索似乎并不打算公开访问,例如https://yarnpkg.com/en/packages?q=bootstrap&p=1
你有什么建议吗?
- 谢谢-谢谢
1条答案
按热度按时间ma8fv8wu1#
更新:感谢约书亚·特里尔的评论,新的正确URL已经更新。
要查询npm软件包信息,npmjs.com可以使用www.example.com的搜索URL:
对于Bootstrap,它是:
twitter Bootstrap将是最好的结果。