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 🙏

© 2025 – Pkg Stats / Ryan Hefner

link-context

v0.0.12

Published

A short url generator, allowing for arbitary data to be attributed to the link

Readme

Short URLs with context

A simple server to generate unique short URLs and attach some contextual data to them.

A live version is available for testing http://asc.li for testing purposes.

An example using the API has is also available on http://addsumcontext.com

Usage

Create a new short link GET /v0/new/link/

http://localhost/v0/new/link/?context=`CONTEXT`&redirect=`REDIRECT`

CONTEXT can be any arbitrary string and is the data we want to attach to the link we are about to create.

REDIRECT where do you want the short link to go when clicked on. Must be a valid URL.

Example:

http://asc.li/v0/new/link?context=bob&redirect=http://ubunutu.com

response --> {
  "link": "http://asc.li/obdkf21"
}

This attaches the data bob to our link and will redirect to http://ubuntu.com when someone clicks on the new http://asc.li/obdkf21 link.

### Getting link statistics

Find by specific short URL GET /v0/link/

http://localhost/v0/link/?path=`PATH`

PATH The short URL we want statistics for.

Example:

http://asc.li/v0/link/?path=http://asc.li/obdkf21

response --> {
  "context": "bob",
  "clicks": 17,
  "link": "http://asc.li/obdkf21",
  "redirect": "http://ubuntu.com"
}

Here we have retrieved the data from the example above. Currently the only additional data tracked is the number of clicks the link has had.

Match on context GET /v0/search/

http://localhost/v0/search/?context=`CONTEXT`

CONTEXT The context you want to search for (does not need to be exact match)

Example:

http://localhost/v0/search/?context=bo

response --> [{
    "context": "bob",
    "clicks": 17,
    "link": "http://asc.li/obdkf21",
    "redirect": "http://ubuntu.com"
  }]

Here we have retrieved an array of objects matching the search criteria of bo. If no results are found an empty array is returned.

Running Locally

If you don't want to use http://asc.li and would rather run your own instance:

$ npm install link-context
$ cd node_modules/link-context
$ npm start

Requirements:

  • node/npm ~ 0.10.33
  • MongoDB ~ 2.6.x

In you want the server running constantly, bring it up with naught:

$ naught start server.js

Requirements:

  • naught installed globally

If you're using naught and running Ubuntu, take a look at the service.sh file. Copy it to /etc/init.d/link-context and setup the configuration variables as defined below in the service file. SERVER_DIR also needs to be defined, which should be where you have link-context installed.

# Start, stop, restart the server
$ service link-context start | stop | restart

##### CONFIG Configuration can be done by setting the following environmental variables.

| Environmental Variable | Description | |:-----------------------|:-------------------------------------------------------------------------| | CONTEXT_SEED | shortid seed | | CONTEXT_PORT | Port the server will run on (default 8000) | | CONTEXT_DOMAIN | Domain your server is running, e.g. http://asc.li |

### Authentication

There is currently no authentication supported. The aim is to make it as easy as possible to test in a browser or with cURL. If your link context is not open data, run your own instance and use a firewall to limit access to the API.

TODO: Token based authentication coming soon to the http://asc.li incase you don't want to maintain your own instance ;)