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

pitchfork

v0.0.16

Published

An Unofficial Pitchfork Music API client for Node.js

Downloads

35

Readme

#Pitchfork Client

Travis CI

An unofficial Node.js client for Pitchfork reviews based on the Pitchfork API Client for Python.

Install

Using NPM

npm install pitchfork

Using Github

git clone [email protected]:omardelarosa/pitchfork-npm.git

You can then use it as a command-line tool or as a node module

##API

You can require pitchfork and use it inside of any Node.JS application.

var p4k = require('pitchfork')

Search

A Search constructor that extends EventEmitter. Listeners can be attached to the 'ready' event which will fire when all reviews have been fetched and parsed. For example:


var p = require('pitchfork')
var s = new p.Search('wilco')

s.on('ready', function(results){
  console.log("results", results)
})

//=> [ {Review}, {Review}, {Review}, ... ]

.results

An Array of Review objects.

.init()

Called once when Search is instantiated to fetch results. Not usually called directly

Page

A Page constructor that extends EventEmitter. This constructor takes an integer argument specifying which page of reviews you wish to fetch from /reviews/albums/:page_num. Listeners can be attached to the 'ready' event which will fire when all reviews have been fetched and parsed. For example, this would return all the most recent reviews:


var p = require('pitchfork')
var s = new p.Page(1)

s.on('ready', function(results){
  console.log("results", results)
})

//=> [ {Review}, {Review}, {Review}, ... ]

Review

The Review constructor encapsulates methods and data relating to the Pitchfork review. The Review extends EventEmitter and fires a 'ready' event when the review has been fetched and parsed.

.attributes

An Object with information about the album and its text. Sample below:

{
  "url": "/reviews/albums/9419-the-letting-go/",
  "name": "Bonnie \"Prince\" Billy - The Letting Go",
  "artist": "Bonnie \"Prince\" Billy",
  "album": "The Letting Go",
  "title": "Bonnie \"Prince\" Billy: The Letting Go | Album Reviews | Pitchfork",
  "label": "Palace / Drag City",
  "year": "2006",
  "score": 8.2,
  "cover": "http://cdn.pitchfork.com/albums/9255/homepage_large.e8a2bd20.jpg",
  "author": "Mark Richardson",
  "date": "September 18, 2006",
  "editorial": {
    "text": "...",
    "html": "..."
}

.fetch()

This method is automatically called when the Review is instantiated and returns a Promise. This generally isn't called directly.

.promise

This stores the thennable promise object generated by .fetch for attaching .then-style callbacks.

.verbose()

The full Review instance represented as JSON.

{
  "url": "/reviews/albums/9419-the-letting-go/",
  "name": "Bonnie \"Prince\" Billy - The Letting Go",
  "artist": "Bonnie \"Prince\" Billy",
  "album": "The Letting Go",
  "title": "Bonnie \"Prince\" Billy: The Letting Go | Album Reviews | Pitchfork",
  "label": "Palace / Drag City",
  "year": "2006",
  "score": 8.2,
  "cover": "http://cdn.pitchfork.com/albums/9255/homepage_large.e8a2bd20.jpg",
  "author": "Mark Richardson",
  "date": "September 18, 2006",
  "editorial": {
    "html": " <p>Though Will Oldham began his musical career while in his early twenties, ... deep absorption or self-reflection so much as a kind of fond familiarity. </p> ",
    "text": " Though Will Oldham began his musical career while in his early twenties ... deep absorption or self-reflection so much as a kind of fond familiarity.  "
  }
}

.truncated()

The attributes of the Review instance with editorial.html/editorial.text condensed into the first 300 characters of of the text assigned to the key '.text'.

{
  "url": "/reviews/albums/9419-the-letting-go/",
  "name": "Bonnie \"Prince\" Billy - The Letting Go",
  "artist": "Bonnie \"Prince\" Billy",
  "album": "The Letting Go",
  "title": "Bonnie \"Prince\" Billy: The Letting Go | Album Reviews | Pitchfork",
  "label": "Palace / Drag City",
  "year": "2006",
  "score": 8.2,
  "cover": "http://cdn.pitchfork.com/albums/9255/homepage_large.e8a2bd20.jpg",
  "author": "Mark Richardson",
  "date": "September 18, 2006",
  "text": " Though Will Oldham began his musical career while in his early twenties, he's never exactly sounded young. From his first releases as Palace Music, Oldham's whiskey-soaked vocals and lyrical obsessions with death, sex, and religion have made \"maturity\" something of a non-issue. And yet, with his mo..."
}

.text_pretty_print()

Prints a plain-text representation of the review.

CLI (Command-Line Interface)

Returns a review for a given artist and album title.

$ pitchfork wilco 'yankee hotel foxtrot'
# { ... pretty-printed, colorized quasi-JSON object... }

or you can use -a and -t flags.

$ pitchfork -a wilco -t 'yankee hotel foxtrot'
# { ... pretty-printed, colorized quasi-JSON object... }

Returns a list of reviews for a given artist with no album.

$ pitchfork -a 'wilco'
# [ 
#    { ... pretty-printed, colorized quasi-JSON object... },
#    { ... pretty-printed, colorized quasi-JSON object... },
#    { ... pretty-printed, colorized quasi-JSON object... }
# ]

For valid, uncolored JSON, use the --json flag:

$ pitchfork -a 'wilco' -t 'yankee hotel foxtrot' --json
# { ... valid JSON object... }

Flags

| flag(s) | required | argument | description | | ------- | ---- | --------- | ------------ | | -a | y | artist_name | returns a review by given artist | | -t | | album_title | returns a review by given album title | | -j,--json | | | returns review attributes as un-prettified json | | -v, --verbose | | | returns review entire object as json | | -V, --version | | | returns version number | | -T,--truncated | | | returns a truncated json object of the review attributes | | -tx,--text | | | returns a text version of review (ex: to pipe output to 'less' ) | | -p | | page_number | returns a list of reviews located on the specified page