PHPackages                             zooxsmart/los-api-client - 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. zooxsmart/los-api-client

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

zooxsmart/los-api-client
========================

REST API Client using Hal

3.0.0(1y ago)014.5k↑17.4%MITPHPPHP ^8.1

Since Mar 15Pushed 1y agoCompare

[ Source](https://github.com/zooxsmart/los-api-client)[ Packagist](https://packagist.org/packages/zooxsmart/los-api-client)[ Docs](https://github.com/Lansoweb/api-client)[ GitHub Sponsors](https://github.com/Lansoweb)[ RSS](/packages/zooxsmart-los-api-client/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (11)Versions (60)Used By (0)

Api-Client
==========

[](#api-client)

ApiClient is a php library to consume Restful APIs using Hal, like [Apigility](http://apigility.org).

Requirements
------------

[](#requirements)

Please, see composer.json

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

[](#installation)

```
php composer.phar require los/api-client
```

### Configuration

[](#configuration)

You need to configure at least the Api URI.

If using a framework that implements `container-interopt`, you can use the following configuration:

Copy the los-api-client.global.php.dist from this module to your application's config folder and make the necessary changes.

```
'los' => [
    'api-client' => [
        'root_uri' => 'http://localhost:8000',
        'add_request_id' => true,
        'add_request_time' => true,
        'add_request_depth' => true,
        'headers' => [
            'Accept'       => 'application/hal+json',
            'Content-Type' => 'application/json',
        ],
        'query' => [
            'key' => '123',
        ],
        'request_options' => [
            'request_options' => [
                'timeout' => 10,
                'connect_timeout' => 2,
                'read_timeout' => 10,
            ],
        ],
        'default_ttl' => 600,
    ],
],
```

Usage
-----

[](#usage)

### Creating the client

[](#creating-the-client)

You can use the `Los\ApiClient\ClientFactory` using the above configuration or manually:

```
$client = new \Los\ApiClient\ApiClient('http://api.example.com');
```

### Single resource

[](#single-resource)

```
/* @var \Los\ApiClient\ApiClient $client */
$client = new \Los\ApiClient\ApiClient('http://api.example.com');

/* @var \Los\ApiClient\Resource\ApiResource $ret */
$ret = $client->get('/album/1');

// $data is an array with all data and resources (_embedded) from the response
$data = $ret->getData();
```

### Collection

[](#collection)

```
/* @var \Los\ApiClient\ApiClient $client */
$client = new \Los\ApiClient\ApiClient('http://api.example.com');

/* @var \Los\ApiClient\Resource\ApiResource $ret */
$ret = $client->get('/album', [ 'query' => ['year' => 2018] ]);

// $data is an array with all data and resources (_embedded) from the response
$data = $ret->getData();

// $data is an array with the first album resource from the response
$data = $ret->getFirstResource('album');

// $data is an array with the all album resources from the response
$data = $ret->getResources('album');

// $data is an array with the all resources from the response
$data = $ret->getResources();
```

### Cache

[](#cache)

```
/* @var \Psr\SimpleCache\CacheInterface */
$cache = null; // Any PSR-16 cache service.

/* @var \Los\ApiClient\ApiClient $client */
$client = new \Los\ApiClient\ApiClient('http://api.example.com', $cache);

// The last param is a per item ttl, please make sure your cache service can handle it.
/* @var \Los\ApiClient\Resource\ApiResource $ret */
$ret = $client->getCached('/album', 'cached-key', [ 'query' => ['year' => 2018] ], null);

// $data is an array with all data and resources (_embedded) from the response
$data = $ret->getData();

// $data is an array with the first album resource from the response
$data = $ret->getFirstResource('album');

// $data is an array with the all album resources from the response
$data = $ret->getResources('album');

// $data is an array with the all resources from the response
$data = $ret->getResources();
```

### Events

[](#events)

The client triggers some events:

- request.pre
- request.post
- request.fail

More info about events on [zend-eventmanager](https://github.com/laminas/laminas-eventmanager).

### Request Id

[](#request-id)

The client automatically adds a X-Request-Id to each request, but only if there is no previous X-Request-Id added.

You can force a new id with:

```
$client = $this->getServiceLocator()->get('hermes');
$client->addRequestId(); // Auto generared
$client->addRequestId('123abc');
```

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 88.9% 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 ~56 days

Recently: every ~86 days

Total

44

Last Release

632d ago

Major Versions

0.9.2 → 1.0.02018-12-06

1.0.6 → 2.0.02019-06-14

1.1.0 → 2.1.02020-02-05

2.7.2 → 3.0.02024-10-10

PHP version history (3 changes)0.1.0PHP ^7.1

2.2.0PHP ^7.4 || ^8.0

2.5.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/9155a672b863ca2243f6b3d69d61d55bf35ae8e421c1b4f1655293a34d0451ba?d=identicon)[talbuquerque](/maintainers/talbuquerque)

---

Top Contributors

[![Lansoweb](https://avatars.githubusercontent.com/u/2109813?v=4)](https://github.com/Lansoweb "Lansoweb (72 commits)")[![talbuquerque](https://avatars.githubusercontent.com/u/20418669?v=4)](https://github.com/talbuquerque "talbuquerque (4 commits)")[![lucas-cn](https://avatars.githubusercontent.com/u/53315213?v=4)](https://github.com/lucas-cn "lucas-cn (2 commits)")[![mariojrrc](https://avatars.githubusercontent.com/u/9058951?v=4)](https://github.com/mariojrrc "mariojrrc (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

apiclientresthal

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zooxsmart-los-api-client/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[civicrm/civicrm-core

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

751291.4k43](/packages/civicrm-civicrm-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M572](/packages/shopware-core)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k51.2M339](/packages/api-platform-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)

PHPackages © 2026

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