PHPackages                             esi/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. [HTTP &amp; Networking](/categories/http)
4. /
5. esi/api

ActiveLibrary[HTTP &amp; Networking](/categories/http)

esi/api
=======

 A simple wrapper/builder using Guzzle for base API clients.

v1.1.0(1y ago)641[1 issues](https://github.com/ericsizemore/api/issues)MITPHPPHP ^8.2 &lt;8.5CI passing

Since Feb 6Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/ericsizemore/api)[ Packagist](https://packagist.org/packages/esi/api)[ Fund](https://ko-fi.com/ericsizemore)[ GitHub Sponsors](https://github.com/ericsizemore)[ RSS](/packages/esi-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (9)Versions (6)Used By (0)

Esi\\Api - A simple wrapper/builder using Guzzle for base API clients.
======================================================================

[](#esiapi---a-simple-wrapperbuilder-using-guzzle-for-base-api-clients)

[![Build Status](https://camo.githubusercontent.com/b8520cae05b3ccf1d7f88b838507f8d879e1cfb17e5b19a23267a88648747273/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6572696373697a656d6f72652f6170692f6261646765732f6275696c642e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/ericsizemore/api/build-status/main)[![Code Coverage](https://camo.githubusercontent.com/da821b1baa943350f11e1a4de0b16a2a1057da39ab48c1f010103686b775485a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6572696373697a656d6f72652f6170692f6261646765732f636f7665726167652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/ericsizemore/api/?branch=main)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ac17595457cbb50f2a787e8ac86813bdc0f7e4e78c34ee68b1470ddca38e8a5b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6572696373697a656d6f72652f6170692f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/ericsizemore/api/?branch=main)[![Continuous Integration](https://github.com/ericsizemore/api/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/ericsizemore/api/actions/workflows/continuous-integration.yml)[![Latest Stable Version](https://camo.githubusercontent.com/462d3bd4fcbb42da8cc55872023520d34f9a0192d8e33216de1bba6fd368dec5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6573692f6170692e737667)](https://packagist.org/packages/esi/api)[![Downloads per Month](https://camo.githubusercontent.com/7409021615b73c6739ead82613199fcca8b9333c08dce58f59ad99fd7393720e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6573692f6170692e737667)](https://packagist.org/packages/esi/api)[![License](https://camo.githubusercontent.com/107316c097f6902862e2e712a10ffaff7582401507de6ba7c4156904040f4ea7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6573692f6170692e737667)](https://packagist.org/packages/esi/api)

`esi/api` is a simple wrapper/builder using Guzzle for base API clients.

Note

Documentation will be a bit lackluster, and the unit tests need a lot of work. With that being said, I created this library more for use in my own projects that center around an API service; to decouple a lot of the logic that would be repeated in each API service library, to its own library. It has a long way to go, but it should be relatively stable.

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

[](#installation)

You can install the package via composer:

```
$ composer require ericsizemore/api
```

Features
--------

[](#features)

- Builds around [`guzzle/guzzle`](https://github.com/guzzle/guzzle) as the HTTP Client.
- Cache's requests via [`Kevinrob/guzzle-cache-middleware`](https://github.com/Kevinrob/guzzle-cache-middleware).
- Can retry requets on a connection or server error via the Guzzle Retry Middleware.
    - `Client::enableRetryAttempts()` to instruct the client to attempt retries.
    - `Client::disableRetryAttempts()` to disable attempt retries.
    - `Client::setMaxRetryAttempts()` to set the maximum number of retries.
- Can pass along headers in `Client::build()` to be 'persistent' headers, i.e. headers sent with every request.
- One function that handles sending a request: `Client::send()`

It currently does not support async requests and pooling. Just your regular, good 'ol, standard requests.

Usage
-----

[](#usage)

```
use Esi\Api\Client;

// api url, api key, cache path, does the api require key sent as a query arg, the name of the query arg
$client = new Client('https://myapiurl.com/api', 'myApiKey', '/var/tmp', true, 'api_key');

// Must first 'build' the client with (optional) $options array which can include any valid Guzzle option.
$client->build([
    'persistentHeaders' => [
        'Accept' => 'application/json',
    ],
    'allow_redirects' => true,
    // ... etc.
]);
$client->enableRetryAttempts();
$client->setMaxRetryAttempts(5);

$response = $client->send('GET', '/', ['query' => ['foo' => 'bar']]);

// Decode the json and return as array
$data = $client->toArray($response);

// or... as an object
$data = $client->toObject($response);

// or... for the raw json response, to do with as you will
$data = $client->raw(); // or $response->getBody()->getContents()
```

### Requirements

[](#requirements)

- PHP 8.2.0 or above.

### Credits

[](#credits)

- [Eric Sizemore](https://github.com/ericsizemore)
- [All Contributors](https://github.com/ericsizemore/api/contributors)

### Contributing

[](#contributing)

See [CONTRIBUTING](CONTRIBUTING.md).

Bugs and feature requests are tracked on [GitHub](https://github.com/ericsizemore/api/issues).

### Contributor Covenant Code of Conduct

[](#contributor-covenant-code-of-conduct)

See [CODE\_OF\_CONDUCT.md](./CODE_OF_CONDUCT.md)

### Backward Compatibility Promise

[](#backward-compatibility-promise)

See [backward-compatibility.md](./backward-compatibility.md) for more information on Backwards Compatibility.

### Changelog

[](#changelog)

See the [CHANGELOG](./CHANGELOG.md) for more information on what has changed recently.

### License

[](#license)

See the [LICENSE](./LICENSE.md) for more information on the license that applies to this project.

### Security

[](#security)

See [SECURITY](./SECURITY.md) for more information on the security disclosure process.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance61

Regular maintenance activity

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 89.1% 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 ~105 days

Total

2

Last Release

727d ago

### Community

Maintainers

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

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (515 commits)")[![ericsizemore](https://avatars.githubusercontent.com/u/723810?v=4)](https://github.com/ericsizemore "ericsizemore (63 commits)")

---

Tags

apiapi-clientapi-wrapperguzzleguzzlehttphacktoberfestapiGuzzleguzzlehttpapi clientApi Wrapper

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[wrapi/slack

Wrapper for Slack Web API

56272.3k2](/packages/wrapi-slack)[antoinelemaire/aircall-php

Aircall API client built on top of Guzzle 6

1049.6k](/packages/antoinelemaire-aircall-php)

PHPackages © 2026

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