PHPackages                             ingress-it-solutions/npm-registry-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ingress-it-solutions/npm-registry-api

ActiveLibrary[API Development](/categories/api)

ingress-it-solutions/npm-registry-api
=====================================

Fetch stats for your NPM packages from npm registry

1.0.0(3y ago)018MITPHPPHP ^8.0

Since Mar 20Pushed 3y agoCompare

[ Source](https://github.com/ingress-it-solutions/npm-registry-api)[ Packagist](https://packagist.org/packages/ingress-it-solutions/npm-registry-api)[ Docs](https://github.com/ingress-it-solutions/npm-registry-api)[ RSS](/packages/ingress-it-solutions-npm-registry-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Fetch stats for your NPM packages
=================================

[](#fetch-stats-for-your-npm-packages)

This package makes it easy to retrieve stats for packages hosted on [npmjs.com](https://www.npmjs.com/)

PS: It's heavily inspired by the [packagist-api package](https://github.com/spatie/packagist-api) made from Spatie

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require ingress-it-solutions/npm-registry-api
```

Usage
-----

[](#usage)

You must pass a Guzzle client to the constructor of `IngressITSolutions\NpmRegistry\NpmRegistry`.

```
$client = new \GuzzleHttp\Client();

$npmStats = new \IngressITSolutions\NpmRegistry\NpmRegistry($client);
```

### Get info for a package of your choice

[](#get-info-for-a-package-of-your-choice)

```
$npmStats->getRegistryInfo('vue');
```

### Get stats for a package of your choice

[](#get-stats-for-a-package-of-your-choice)

```
$npmStats->getStats('jquery');
```

### Get stats with a period of your choice

[](#get-stats-with-a-period-of-your-choice)

Use a constant provided by the NpmRegistry class to get stats for the last day, week, month, year or in total.

```
$npmStats->getStats('jquery', NpmRegistry::LAST_DAY);
```

You can also pass in specific dates

```
$npmStats->getStats('jquery', '2017-01-01');
```

Or even ranges

```
$npmStats->getStats('jquery', '2014-02-07:2014-02-14');
```

The output will be already decoded from json:

```
array(4) {
  ["downloads"]=>
  int(198672)
  ["start"]=>
  string(10) "2017-10-10"
  ["end"]=>
  string(10) "2017-10-10"
  ["package"]=>
  string(6) "jquery"
}
```

### Get stats with a period of your choice as range

[](#get-stats-with-a-period-of-your-choice-as-range)

You can also get the stats as a *range*, means the downloads split up per day:

```
$npmStats->getStats('jquery', NpmRegistry::LAST_WEEK, true);
```

And this would be the result of that call:

```
array(4) {
  ["start"]=>
  string(10) "2017-10-04"
  ["end"]=>
  string(10) "2017-10-10"
  ["package"]=>
  string(6) "jquery"
  ["downloads"]=>
  array(7) {
    [0]=>
    array(2) {
      ["downloads"]=>
      int(200678)
      ["day"]=>
      string(10) "2017-10-04"
    }
    [1]=>
    array(2) {
      ["downloads"]=>
      int(195593)
      ["day"]=>
      string(10) "2017-10-05"
    }
    [2]=>
    array(2) {
      ["downloads"]=>
      int(172132)
      ["day"]=>
      string(10) "2017-10-06"
    }
    [3]=>
    array(2) {
      ["downloads"]=>
      int(51068)
      ["day"]=>
      string(10) "2017-10-07"
    }
    [4]=>
    array(2) {
      ["downloads"]=>
      int(46892)
      ["day"]=>
      string(10) "2017-10-08"
    }
    [5]=>
    array(2) {
      ["downloads"]=>
      int(171920)
      ["day"]=>
      string(10) "2017-10-09"
    }
    [6]=>
    array(2) {
      ["downloads"]=>
      int(198672)
      ["day"]=>
      string(10) "2017-10-10"
    }
  }
}
```

### Get bulk stats

[](#get-bulk-stats)

Of course you can retrieve up to 128 packages as a bulk query. Simply separate them with a command and you are good to go.

```
$npmStats->getStats('vue,express', NpmRegistry::LAST_WEEK);
```

But beware! This only works in point mode, not in range mode.

```
$npmStats->getStats('vue,express', NpmRegistry::LAST_WEEK, true);
//Won't work
```

Anyway, the output will look similar to the normal point mode output:

```
array(2) {
  ["vue"]=>
  array(4) {
    ["downloads"]=>
    int(3980980980098089080980983)
    ["package"]=>
    string(5) "vue"
    ["start"]=>
    string(10) "2017-10-10"
    ["end"]=>
    string(10) "2017-10-10"
  }
  ["express"]=>
  array(4) {
    ["downloads"]=>
    int(818264)
    ["package"]=>
    string(7) "express"
    ["start"]=>
    string(10) "2017-10-10"
    ["end"]=>
    string(10) "2017-10-10"
  }
}
```

More in-depth info about the NPM stats API
------------------------------------------

[](#more-in-depth-info-about-the-npm-stats-api)

You can find a detailed explanation about how the stats API of NPM works in this [repository README file](https://github.com/npm/registry/blob/master/docs/download-counts.md)

Limits of the API
-----------------

[](#limits-of-the-api)

The official limits are:

- Bulk queries: 128 packages at a time and at most 365 days of data
- All other queries: limited to at most 18 months of data
- Earliest date available: January 10, 2015

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Ingress 2.0 Team](https://www.ingressit.com)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1149d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/47470909?v=4)[vandanafuletra](/maintainers/vandanafuletra)[@vandanafuletra](https://github.com/vandanafuletra)

---

Tags

apistatsnpmingress-it-solutions

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ingress-it-solutions-npm-registry-api/health.svg)

```
[![Health](https://phpackages.com/badges/ingress-it-solutions-npm-registry-api/health.svg)](https://phpackages.com/packages/ingress-it-solutions-npm-registry-api)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[get-stream/stream-chat

A PHP client for Stream Chat (https://getstream.io/chat/)

301.8M2](/packages/get-stream-stream-chat)[developmint/npm-stats-api

Fetch stats for your NPM packages

186.6k1](/packages/developmint-npm-stats-api)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
