Query npmjs registry via api

I find I'm often unsatisfied with the ordering and expressiveness of searches on https://www.npmjs.com/. I guess there should be a way to programmatically query the server using https://api.npmjs.org/ or http://registry.npmjs.org/. But how? Where is the documentation?

(Or are there node packages to faciliate that? I know SO isn't about tool or package recommendations, so perhaps I shouldn't be asking about this as well, but if there were some tool, I could likely read the API from that as well.)


There is a really good npm query site https://npms.io which I am using for years on my web project. It is an open-source project and supports advanced search with a better quality of the results for the keywords.

They have a scoring system for each package using the collected information about the project. The final score is calculated based on four different aspects of Quality, Maintenance, Popularity, and Personalities.

It also has very neat REST API.
API Doc: https://api-docs.npms.io


Of course there is at least one tool designed to talk to that registry, and that is the npm command line tool itself. Its search for example starts by updating a local cached copy of the index, filtering that. In update-index one can read that the URL ending in /-/all is apparently special. And indeed, appending that to registry.npmjs.org (deliberately not formatted as a link) will fetch a 125M file which might be too much for your browser. Luckily the cached version is stored available in ~/.npm/registry.npmjs.org/-/all/.cache.json. From there one can read a list of all nown packages. One could then continue to query each such package in more detail.

The fact that npm search apparently uses no more elaborate scheme suggests that there is not much of a server-side api here.

Searching the web for pages mentioning api.npmjs.org I found that the download counts can be retrieved from there. All other documents I found make use of that single facility.

Looking for alternatives, I also stumbled upon npmsearch.com which offers some more versatile searching facilities and has a somewhat documented API.