node-brewerydb
v0.1.0
Published
Service library for www.brewerydb.com
Downloads
3
Readme
Node BreweryDB wrapper
This is a node package (WIP) wrapper for the http://www.brewerydb.com/ service API.
Setup
Install the library.
npm instal https://github.com/DanielOchoa/node-brewery-db
Import the library.
var BreweryDb = require('node-brewerydb');
Create a new instance by passing an object with the apiKey
.
var client = new BreweryDb({apiKey: yourApiKey});
How to use
You can access the restful resources from BreweryDB as follows:
For Beers
For the beers endpoint, just call the beers
method and pass in any extra
parameters from the BreweryDB docs.
For example, to get a beer by name:
client.beers({name: 'Tecate'}, function(err, res) {
if (err) {
// handle errors
}
console.log(res);
});
Or with promises:
return client.beers({name: 'Tecate'}).then(function(res) {
console.log(res);
}, function(err) {
// in case an error happens.
});
To get a single beer, you need to pass the beer id as follows:
client.beer('IPhAuu', function(err, res) {
console.log(res);
});
You can also get nested resources for any given resource that allows it, see the BreweryDB docs. For example, beers take a nested resource:
client.beer('IPhAuu', 'breweries', function(err, res) {
// here are the breweries for this particular beer.
console.log(res);
});
You can also access any other nested resource for a beer, such as adjunt, event and fermentable.
TODO
So far we can access beer/beers, nested resources for beer, styles and brewery/breweries. Work needs to be done to access other resources.