npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nwire/api

v0.1.7

Published

Koa.js companion for REST API

Downloads

86

Readme

API Query

Example


const query = 'status=sent&timestamp>2016-01-01&author.firstName=/john/i&limit=100&skip=50&sort=-timestamp&populate=logs&fields=id,logs.ip'
const result = {     filter: {         status: 'sent',         timestamp: { $gt: new Date('Fri Jan 01 2016 01:00:00 GMT+0100 (CET)') },         'author.firstName': /john/i }, sort: { timestamp: -1 }, skip: 50, limit: 100, projection: { id: 1 }, population: [ { path: 'logs', select: { ip: 1 } } ]
}

Supported features

Filtering operators

| MongoDB | URI | Example |
| --------- | -------------------- | ----------------------- | | $eq | key=val | type=public | | $gt | key>val | count>5 | | $gte | key>=val | rating>=9.5 | | $lt | key<val | createdAt<2016-01-01 | | $lte | key<=val | score<=-5 | | $ne | key!=val | status!=success | | $in | key=val1,val2 | country=GB,US | | $nin | key!=val1,val2 | lang!=fr,en | | $exists | key | phone | | $exists | !key | !email | | $regex | key=/value/<opts> | email=/@gmail\.com$/i | | $regex | key!=/value/<opts> | phone!=/^06/ |

For more advanced usage ($or, $type, $elemMatch, etc.), pass any MongoDB query filter object as JSON string in the filter query parameter, ie:

'filter={"$or":[{"key1":"value1"},{"key2":"value2"}]}'

Skip / Limit operators

'skip=5&limit=10'

Projection operator

  • It accepts a comma-separated list of fields. Default behavior is to specify fields to return. Use - prefixes to return all fields except some specific fields.
  • Due to a MongoDB limitation, you cannot combine inclusion and exclusion semantics in a single projection with the exception of the _id field.
  • It also accepts JSON string to use more powerful projection operators ($, $elemMatch or $slice)
'fields=id,url'
'fields=-_id,-email'
'fields={"comments":{"$slice":[20,10]}}'

Sort operator

  • It accepts a comma-separated list of fields. Default behavior is to sort in ascending order. Use - prefixes to sort in descending order.
'sort=-points,createdAt'

Population operator

  • It accepts a comma-separated list of fields.
  • It extracts projection on populated documents from the projection object.
'populate=a,b&fields=foo,bar,a.baz'

Keys with multiple values

Any operators which process a list of fields ($in, $nin, sort and projection) can accept a comma-separated string or multiple pairs of key/value:

  • country=GB,US is equivalent to country=GB&country=US
  • sort=-createdAt,lastName is equivalent to sort=-createdAt&sort=lastName

Embedded documents using . notation

Any operators can be applied on deep properties using . notation:

'followers[0].id=123&sort=-metadata.created_at'