当前位置:网站首页>Qiao NPMS: get the download volume of NPM packages

Qiao NPMS: get the download volume of NPM packages

2022-06-11 08:23:00 uikoo9

【 Preface 】

A common requirement is to get something npm Package Downloads ,

Yes, of course npm The official website enters a npm Package details page ,

But when you maintain multiple npm When the package , It's more troublesome

【 obtain npm Package downloads 】

npm The official has access to a npm The opening of package downloads api, See :

registry/download-counts.md at master · npm/registry · GitHub

adopt get Request this interface

GET https://api.npmjs.org/downloads/point/{period}[/{package}]

There are two parameters

period, Time range , Common are last-day,last-week,last-month etc.

package, The package name you want to query

【qiao-npms】

Will be common last-day,last-week,last-month Do the packaging , See :

qiao-npms - npm

downloadCountsLastDay

'use strict';

var q = require('qiao-npms');

var test = async function(){
    try{
        var packageName = 'qiao-cos';
        var res = await q.downloadCountsLastDay(packageName);
        console.log(res);
    }catch(e){
        console.log(e);
    }
};

test();

 return

{
  downloads: 0,
  start: '2022-06-08',
  end: '2022-06-08',
  package: 'qiao-cos'
}

downloadCountsLastWeek

'use strict';

var q = require('qiao-npms');

var test = async function(){
    try{
        var packageName = 'qiao-cos';
        var res = await q.downloadCountsLastWeek(packageName);
        console.log(res);
    }catch(e){
        console.log(e);
    }
};

test();

return

{
  downloads: 80,
  start: '2022-06-02',
  end: '2022-06-08',
  package: 'qiao-cos'
}

downloadCountsLastMonth

'use strict';

var q = require('qiao-npms');

var test = async function(){
    try{
        var packageName = 'qiao-cos';
        var res = await q.downloadCountsLastMonth(packageName);
        console.log(res);
    }catch(e){
        console.log(e);
    }
};

test();

return

{
  downloads: 763,
  start: '2022-05-10',
  end: '2022-06-08',
  package: 'qiao-cos'
}

downloadCounts

'use strict';

var q = require('qiao-npms');

var test = async function(){
    try{
        var packageName = 'qiao-cos';
        var res = await q.downloadCounts(packageName, 'last-day');
        console.log(res);
    }catch(e){
        console.log(e);
    }
};

test();

return

{
  downloads: 0,
  start: '2022-06-08',
  end: '2022-06-08',
  package: 'qiao-cos'
}

【qiao-lerna】

qiao-npms It is a tool to obtain the download volume of a single package ,

If you want to count multiple npm The amount of package downloads can be used qiao-lerna,

qiao-lerna - npm

Usage method , See :

https://uikoo9.blog.csdn.net/article/details/125215862

【 summary 】

1.qiao-npms, Easy access npm Package downloads

2.qiao-lerna, Batch acquisition npm Package downloads

原网站

版权声明
本文为[uikoo9]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110817128345.html