1.0.8 • Published 4 years ago

npm-statistics v1.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

💨 Npm statistics

Find your npm packages download statistics.

npm.io npm.io npm.io

Installation

$ npm i npm-statistics
# or
$ yarn add npm-statistics

Usage

const { getAll, getOne } = require('npm-statistics');
// or
import { getAll, getOne } from 'npm-statistics';

Or include it via jsDelivr CDN:

<!-- axios is required -->
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/npm-statistics/build/index.js"></script>
<!-- access via object : NpmStats -> NpmStats.getAll(options) -->

Methods and examples

  • getAll(options: Object): Promise

let options = { 
  proxy: 'https://myproxy.com', // (optional) -> proxy url
  author: 'haikel',             // (required) -> npm username
  from: '2020-09-01',           // (optional) -> default: today - 1 year
  until: '2021-09-01',          // (optional) -> default: today
  exculde: ['xtra-fs']          // (optional) -> an array of packages to exclude
}

getAll(options).then(results => {
     console.log(results);
     /* {
      "packages": [
          { "name": "makeuid", "downloads": 274 },
          { "name": "envn", "downloads": 481 }
        ],
        "total": 9695
      } */ 
    })
  .catch(e => { console.log(e); });
  • getOne(options: Object): Promise

let options = { 
  proxy: 'https://myproxy.com', // (optional) -> proxy url
  name: 'axios',                // (required) -> npm package name
  from: '2020-09-01',           // (optional) -> default: today - 1 year
  until: '2021-09-01'           // (optional) -> default: today
}

getOne(options).then(result => { 
    console.log(result);  
    // { "package": "axios", "downloads": 111150 }
  })
  .catch(e => { console.log(e); })

CLI

  • Get all packages stats
nstats -all -author haikel -from 2020-02-02 -until 2021-02-02 -exclude axios,react
  • Get one packages stats
nstats -name axios -from 2020-02-02 -until 2021-02-02

Notes

  • All pull requests are welcome, feel free.

License

MIT

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago