PunkAPI Javascript Wrapper

This weekend I created a Javascript wrapper for the PunkAPI - an unofficial API for querying beers from the BrewDog DIY catalog. Even if you're a developer some of that might not have made sense.

BrewDog is a brewery, started in 2005 in Aberdeen, Scotland, who now operates dozens of beer bars around the world. They recently broke into the U.S. market with a brewery in my hometown of Columbus, Ohio. They produce great beers and make the recipes for past brews available through the DIY Dog website.

There's no official API for the DIY catalog so @samjbmason and others scraped the info from the DIY website and created an unofficial API.

Their API is accessible via HTTPS and is CORS-enabled, meaning it will work for client-side requests with JS.

By itself the API is straightforward. There are 3 endpoints

  • returning a specific beer, a list of beers based on filter options and a random beer. It would be relatively easy to implement the API in most apps.

I wanted to make it even easier though, so I created an Javascript wrapper to abstract the API into a few simple commands.

The PunkAPI Javascript Wrapper

My PunkAPI Javascript Wrapper is available as a npm module, bower component or regular JS library. This should be flexible enough for nearly any implementation from vanilla JS to Webpack and Node.

There are 3 ways to install it.

  • Clone the repo from Github into your project

  • Install with npm using `npm install --save punkapi-javascript-wrapper

  • Install with bower using bower install --save punkapi-javascript-wrapper

Once the wrapper is installed it can be implemented as a library (by adding the /dist/punkapi-javascript-wrapper.js) or via a require().

Once installed there are 3 methods available to retrieve beers:

  • getRandom()
  • getBeers({options})
  • getBeer(id)

All 3 return a Promise so a callback function can be called.

Here's a quick example:

const PunkAPIWrapper = require('punkapi-javascript-wrapper')

const punkAPI = new PunkAPIWrapper()

const randomBeer = punkAPI.getRandom()

randomBeer.then(beer => {

More info and examples available on the README.