Query npmjs registry via api

前端 未结 10 1590
走了就别回头了
走了就别回头了 2020-12-23 13:51

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

10条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 14:32

    If you can't find a package or are just hacking together a shell script the Registry API Docs in the registry's git repository include detailed information on Search API and search qualifiers.

    If you're looking for the most popular insecure package in the public registry run:

    wget -qO - "http://registry.npmjs.com/-/v1/search?text=is:insecure&popularity=1.0&size=1"
    

    The above uses the is:insecure search qualifier without any additional text criteria and grabs size=1 results where popularity=1.0 (the most popular).

    Check in the docs directory in the repo for a number of other useful things such as:

    • Detailed list of response Package Metadata.
    • Replicate API for scoped and unscoped packages.
    • Information on getting download counts.
    • Walkthrough on how to create a registry "follower".

提交回复
热议问题