PHPackages                             aalfiann/ebook-api-php - 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. aalfiann/ebook-api-php

ActiveLibrary[API Development](/categories/api)

aalfiann/ebook-api-php
======================

A PHP wrapper class to get data ebook from Google Book and GoodReads API.

1.2.3(7y ago)025MITPHPPHP &gt;=5.4

Since Apr 9Pushed 7y ago1 watchersCompare

[ Source](https://github.com/aalfiann/ebook-api-php)[ Packagist](https://packagist.org/packages/aalfiann/ebook-api-php)[ RSS](/packages/aalfiann-ebook-api-php/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (8)Used By (0)

EbookAPI
========

[](#ebookapi)

[![Version](https://camo.githubusercontent.com/3b1aac356be67222fc8868dfcb508cdcf98d8845a56ec8b161b8bad7d478e7b1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737461626c652d312e322e332d677265656e2e737667)](https://github.com/aalfiann/ebook-api-php)[![Total Downloads](https://camo.githubusercontent.com/aec5facd3197b6843782c493c438ad42982427e926eefde82b792d0c445c1451/68747470733a2f2f706f7365722e707567782e6f72672f61616c6669616e6e2f65626f6f6b2d6170692d7068702f646f776e6c6f616473)](https://packagist.org/packages/aalfiann/ebook-api-php)[![License](https://camo.githubusercontent.com/b811ecafa5961acb1b08999ad7e0850ff77fc683eb8288cc0aba067adc87cf46/68747470733a2f2f706f7365722e707567782e6f72672f61616c6669616e6e2f65626f6f6b2d6170692d7068702f6c6963656e7365)](https://github.com/aalfiann/ebook-api-php/blob/HEAD/LICENSE.md)

A PHP wrapper class to get the ebook information data from Google Book or GoodReads API.

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

[](#installation)

Install this package via [Composer](https://getcomposer.org/).

```
composer require "aalfiann/ebook-api-php:^1.0"

```

Usage to use Google Book API
----------------------------

[](#usage-to-use-google-book-api)

This is the basic to search books.

```
use aalfiann\EbookAPI\GoogleBook;
require_once ('vendor/autoload.php');

header('Content-Type: application/json');
$ebook = new GoogleBook('YOUR_GOOGLE_API_KEY');

// Search book
echo $ebook->search('vue js')

    // you can add filter to search only free-ebooks
    ->filter('free-ebooks')

    // you can add projection 'lite'. This includes only a subject of volume and access metadata.
    ->projection('lite')

    // you can add printType 'books'. This will return just books.
    ->printType('books')

    // you can add langRestrict 'en'. This will return books with english only.
    ->langRestrict('en')

    // you can add download 'epub'. Currently only support epub.
    ->download('epub')

    // you can add orderBy 'newest'. This will order books start from newest.
    ->orderBy('newest')

    // you can add startIndex 0. First page always start from 0.
    ->startIndex(0)

    // you can add maxResults 10. This will return only 10 item of books. Max value is 40.
    ->maxResults(10)

    // send request to Google Book API
    ->send()

    // get the response from Google Book API
    ->getResponse();
```

### Get Books start with spesific parameter.

[](#get-books-start-with-spesific-parameter)

Get book by title

```
// Get book by title name
$ebook->title('steve jobs')->maxResults(10);

// Get book by title name 'steve jobs' but only return which is having 'Biography' word in title
$ebook->title('steve jobs','Biography')->maxResults(10);
```

Get book by author

```
// Get book by author name
$ebook->author('keyes')->maxResults(10);

// Get book by author name 'keyes' but only return which is having 'flowers' word in title
$ebook->author('keyes','flowers')->maxResults(10);
```

Get book by subject name

```
// Get book by subject name
$ebook->subject('Fiction')->maxResults(10);

// Get book by subject name 'Fiction' but only return which is having 'flowers' word in title
$ebook->subject('Fiction','flowers')->maxResults(10);
```

Get book by publisher name

```
// Get book by publisher name
$ebook->publisher('OUP Oxford')->maxResults(10);

// Get book by publisher name 'OUP Oxford' but only return which is having 'Law' word in title
$ebook->publisher('OUP Oxford','Law')->maxResults(10);
```

Get book by ID

```
// Get book by Google Book ID
$ebook->id('BOOK_ID');

// Get book by ISBN
$ebook->isbn('ISBN_ID');

// Get book by LCCN
$ebook->lccn('LCCN_ID');

// Get book by OCLC
$ebook->oclc('OCLC_ID');
```

### Get Bookshelves

[](#get-bookshelves)

```
// Get bookshelves from user id '109862556655476830073'
echo $ebook->bookshelves('109862556655476830073')

    // you can choose the shelf. For example only shelf with id '1001'
    ->shelf('1001')

    // if you want to show the items inside shelf
    ->retrieve()

    // send request to Google Book API
    ->send()

    // get response from Google Book API
    ->getResponse();
```

If you want to see the response

```
echo $ebook->send()->getResponse();
```

If you want to count the result items

```
echo $ebook->send()->count();
```

If you want to see the debug response

```
echo $ebook->send(false)->getResponse();
```

Usage to use GoodReads API
--------------------------

[](#usage-to-use-goodreads-api)

### Example how to search books

[](#example-how-to-search-books)

To search books with `GoodReads`, you must send a request to `https://www.goodreads.com/search/index.xml` and there is four parameters required, it is `key`,`q`,`page` and `search[field]`. [Visit here for more information](https://www.goodreads.com/api/index#search.books).

```
use aalfiann\EbookAPI\GoodReads;
require_once ('vendor/autoload.php');

header('Content-Type: application/json');
$ebook = new GoodReads('YOUR_GOODREADS_API_KEY');

$ebook->path('search/index.xml')
    // Add param 'q' to query
    ->q('steve jobs')

    // Add param 'search[Field]' to query more spesific results. default is 'all'
    ->searchField('title')

    // You can add 'page' for pagination. Start page is always 1
    ->page(1)

    // Send request to GoodReads API
    ->send()

    // Get response from GoodReads API
    ->getResponse();
```

### Example how to manual add param

[](#example-how-to-manual-add-param)

If there is new feature released by Goodreads, of course the shortcut method of the new parameter is not available in the class.
So you can use `addParam($name,$value)` function.

For example we want to [Get a user's review for a given book](https://www.goodreads.com/api/index#review.show_by_user_and_book)

```
$ebook->path('review/show_by_user_and_book.xml')
    // Add param 'user_id' which is not available inside the class
    ->addParam('user_id',1)

    // Add param 'book_id' which is not available inside the class
    ->addParam('book_id',50)

    // Add param 'include_review_on_work' which is not available inside the class
    ->addParam('include_review_on_work','false')

    // Send request to GoodReads API
    ->send()

    // Get response from GoodReads API
    ->getResponse();
```

For more information about `path()` and other , You have to read the [GoodReads API Documentation](https://www.goodreads.com/api/index), because this `GoodReads` class is a wrapper only.

### GoodReadsMethod class

[](#goodreadsmethod-class)

`GoodReadsMethod` class is the simple way to make a communication with GoodReads API. This class is contains the method which is often to use or general method only.

This is how to use with `GoodReadsMethod` class

```
use aalfiann\EbookAPI\GoodReadsMethod;
require_once ('vendor/autoload.php');

header('Content-Type: application/json');
$ebook = new GoodReadsMethod('YOUR_GOODREADS_API_KEY');

// Search Book
echo $ebook->searchBook('fiction');

// Search Book about 'fiction' but show at page 3
echo $ebook->searchBook('fiction',3);

// Search Book by Genre 'comedy'
echo $ebook->searchBookByGenre('comedy');

// Get book by GoodReads Internal ID
echo $ebook->getBook('21825181');

// Get book by ISBN
echo $ebook->getBookByISBN('9781451648546');

// Get book by title
echo $ebook->getBookByTitle('vuejs');
```

### Limitation:

[](#limitation)

- This library is only to get the public data information from `Google Book` or `GoodReads` API, so there is no **OAuth / Authorization** implemented in this library.
- This library does not include with cache. You should cache the results, because `Google` and `GoodReads` has **LIMIT RATE** and will block your IP address server if too many request.
- `GoodReadsMethod` class is unstable, maybe code will change in the future depends on `GoodReads`.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~2 days

Total

7

Last Release

2576d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c101f6be505e4713be942f6b80d849b46702e6f4069430e1dbbe60fa18289c54?d=identicon)[aalfiann](/maintainers/aalfiann)

---

Top Contributors

[![aalfiann](https://avatars.githubusercontent.com/u/9458941?v=4)](https://github.com/aalfiann "aalfiann (10 commits)")

---

Tags

apipsr4Goodreadsgooglebook

### Embed Badge

![Health badge](/badges/aalfiann-ebook-api-php/health.svg)

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

###  Alternatives

[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

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