PHPackages                             billythekid/punk-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. billythekid/punk-api

ActiveLibrary

billythekid/punk-api
====================

PHP Wrapper for the Punk API https://punkapi.com

1.1.2(9y ago)460MITPHP

Since Oct 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/billythekid/PunkApi)[ Packagist](https://packagist.org/packages/billythekid/punk-api)[ RSS](/packages/billythekid-punk-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

PunkApi
=======

[](#punkapi)

[![Latest Stable Version](https://camo.githubusercontent.com/4a4c7e5c67fb7025c49c1e821a9007bad61627b373cfc1687789ddf2666bf363/68747470733a2f2f706f7365722e707567782e6f72672f62696c6c797468656b69642f70756e6b2d6170692f76657273696f6e)](https://packagist.org/packages/billythekid/punk-api)[![Total Downloads](https://camo.githubusercontent.com/a6af63a942cb097dcb0454b3fb0fc321d60c907107507f8abdc253a58764f59e/68747470733a2f2f706f7365722e707567782e6f72672f62696c6c797468656b69642f70756e6b2d6170692f646f776e6c6f616473)](https://packagist.org/packages/billythekid/punk-api)[![Latest Unstable Version](https://camo.githubusercontent.com/b5b79a61afe09a9ba96621988f02e79f45f6b0fc387e84a062f923d9c28ffed2/68747470733a2f2f706f7365722e707567782e6f72672f62696c6c797468656b69642f70756e6b2d6170692f762f756e737461626c65)](//packagist.org/packages/billythekid/punk-api)[![License](https://camo.githubusercontent.com/b7a5a16440196860dae248ea5911508129538b1ee7e9301bc3b43c58b0d631aa/68747470733a2f2f706f7365722e707567782e6f72672f62696c6c797468656b69642f70756e6b2d6170692f6c6963656e7365)](https://packagist.org/packages/billythekid/punk-api)[![Monthly Downloads](https://camo.githubusercontent.com/e5bc7ec3cd9f7a781c45b83ec0510fdab45ec9bcaf5aa4ccafc80e6a90d8e0da/68747470733a2f2f706f7365722e707567782e6f72672f62696c6c797468656b69642f70756e6b2d6170692f642f6d6f6e74686c79)](https://packagist.org/packages/billythekid/punk-api)[![Daily Downloads](https://camo.githubusercontent.com/9011ffa2aad0205e15c155e858625034aea3a26c40430e5267354b7b6661e2c9/68747470733a2f2f706f7365722e707567782e6f72672f62696c6c797468656b69642f70756e6b2d6170692f642f6461696c79)](https://packagist.org/packages/billythekid/punk-api)[![composer.lock available](https://camo.githubusercontent.com/5b4f57b57a891b74069ede959f859fda2b6972721a7daffc289ec35fcda0bd83/68747470733a2f2f706f7365722e707567782e6f72672f62696c6c797468656b69642f70756e6b2d6170692f636f6d706f7365726c6f636b)](https://packagist.org/packages/billythekid/punk-api)

PHP wrapper to query the PunkAPI  by [Sam Mason](https://twitter.com/samjbmason)

Full API docs for this project available at

Installation
------------

[](#installation)

via composer `composer require billythekid/punk-api`

Usage
-----

[](#usage)

Create a new instance of the client

```
$punkApi = new billythekid\PunkApi();
```

or

```
$punkApi = billythekid\PunkApi::create();
```

### Methods

[](#methods)

```
getEndpoint()
```

Returns the current endpoint that will be hit based on the options provided. Good to check what'll be hit without actually hitting it. This method is not chainable.

-

```
addParams(Array $params)
```

This method is chainable.

Add parameters to the search. The following parameter keys are supported:

- `abv_gt` number Returns all beers with ABV greater than the number
- `abv_lt` number Returns all beers with ABV less than the number
- `ibu_gt` number Returns all beers with IBU greater than the number
- `ibu_lt` number Returns all beers with IBU less than the number
- `ebc_gt` number Returns all beers with EBC greater than the number
- `ebc_lt` number Returns all beers with EBC less than the number
- `beer_name` string Returns all beers matching the supplied name (this will match partial strings as well so e.g punk will return Punk IPA)
- `yeast` string Returns all beers matching the supplied yeast name, this also matches partial strings
- `brewed_before` date(string) Returns all beers brewed before this date, the date format is mm-yyyy e.g 10-2011
- `brewed_after` date(string) Returns all beers brewed after this date, the date format is mm-yyyy e.g 10-2011
- `hops` string Returns all beers matching the supplied hops name, this also matches partial strings
- `malt` string Returns all beers matching the supplied malt name, this also matches partial strings
- `food` string Returns all beers matching the supplied food string, this also matches partial strings
- `page` number Return the beers from the page given (responses are paginated)
- `per_page` number Change the number of beers returned per page (default - 25)
- `ids` string New for V2 - pipe separated string of ID numbers (192|224 etc)

### The following chainable methods can be used to alter the parameters if you prefer

[](#the-following-chainable-methods-can-be-used-to-alter-the-parameters-if-you-prefer)

```
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.
```

#### Examples

[](#examples)

```
//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
```

---

```
removeParams($param1 [, $param2, ..., $paramN])
```

Removes parameters from the search. This method is chainable

#### Example

[](#example)

```
$punkApi = \billythekid\PunkApi::create("PUNK_API_KEY")
    ->addParams(['abv_gt' => 4, 'abv_lt' => 9])
    ->addParams(['beer_name' => "punk"])
    ->removeParams('beer_name', 'abv_gt')
    ->addParams(['ibu_lt'=> 100])
    ->getEndpoint(); // https://api.punkapi.com/v2/beers?abv_lt=9&ibu_lt=100
```

-

```
clearParams()
```

Empties all the parameters. This method is chainable.

#### Example

[](#example-1)

```
$punkApi = \billythekid\PunkApi::create("PUNK_API_KEY")
    ->addParams(['abv_gt' => 4, 'abv_lt' => 9])
    ->addParams(['beer_name' => "punk"])
    ->clearParams()
    ->getEndpoint(); //https://api.punkapi.com/v2/beers
```

-

```
getBeers()
```

Perform a query on the API, returns an array of beers.

#### Example

[](#example-2)

```
$punkApi = \billythekid\PunkApi::create("PUNK_API_KEY")
    ->addParams(['abv_gt' => 4, 'abv_lt' => 9])
    ->addParams(['beer_name' => "punk"])
    ->removeParams('beer_name', 'abv_gt')
    ->addParams(['ibu_lt'=> 100])
    ->getBeers(); // returns a PHP array of beer objects - see the Example JSON Response at https://punkapi.com/documentation
```

-

```
getRandomBeer()
getBeerById($beerId)
```

Pull a random beer from the API or pull a specific beer from the API by it's ID number

#### Example

[](#example-3)

```
$punkApi = \billythekid\PunkApi::create("PUNK_API_KEY")
    ->getRandomBeer(); // returns an array with a single beer object (StdObject)
```

---

### Changelog

[](#changelog)

##### v 1.1.2 - Mar 23, 2017

[](#v-112---mar-23-2017)

- Bugfix - not passing a param to :create() threw an error

##### v 1.1.1 - Feb 10, 2017

[](#v-111---feb-10-2017)

- Bugfix - perPage() wasn't working properly
- Added more tests

##### v 1.1.0 - Feb 10, 2017

[](#v-110---feb-10-2017)

- Non-breaking update to use version 2 of the Punk Api by default
- Updated docs and readme
- Added `->ids()` endpoint and `ids` paramater
- Added tests

##### v 1.0.0 - Oct 15, 2016

[](#v-100---oct-15-2016)

- Initial release

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~53 days

Total

4

Last Release

3335d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a64cf630fcbf150620c3d37c978becf2c6e9a8efcc858d23bd322c28f35e300?d=identicon)[billythekid](/maintainers/billythekid)

---

Top Contributors

[![billythekid](https://avatars.githubusercontent.com/u/330170?v=4)](https://github.com/billythekid "billythekid (37 commits)")

---

Tags

beerbeers-matchingbrewdogphppunkapiwrapper

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/billythekid-punk-api/health.svg)

```
[![Health](https://phpackages.com/badges/billythekid-punk-api/health.svg)](https://phpackages.com/packages/billythekid-punk-api)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k20](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
