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

rest-tagging

v2.0.1

Published

A REST interface for redis-tagging

Downloads

16

Readme

REST Tagging

A REST interface for the Redis-Tagging module.

Use Redis-Tagging on other platforms (PHP, Ruby, Coldfusion, Python etc.) via this simple REST interface.

BREAKING MAJOR RELEASE 2.x

rest-tagging now uses [email protected]
For migration update Node.js to >= 14.0.0
Routes did not change. Only the underlying code was ported from coffee script to typescript.

Installation

  • Clone this repository
  • Run npm install to install the dependencies.
  • For the test make sure Redis runs locally and run npm test
  • Optional: Modify the default parameters (namespaces and Redis host) in config.json
  • Start the server: npm start

Methods

Redis Tagging uses the concept of buckets (you might call them namespaces). This way a single Redis Tagging instance can store ids and tags for multiple applications. A bucket name must be alphanumeric including - and _ and between 1 and 80 characters in length. There is no limit on ids and tags. They could include any character.

PUT /rt/id/:bucket/:id

Add or update an item. The URL contains the bucket (e.g. 'concerts') and the id for this item.

Parameters (as query parameters):

  • tags (String) A JSON string with an array of one or more tags (e.g. ["chicago","rock"])
  • score (Number) optional Default: 0 This is the sorting criteria for this item

Example:

PUT /rt/id/concerts/571fc1ba4d?score=20130823&tags=["rock","stadium"]

Returns:

true

DELETE /rt/id/:bucket/:id

Delete an item and all its tag associations.

Example: DELETE /rt/id/concerts/12345

Returns:

true

GET /rt/tags/:bucket?queryparams

The main method. Return the IDs for one or more tags. When more than one tag is supplied the query can be an intersection (default) or a union. type=inter (default) only those IDs will be returned where all tags match. type=union all IDs where any tag matches will be returned.

Parameters:

  • tags (String) a JSON string of one or more tags.
  • type (String) optional Either inter (default) or union.
  • limit (Number) optional Default: 100.
  • offset (Number) optional Default: 0 The amount of items to skip. Useful for paging thru items.
  • withscores (Number) optional Default: 0 Set this to 1 to also return the scores for each item.
  • order (String) optional Either asc or desc (default).

Example:

GET /rt/tags/concerts?tags=["Berlin","rock"]&limit=2&offset=4&type=inter

Returns:

{
    "total_items":108,
    "items":["8167","25652"],
    "limit":2,
    "offset":4
}

The returned data is item no. 5 and 6. The first 4 got skipped (offset=4). You can now do a

SELECT * FROM Concerts WHERE ID IN (8167,25652) ORDER BY Timestamp DESC

GET /rt/toptags/:bucket/:amount

Get the top n tags of a bucket.

Example:

GET /rt/toptags/concerts/3

Returns:

{
    "total_items": 18374,
    "items":[
        {"tag":"rock", "count":1720},
        {"tag":"pop", "count":1585},
        {"tag":"New York", "count":720}
    ]
}

GET /rt/id/:bucket/:id

Get all associated tags for an item. Usually this operation is not needed as you will want to store all tags for an item in you database.

Example:

GET /rt/id/concerts/12345

Returns:

[
    "rock",
    "stadium",
    "miami"
]

GET /rt/allids/:bucket

Get all IDs saved in a bucket.

Example:

GET /rt/allids/concerts

Returns:

[
    "id123",
    "id456",
    "id789"
]

GET /rt/buckets

List all buckets. Note: This uses redis.keys. Use with care! It will slow down Redis when lots of keys are stored in Redis.

Example:

GET /rt/buckets

Returns:

[
    "concerts",
    "vacations",
    "users"
]

DELETE /rt/removebucket/:bucket

Remove a single bucket.

Example:

DELETE /rt/removebucket/concerts

Returns:

true