PHPackages                             krzysztof-moskalik/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. krzysztof-moskalik/api-client

ActiveLibrary[API Development](/categories/api)

krzysztof-moskalik/api-client
=============================

Client for consuming REST APIs

2.0.0(5mo ago)051MITPHPPHP &gt;=8.4

Since Jan 21Pushed 5mo agoCompare

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

READMEChangelogDependencies (10)Versions (5)Used By (1)

API Client
==========

[](#api-client)

**This library makes an abstraction layer for REST APIs.
It allows mapping API resources to your application models.**

Note
----

[](#note)

**This library is under development!
Many things can be changed, and many new features can be added.**

Symfony Note
------------

[](#symfony-note)

This library is not tied to a Symfony framework, but there is a Symfony bundle available: [KrzysztofMoskalik/api-client-bundle](https://github.com/KrzysztofMoskalik/api-client-bundle).

Features:
---------

[](#features)

- Easy to use
- Flexible
- Easy to extend
- Works the best with standard JSON REST APIs
- Supports multiple APIs
- Supports multiple authentication methods
- Supports multiple endpoints per same resource (with the same HTTP method)

Simple configuration
--------------------

[](#simple-configuration)

Api Client does not come with a builtin serializer, so first you need to define your own one.
For example:

```
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;

$serializer = new Serializer(
    [
        new ObjectNormalizer(),
        new ArrayDenormalizer(),
    ],
    [
        new JsonEncoder(),
    ]
);
```

Same thing with HTTP Client:

```
$httpClient = new GuzzleHttp\Client();
```

Finally, you can create an Api Client instance with a simple configuration:

```
use App\Model\User;
use KrzysztofMazur\Api\Api;
use KrzysztofMazur\Api\Client;

$client = new Client();

$client->globals
    ->setSerializer($serializer)
    ->setHttpClient($httpClient)

$client->addApi(
    new Api('my_api_name')
        ->setBaseUrl('https://my-api.com/api/')
        ->generic(User::class)
);
```

This will create repository for all CRUD operations on User resource that will be represented by `App\Model\User` class.

Usage
-----

[](#usage)

With this simple configuration you can now use Api Client to interact with your API:

```
$repository = $client->getRepository(User::class);

$user = $repository->get(2340); // fetch user with id 2340

$users = $repository->list(); // fetch all users

$repository->delete(3671); // delete user with id 3671

$user = new User(
    'John Doe',
    'john.doe@example.com'
);
$repository->create($user); // create new user

$user->setEmail('john.doe@lorem.com');
$repository->update($user); // update user

$user->setEmail('john.doe@ipsum.com');
$repository->patch($user); // partial update user
```

Full config reference
---------------------

[](#full-config-reference)

Work in progress...

Todos
-----

[](#todos)

- handling filtering and sorting on list operations
- handling nesting data paths
- implement bearer auth

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance72

Regular maintenance activity

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

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

4

Last Release

155d ago

Major Versions

1.1.0 → 2.0.02026-01-29

PHP version history (2 changes)1.0.0PHP &gt;=8.5

1.1.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/491c203c651745274ac1cf3968e5071d650cb524e76f2dead5b5dceeb5e0f28f?d=identicon)[krzysztof-moskalik](/maintainers/krzysztof-moskalik)

---

Top Contributors

[![KrzysztofMoskalik](https://avatars.githubusercontent.com/u/9136446?v=4)](https://github.com/KrzysztofMoskalik "KrzysztofMoskalik (5 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

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

8.5k5.9M738](/packages/sylius-sylius)[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)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)

PHPackages © 2026

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