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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@prejt/resource-api

v0.1.25

Published

Resource api

Readme

Common behavior for (almost) all endpoints

There are 3 types of endpoints now

  • /api/resource/:resourceName - endpoints for administration - authentication is needed
  • /api/public/:resourceName - public endpoints (only read only) - without authentication
  • /api/custom/:name - there can be also custom non-resource endpoints

GET method for reading data in format

  • /api/resource/:resourceName - for collection of items
  • /api/resource/:resourceName/:id - for single item by id

For collections

Collections are returned as arrays of objects (items), request for collection can have following query parameters:

Format

/api/resource/:resourceName?format=id,name

It defines which attributes from item object will be returned (for every item in collection)

  • Attributes are separated by ','
    • /api/custom/event?format=id,name
  • It can also return deep parameters in related objects (as sub objects)
    • /api/custom/event?format=id,name,place.name
  • If there can be more related objects, it will return them as array (every object in the array will be formatted)
    • /api/custom/event?format=id,name,tournament.name will return:
    [{
    	id: 1,
    	name: 'event name',
    	tournament: [{
    		name: 'singles'
    	}, {
    		name: 'doubles'
    	}]
    }]
  • If without format, it will return all allowed attributes of base object (without relations)
  • (TBD) Can use '*' in format to return all allowed attributes of base object (without relations)
    • /api/custom/event?format=*,tournament.name - it will return base attributes of event + tournament array with name
Format functions

/api/resource/:resourceName?format=id,date(date_start)

  • only functions for formatting dates are available now
    • date
    • dateTime
  • it wraps format attribute (is first parameter of function, other parameters are for formating and depends on function)
  • '*' can't be used in format function
  • if function is used without name, it will use object format function as default
    • first parameter is name of field which should be formatted, other parameters are fields which should be returned by formatting (if none of them are supplied, whole entity without formatting is returned)
    • /api/custom/event?format=id,name,(place,id,name) is equivalent to /api/custom/event?format=id,name,place.id,place.name
  • functions can be nested
    • /api/custom/event?format=id,name,(tournament,,(tableType,,(manufacturer,*))) is equivalent to:
    • /api/custom/event?format=id,name,tournament.,tournament.tableType.,tournament.tableType.manufacturer.*

Filters

  • Filters are query parameters with prefix f.
    • For example: /api/custom/event?f.place_id=4 will return all events with place_id=4
    • if there is no compare function used, equal is used as default (==)
    • if there are more filters defined, only items which meets all of them are returned (logical AND)
    • compare function wraps value of filter in url, for example:
      • /api/custom/tournament?f.attendance=gt(10) will return tournaments with attendance greater then 10
      • List of compare functions:
        • gt(value)
        • lt(value)
        • gte(value)
        • lte(value)
        • like(partOfText)

Paginating

  • query parameter limit - how many items should be returned
  • query parameter offset - from which item to start

Ordering

  • query parameter order with attributes separated by ','
    • attribute without prefix - asc
    • attribute with '-' prefix - desc
  • example:
    • /api/resource/:resourceName?order=attr1,-attr2

For single records

/api/resource/:resourceName/:id

  • returned record is defined by id in url
  • format can be specified in the same style as for collections