api in npm for getting the number or list of dependent packages?

453 views
Skip to first unread message

Gregg Caines

unread,
May 4, 2013, 3:52:54 PM5/4/13
to nod...@googlegroups.com
Hey all, does anyone know if npm has an API (or couchdb view) for getting the list (or just the count) of dependent packages of a given package ?  I suspect it does since npmjs.org has the info.

I know there's an npm mailing list, but it mysteriously won't let me post.  Thanks!

G

Martin Cooper

unread,
May 4, 2013, 4:33:01 PM5/4/13
to nod...@googlegroups.com
The simplest way is to grab the package metadata from the registry with this URL:

That will get you a JSON version of the same object you see with 'npm view <package>', at which point you can just pluck out the 'dependencies' object.

--
Martin Cooper




--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gregg Caines

unread,
May 4, 2013, 4:37:25 PM5/4/13
to nod...@googlegroups.com
I'm actually looking for the opposite... the dependants, not the dependencies.  For a given package x, it's the list of all the packages that depend on x.

G


You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/_H8sH6qWozs/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.

Isaac Schlueter

unread,
May 6, 2013, 12:19:40 PM5/6/13
to nodejs
Yes, you can use the "dependedUpon" view in the couchdb.

For example, to find all the packages that depend on "request":
http://isaacs.iriscouch.com/registry/_design/app/_view/dependedUpon?startkey=[%22request%22]&endkey=[%22request%22,{}]&group_level=2

That's what the npmjs.org site uses. Note that you can always dive
into the code to find out how it does stuff:
https://github.com/isaacs/npm-www
Reply all
Reply to author
Forward
0 new messages