我正在尋找一種方法來查詢npm REST API以返回相關結果。我想將搜索集成到我的應用程序中。如何查詢NPM REST API搜索以獲得相關結果?
F.e.如果我查詢故宮的「引導」我收到了一堆的結果,但不是的 Twitter的引導包的第一頁上:
請求
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}
我怎麼可以即興e NPM搜索的實用性?
yarnpkg.com已經做了很好的工作提供了一個很酷的搜索,但是搜索似乎並不意在被公開訪問,即 https://yarnpkg.com/en/packages?q=bootstrap&p=1
你有什麼建議嗎?
謝謝。
要查詢npm包信息,您可以使用npmjs.com的搜索URL。對於Bootstrap,它是:https://www.npmjs.com/-/search?text=bootstrap twitter Bootstrap將是最重要的結果。 – shaochuancs
謝謝。那就是我需要的。 –
歡迎。這些信息已作爲答案發布,以便其他訪問此問題的人可以快速獲得答案。 – shaochuancs