PHPackages                             bookboon/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. [API Development](/categories/api)
4. /
5. bookboon/api

ActiveLibrary[API Development](/categories/api)

bookboon/api
============

Wrapper for Bookboon API

v4.18.2(4y ago)499.3k2[1 issues](https://github.com/bookboon/api-php/issues)[1 PRs](https://github.com/bookboon/api-php/pulls)MITPHPPHP &gt;=7.3CI failing

Since Dec 1Pushed 4y ago4 watchersCompare

[ Source](https://github.com/bookboon/api-php)[ Packagist](https://packagist.org/packages/bookboon/api)[ Docs](https://github.com/bookboon/api-php)[ RSS](/packages/bookboon-api/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (5)Versions (140)Used By (0)

\#Bookboon API PHP Class [![Build Status](https://camo.githubusercontent.com/bb2df438c148a209b01f6fd3734c6397c9427929006e11aef9d38544a0baf06f/68747470733a2f2f7472617669732d63692e6f72672f626f6f6b626f6f6e2f6170692d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bookboon/api-php) [![Code Climate](https://camo.githubusercontent.com/5ce22438e4f17ddddf1081fefa505fb2049742669b71f9b41dfa5b6ef8589d92/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f626f6f6b626f6f6e2f6170692d7068702f6261646765732f6770612e737667)](https://codeclimate.com/github/bookboon/api-php) [![Test Coverage](https://camo.githubusercontent.com/f566c7ed1157133c6e571192291bd612495e74b26f6ad6c1269be993577ff207/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f626f6f6b626f6f6e2f6170692d7068702f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/bookboon/api-php/coverage)

The PHP class is a wrapper for the Bookboon.com API. Because this is just a wrapper class you should familiarize yourself with the [REST api](https://github.com/bookboon/api) before using it.

\##Usage

To use the Bookboon AIP you are required to have an application id and secret (`$API_ID` and `$API_SECRET` below), see the [API page](https://github.com/bookboon/api) for details. Install via composer:

```
composer require bookboon/api

```

To use it without composer, use with any PSR-0 compatible autoloader or require every file manually.

The simplest way to get a book is to use the getBook method:

```
$bookboon = new Bookboon($API_ID, $API_SECRET, array(/*optional named array to set request headers*/));
$book = $bookboon->getBook("BOOK_GUID");

```

That will return a Book object with public getters for every property. There are plenty more simple get functions:

```
$category = $bookboon->getCategory("CATEGORY_GUID"); // return Category object
$reviews = $bookboon->getReviews("BOOK_GUID"); // return array of Review
$search = $bookboon->getSearch("query text"); // return array of Book
$recommendations = $bookboon->getRecommendations(array("BOOK_ID_1", "BOOK_ID_2"); // return array of Book
$questions = $bookboon->getQuestions(); // return array of Question

```

Finally you can download a book usually the following, you need to send a unique user identifier `handle` for every unique user (for instance a user id, email):

```
$url = $bookboon->getBookDownloadUrl("BOOK_GUID", array("handle" => "user@email"));
// Send the $url in a redirect header to the user

```

> **Important:** Do **NOT** store this value as it will change constantly.

Use api raw
-----------

[](#use-api-raw)

You can also use the `api` method to get database from the API. To pass variables to the API send an array with the `api` function:

```
/* The bacon-loving student */
$vars = array('post' => array( 'answer[0]' => '6230e12c-68d8-45d5-8f02-1d3997713150',
			  			       'answer[1]' => '5aca0fe1-0d93-41b1-8691-aa242a526f17'
							 )
			 );

$bookboon->api('/questions', $vars);

```

> **Note:** To make the php class more versatile you need to tell it whether to pass variables using POST or GET methods. The `api` function will only accept keys named 'post' and 'get' and parse their respective arrays into the correct query strings.

\##Result

Results from the `api` method is json decoded arrays of data directly from the API, if you use any of the other methods (`getbooks`, `getCategories` etc.) an appropiate object will be returned.

\##Exceptions

The wrapper will throw a few different exceptions. If API responds with an unhandled HTTP status such as if a variabls are missing (403), the posted data is malformed (400) or an unknown API error (500). You may wish to catch these errors, like so:

```
$bookboon = new Bookboon($API_ID, $API_SECRET);

try {
	print_r($bookboon->api('/recommendations', array(
        'get' => array(
            'books' => $book_id
        )));
}
catch (NotFoundException $e) {
    // handle exception here
}

```

Right now we throw the following exceptions:

`ApiSyntaxException` - Usually missing or malformed parameters
`AuthenticationException` - Bad credentials
`GeneralApiException` - When some unknown goes wrong, please report this to us
`NotFoundException` - API returns not found status (404)

\##Cache

The wrapper class provides a cache interface to be used to speed up GET queries. At the moment only memcached is implemented. To set the cache provider use the `setCache` method:

```
$bookboon->setCache(new \Bookboon\Api\Memcached($server, $port, $timeToLive));

```

To implement your own provider cache software, make sure your interface imlements ` \Bookboon\Api\Cache`. It only has three methods: `save`, `get` and `delete`, so it should be easy enough to do.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 85.2% 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 ~23 days

Recently: every ~43 days

Total

101

Last Release

1548d ago

Major Versions

v2.4 → v3.62018-10-10

v2.4.1 → v4.02019-01-30

v2.4.3 → v4.32019-02-28

v2.4.4 → v4.8.32020-02-21

v2.4.5 → v4.11.22020-07-01

PHP version history (7 changes)v1.1PHP &gt;=5.3.0

v3.7PHP &gt;=5.6

v3.14.1PHP &gt;=7.1

v4.0PHP ^7.1

v2.4.4PHP &gt;=5.6.0

v4.13PHP ^7.3|^8.0

v4.14PHP &gt;=7.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1746160?v=4)[Bookboon.com Ltd](/maintainers/bookboon)[@bookboon](https://github.com/bookboon)

---

Top Contributors

[![lkm](https://avatars.githubusercontent.com/u/1745971?v=4)](https://github.com/lkm "lkm (224 commits)")[![robo220](https://avatars.githubusercontent.com/u/11950073?v=4)](https://github.com/robo220 "robo220 (29 commits)")[![rossb220](https://avatars.githubusercontent.com/u/56581954?v=4)](https://github.com/rossb220 "rossb220 (8 commits)")[![jaztinas](https://avatars.githubusercontent.com/u/9946734?v=4)](https://github.com/jaztinas "jaztinas (1 commits)")[![schourode](https://avatars.githubusercontent.com/u/28538?v=4)](https://github.com/schourode "schourode (1 commits)")

---

Tags

apiwrapper

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M19.6k](/packages/laravel-framework)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M151](/packages/algolia-algoliasearch-client-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k39](/packages/civicrm-civicrm-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k13](/packages/tempest-framework)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[php-tmdb/api

PHP wrapper for TMDB (TheMovieDatabase) API v3. Supports two types of approaches, one modelled with repositories, models and factories. And the other by simple array access to RAW data from The Movie Database.

435383.9k17](/packages/php-tmdb-api)

PHPackages © 2026

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