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

ActiveLibrary[API Development](/categories/api)

somnambulist/api-client
=======================

A library to help ease creating API integrations

5.0.0(1mo ago)13.5k1MITPHPPHP &gt;=8.4CI passing

Since Dec 4Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/somnambulist-tech/api-client)[ Packagist](https://packagist.org/packages/somnambulist/api-client)[ RSS](/packages/somnambulist-api-client/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (28)Versions (42)Used By (1)

Somnambulist API Client Library
===============================

[](#somnambulist-api-client-library)

[![GitHub Actions Build Status](https://camo.githubusercontent.com/e1b1863985f7b224d4cb8e41da27f744737320bc224da375fb12e0837eb8d324/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f6d6e616d62756c6973742d746563682f6170692d636c69656e742f74657374732e796d6c3f6c6f676f3d676974687562266272616e63683d6d6173746572)](https://github.com/somnambulist-tech/api-client/actions?query=workflow%3Atests)[![Issues](https://camo.githubusercontent.com/52d1eed9b5b43afdb91ac36dde6341e5b61b10d81c3138084e0eaab0436f8c42/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f736f6d6e616d62756c6973742d746563682f6170692d636c69656e743f6c6f676f3d676974687562)](https://github.com/somnambulist-tech/api-client/issues)[![License](https://camo.githubusercontent.com/53bd16982414ad1318abbe641af39f9f96071a02b833b07489538d1b14cd2eb7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736f6d6e616d62756c6973742d746563682f6170692d636c69656e743f6c6f676f3d676974687562)](https://github.com/somnambulist-tech/api-client/blob/master/LICENSE)[![PHP Version](https://camo.githubusercontent.com/f5920d8ad1cd69e6d71eaf983fa1bb0433834caa5a0cd5fbe0f695d62261fc2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736f6d6e616d62756c6973742f6170692d636c69656e743f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/somnambulist/api-client)[![Current Version](https://camo.githubusercontent.com/25f893c83740751b48a32866b9a7478b156637c8b3b1ae5e8451d4f5e67df77e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6d6e616d62756c6973742f6170692d636c69656e743f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/somnambulist/api-client)

The ApiClient library is intended to help build client libraries for consuming JSON APIs. The library provides abstract models for primary resource objects and related value objects. Persistence requests are handled by ApiActions that encapsulate a change request.

Models and ValueObjects make use of [somnambulist/attribute-model](https://github.com/somnambulist-tech/attribute-model) type casting system.

The library uses Symfony HTTP Client under the hood.

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

[](#requirements)

- PHP 8.4+
- cURL
- symfony/event-dispatcher
- symfony/http-client
- symfony/routing

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

[](#installation)

Install using composer, or checkout / pull the files from github.com.

- composer require somnambulist/api-client

Usage
-----

[](#usage)

This library provides some building blocks to help you get started with consuming RESTful APIs. Typically, this is for use with a micro-services project where you need to write clients that will be shared amongst other projects.

Please note: this project does not make assumptions about the type of service being used. The included libraries provide suitable defaults, but can be completely replaced by your own implementations.

The docs are available in the docs folder with a suggested reading order as follows:

- [upgrade notes 1.X](docs/upgrading_from_1.X_to_2.0.md)
- [upgrade notes 2.X](docs/upgrading_from_2.X_to_3.0.md)
- [upgrade notes 3.X](docs/upgrading_from_3.X_to_4.0.md)
- [adding routes](docs/routing.md)
- [defining API connections](docs/connections.md)
- [expected JSON structure](docs/json_format.md)
- [using Models and ValueObjects](docs/models.md)
- [searching and querying](docs/models.md)
- [type casting attributes](docs/type_casting.md)
- [model relationships](docs/model_relationships.md)
- [storing data](docs/persistence.md)
- [recording API responses](docs/recording.md)

Tests
-----

[](#tests)

PHPUnit 12+ is used for testing. Run tests via `vendor/bin/phpunit`.

Test data was generated using faker and was randomly generated.

Links
-----

[](#links)

- [Symfony HTTP Client](https://symfony.com/doc/current/components/http_client.html)
- [Somnambulist Read-Models](https://github.com/somnambulist-tech/read-models)
- [Somnambulist Attribute-Model](https://github.com/somnambulist-tech/attribute-model)
- [Somnambulist Domain](https://github.com/somnambulist-tech/domain)

###  Health Score

57

↑

FairBetter than 98% of packages

Maintenance89

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

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

Recently: every ~309 days

Total

41

Last Release

56d ago

Major Versions

1.8.0 → 2.0.02020-09-13

2.4.0 → 3.0.02021-01-21

3.x-dev → 4.0.02023-01-19

4.1.1 → 5.0.02026-06-13

PHP version history (6 changes)1.0.0PHP &gt;=7.2

1.4.0PHP &gt;=7.3

2.0.0PHP &gt;=7.4

3.0.0PHP &gt;=8.0

4.0.0PHP &gt;=8.1

5.0.0PHP &gt;=8.4

### Community

Maintainers

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

---

Top Contributors

[![dave-redfern](https://avatars.githubusercontent.com/u/1477147?v=4)](https://github.com/dave-redfern "dave-redfern (68 commits)")

---

Tags

apiclientphpsymfony-client

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k6.0M767](/packages/sylius-sylius)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M656](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

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

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M225](/packages/sulu-sulu)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6943.5M446](/packages/drupal-core-recommended)[contao/core-bundle

Contao Open Source CMS

1301.7M3.0k](/packages/contao-core-bundle)

PHPackages © 2026

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