1. Go to this page and download the library: Download billythekid/punk-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
billythekid / punk-api example snippets
$punkApi = new billythekid\PunkApi();
$punkApi = billythekid\PunkApi::create();
getEndpoint()
addParams(Array $params)
abvAbove($number)
abvBelow($number)
ibuAbove($number)
ibuBelow($number)
ebcAbove($number)
ebcBelow($number)
named($beerName)
yeast($yeastName)
brewedBefore($date)
brewedAfter($date)
hops($hopsName)
malt($maltName)
food($foodName)
page($pageNumber)
perPage($number)
ids($ids) // can pass an array of ids instead of piping them into a string here.
//get all beers with an ABV between 4 and 9, called *punk*
$punkApi = \billythekid\PunkApi::create("PUNK_API_KEY")
->addParams(['abv_gt' => 4, 'abv_lt' => 9])
->addParams(['beer_name' => "punk"])
->getEndpoint(); // https://api.punkapi.com/v2/beers?abv_gt=4&abv_lt=9&beer_name=punk
//Chained method for same result
$punkApi = \billythekid\PunkApi::create("PUNK_API_KEY")
->abvAbove(4)
->abvBelow(9)
->named("punk")
->getEndpoint(); // https://api.punkapi.com/v2/beers?abv_gt=4&abv_lt=9&beer_name=punk