Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Badge request: dependents of a npm package #1845

Open
sindresorhus opened this issue Aug 4, 2018 · 6 comments
Open

Badge request: dependents of a npm package #1845

sindresorhus opened this issue Aug 4, 2018 · 6 comments
Labels
good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs

Comments

@sindresorhus
Copy link

Would be nice to have a badge to show off how many npm packages depend on my package. For example, the 1717 Dependents number at https://www.npmjs.com/package/got.

You could either:

@paulmelnikow
Copy link
Member

The API doesn't match the number on the npm site. See chrisdickinson/npm-get-dependents#3. I confirmed that through my own experimentation with the endpoint it uses on the legacy npm registry mirror. (https://skimdb.npmjs.com/registry/_design/app/_view/dependedUpon)

Scraping npmjs is a nice solution, and more server capacity would enable that. See my proposal at #1742 (comment) and some actionable work in #1848.

I have an implementation using Libraries.io, which we've used elsewhere. (#1895) That API is on the slow side, but it works, and may be an acceptable option for the time being.

@platan platan added hacktoberfest Same as "good first issue" and removed hacktoberfest Same as "good first issue" labels Sep 30, 2018
@hiteshpr
Copy link

hiteshpr commented Oct 2, 2018

I can work on this.

@platan platan removed hacktoberfest Same as "good first issue" labels Nov 1, 2018
@paulmelnikow
Copy link
Member

I just learned about npms! We could base this on their API.

@paulmelnikow paulmelnikow changed the title Badge to show dependents of a npm package Badge request: dependents of a npm package Jan 28, 2019
@calebcartwright calebcartwright added the hacktoberfest Same as "good first issue" label Oct 2, 2019
@ainthek
Copy link

ainthek commented Oct 23, 2019

I just learned about npms! We could base this on their API.
I had a quick look at the API on npmjs, but is there any way to get dependents ? I did not find it. Thanx

@calebcartwright
Copy link
Member

I had a quick look at the API on npmjs, but is there any way to get dependents ? I did not find it.

Though it's not explicitly called out in the npms API docs, the API response does include a value for dependents count in collected.npm.dependentsCount

https://api.npms.io/v2/package/got

{ 
  "analyzedAt":"2019-10-19T11:32:46.782Z",
  "collected":{ 
    "metadata":{ .. },
    "npm":{ 
      "downloads":[ .. ],
      "dependentsCount":2349,
      "starsCount":124
    },
    "github":{ .. },
    "source":{ .. }
  },
  "evaluation":{ .. },
  "score":{ .. }
}

However, I think the same issue exists here relative to the counts being off. The registry shows (at the time of this post) 2,844 dependents for got whereas the API response from npms shows 2,349

@calebcartwright
Copy link
Member

Probably worth keeping tabs on npms-io/npms#37 over in the npms repo to see if there's an explanation for the descrepancy

@calebcartwright calebcartwright removed the hacktoberfest Same as "good first issue" label Nov 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

No branches or pull requests

7 participants