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

pnet

v0.1.1

Published

Node.js client for the Phish.net API

Downloads

7

Readme

pnet

pnet is an API client for the phish.net API. It comes with sane defaults, a command line interface and a module interface.

Install

npm install pnet

If you're planning on using the CLI, it's probably best to install it globally:

npm install -g pnet

Module Interface

get(method, params, callback) → undefined

Performs a GET against the phish.net API with the specified method and params.

  • method {String} - The phish.net API method. Preceeding 'pnet.' is optional.
  • params {Object} - Params to be passed in the API call.
  • callback {Function} - The function to be called when the request completes or errors out. The function will be passed three arguments, the first argument is an Error object if one has occurred or null. The second argument is the requested URL and the third is the parsed JSON response from the phish.net API.

apikey(key) → String or undefined

Sets a default phish.net API key. When called with no args, it returns the API key.

  • key {String|undefined|null} - When passed a value other than null or undefined, it sets the default API key to key. When called with 0 arguments, it returns the value that was set or undefined. When called explicitly with null or undefined, it unsets the current value of the API key from the default params.

Examples

var pnet = require('pnet');
var method = 'pnet.shows.query';
var params = {
  year: 2013,
  month: 8
}

// Set default API key to be used
pnet.apikey("a1b2c3");
pnet.apikey(); // => "a1b2c3"

pnet.get(method, params, function(err, url, parsedJSONResource){
  // do stuff
});

// Remove default apikey
pnet.apikey(undefined); // or:  pnet.apikey(null);
pnet.apikey(); // => undefined

Command Line Interface

USAGE: pnet method [options]

pnet shows.setlists.get -d 2013-10-31 -o ~/setlists/halloween_2013.json

-d, --date              Specify a `showdate` param to be used in API call.
                        Shorthand for '-p showdate:YYYY-MM-DD'
-o, --output            Output to file instead of STDOUT
-p, --params            Specify colon-delimited key value pairs as arguments to
                        the phish.net API; i.e. '-p venueid:123456 -p year:2012'

--configure             Specify colon-delimited key value pairs to be used as
                        defaults for all phish.net API calls through the CLI. i.e.
                        '--configure apikey=your-api-key --configure api:2.0'
--defaults              Print the defaults that have been set via the --configure
                        flag and exit
--list                  List the available phish.net API methods
--help                  Display this message and exit
--url-only              Print phish net API url and exit instead of
                        requesting the resource
--version               Print current version of this package and exit

CLI Examples

> pnet -p method:pnet.shows.setlists.get -p showdate:2013-10-31 -o ~/shows/halloween_2013.json

The following is shorthand for the above (optional preceeding "pnet." for the method):

> pnet shows.setlists.get -d 2013-10-31 -o ~/shows/halloween_2013.json

Since you're likely to have defaults for your API calls (i.e. apikey, api version, format), you can configure pnet with defaults.

> pnet --configure apikey:123456 --configure format:json --configure api:2.0

The above command will write those defaults to a file at ~/.pnet and will be used on subsequent API calls through the CLI. To list the defaults you have set, you can use the defaults flag.

> pnet --defaults
{
    "format": "json",
    "api": "2.0",
    "apikey": "123456"
}

The pnet CLI comes with its own set of defaults which can be found in config.json file in the root of this repository. The defaults are:

  • API base URL: https://api.phish.net/api.js
  • format: json
  • api: 2.0

If you want to print the phish.net request URL to STDOUT, you can provide the --url-only flag, i.e.

> pnet shows.setlists.get -d 2013-10-31 --url-only
https://api.phish.net/api.js?api=2.0&format=json&apikey=123456&method=pnet.shows.setlists.get&showdate=2013-10-31

Lastly, if you want to see all the methods phish.net exposes, just --list them:

pnet --list

License

MIT