https://github.com/bukinoshita/npmstat
npm packages downloads stats
https://github.com/bukinoshita/npmstat
javascript nodejs npm package stat stats
Last synced: about 1 month ago
JSON representation
npm packages downloads stats
- Host: GitHub
- URL: https://github.com/bukinoshita/npmstat
- Owner: bukinoshita
- License: mit
- Created: 2017-07-06T15:41:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T23:49:32.000Z (over 2 years ago)
- Last Synced: 2025-02-28T02:11:14.430Z (about 2 months ago)
- Topics: javascript, nodejs, npm, package, stat, stats
- Language: JavaScript
- Homepage:
- Size: 292 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 15
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# npmstat [](https://travis-ci.org/bukinoshita/npmstat)
> npm package stats
## Install
```
$ npm install --save npmstat
```## Usage
```js
const npmstat = require('npmstat')npmstat.getPackage('npmstat').then(res => res)
// => { name: 'npmstat', description: 'npm package stats', ... }npmstat.getPackages('bukinoshita').then(res => res)
// => [{ name: 'react-cookies', version: '0.1.0', ... }, { name: 'is-github-repo', version: '0.2.0', ... }, ...]npmstat.getDownloads('react-cookies').then(res => res)
// => { downloads: 19271, package: 'react-cookies', ... }
```## API
### npmstat
### .getPackage(packageName)
Returns a `promise`
Get npm package information#### packageName
Type: `string`
RequiredPackage name
```js
npmstat.getPackage('npmstat')
.then(pkg => pkg)
.catch(err => err)
// => { name: 'npmstat', description: 'npm packages stats', ... }
```### .getPackages(username)
Returns a `promise`
Get user npm pkgs information#### username
Type: `string`
Requirednpm username
```js
npmstat.getPackages('bukinoshita')
.then(pkg => pkg)
.catch(err => err)
// => [{ name: 'react-cookies', version: '0.1.0', ... }, { name: 'is-github-repo', version: '0.2.0', ... }, ...]
```### .getDownloads(packageName, [options])
Returns a `promise`
Get npm package downloads count#### packageName
Type: `string`
RequiredPackage name
```js
npmstat.getDownloads('react-cookies')
.then(pkg => pkg)
.catch(err => err)
// => { downloads: 19271, package: 'react-cookies', ... }
```#### options
Type: `object`
##### range
Type: `string`
Default: `last-month`
Options: `last-day`, `last-week`, `last-month`, `YYYY-MM-DD` (specific date) or `YYYY-MM-DD:YYYY-MM-DD` (specific month)- **last-day**: Gets downloads for the last available day. In practice, this will usually be "yesterday" (in GMT) but if stats for that day have not yet landed, it will be the day before.
- **last-week**: Gets downloads for the last 7 available days.
- **last-month**: Gets downloads for the last 30 available days.```js
npmstat.getDownloads('react-cookies', { range: 'last-week' })
.then(pkg => pkg)
.catch(err => err)
// => { downloads: 19271, package: 'react-cookies', ... }
```##### type
Type: `string`
Default: `point`
Options: `point` or `range````js
npmstat.getDownloads('react-cookies', { type: 'range' })
.then(pkg => pkg)
.catch(err => err)
// => { package: 'react-cookies', downloads: [{ downloads: 100, day: '2017-06-8'}, ...], ... }
```## Related
- [npmstat-cli](https://github.com/bukinoshita/npmstat-cli) — CLI for this module
## License
MIT © [Bu Kinoshita](https://bukinoshita.io)