我正在寻找一种查询npm REST API以返回相关结果的方法。我想将搜索集成到我的应用程序中。
F.e。如果我查询npm的“bootstrap”,我会收到一堆结果,但第一页上的不是 twitter bootstrap包:
请求
curl https://npmsearch.com/query?q=bootstrap&fields=name,description,rating,version
结果
{"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
你有什么建议吗?
感谢。
答案 0 :(得分:0)
要查询npm包信息,可以使用npmjs.com的搜索URL:
http://npmjs.com/-/search?text=<search keyword>
对于Bootstrap,它是:
http://npmjs.com/-/search?text=bootstrap
Twitter Bootstrap将是最好的结果。