PHPackages                             keboola/billing-api-php-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. keboola/billing-api-php-client

ActiveLibrary[API Development](/categories/api)

keboola/billing-api-php-client
==============================

PHP Client for Keboola Connection Billing API

6.0.0(2w ago)013.3k↓66.9%MITPHPPHP &gt;=8.2CI failing

Since Sep 10Pushed 2w ago16 watchersCompare

[ Source](https://github.com/keboola/billing-api-php-client)[ Packagist](https://packagist.org/packages/keboola/billing-api-php-client)[ RSS](/packages/keboola-billing-api-php-client/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (16)Versions (24)Used By (0)

Billing API PHP Client [![Build Status](https://camo.githubusercontent.com/4eed47f5edacf1d9d0bedfa27439c14813d98d2e3ad4743d6a11165b90443a1d/68747470733a2f2f6465762e617a7572652e636f6d2f6b65626f6f6c612d6465762f62696c6c696e672d6170692d7068702d636c69656e742f5f617069732f6275696c642f7374617475732f6b65626f6f6c612e62696c6c696e672d6170692d7068702d636c69656e743f6272616e63684e616d653d6d61696e)](https://dev.azure.com/keboola-dev/billing-api-php-client/_build/latest?definitionId=89&branchName=main)
==========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#billing-api-php-client-)

PHP client for the Billing API ([API docs](https://keboolabillingapi.docs.apiary.io/#)).

Built on [`keboola/php-api-client-base`](https://github.com/keboola/php-api-client-base), the shared base for Keboola service API clients (HTTP transport, authentication, retries, JSON handling and error normalization).

Usage
-----

[](#usage)

```
composer require keboola/billing-api-php-client
```

Clients are created through `ClientFactory`, which wires the correct authentication header for each client (`X-StorageApi-Token` for the project client, `X-KBC-ManageApiToken` for the manage client):

```
use Keboola\BillingApi\ClientFactory;

$factory = new ClientFactory();

// Project client (authenticated with a Storage API token).
$client = $factory->createClient('https://billing.keboola.com/', $storageApiToken);
$credits = $client->getRemainingCredits();
var_dump($credits);

// Manage client (authenticated with a Manage API token).
$manageClient = $factory->createManageClient('https://billing.keboola.com/', $manageApiToken);

// Manage client without a token: authenticates with the projected Kubernetes
// service-account token (X-Kubernetes-Authorization), read from the standard
// mount path at request time. Use this when running inside the cluster.
$manageClient = $factory->createManageClient('https://billing.keboola.com/');
```

`createManageClient()`'s token is optional: pass a Manage API token to authenticate with it, or omit it (leave it `null`) to fall back to the projected service-account token. `createClient()` always requires a Storage API token. A non-null token must be a non-empty string — an empty token is rejected (`Webmozart\Assert\InvalidArgumentException`).

`createClient()` and `createManageClient()` accept an optional `$options` array (`backoffMaxTries`, `timeout`, `connectTimeout`, `userAgent`, `logger`).

For a custom authentication scheme, construct `InternalClient` directly with any `Keboola\ApiClientBase\Auth\RequestAuthenticatorInterface` implementation:

```
use Keboola\ApiClientBase\Auth\ManageApiTokenAuthenticator;
use Keboola\BillingApi\InternalClient;
use Keboola\BillingApi\ManageClient;

$manageClient = new ManageClient(
    new InternalClient('https://billing.keboola.com/', new ManageApiTokenAuthenticator($manageApiToken)),
);
```

Error handling
--------------

[](#error-handling)

Every failure (transport error, non-2xx response, invalid/empty body) throws a `Keboola\BillingApi\Exception\BillingException`. It extends the base client's `Keboola\ApiClientBase\Exception\ClientException`, so it also exposes the HTTP status code and the raw response body when a response was received:

```
use Keboola\BillingApi\Exception\BillingException;

try {
    $credits = $client->getRemainingCredits();
} catch (BillingException $e) {
    $e->getStatusCode();   // ?int  — HTTP status, or null for transport/connection failures
    $e->getResponseBody(); // ?string — raw response body when available
}
```

Run tests
---------

[](#run-tests)

- With the above setup, you can run tests:

    ```
    docker compose build
    docker compose run tests
    ```
- To run tests with local code use:

    ```
    docker compose run tests-local composer install
    docker compose run tests-local
    ```

License
-------

[](#license)

MIT licensed, see [LICENSE](./LICENSE) file.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance98

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

22

Last Release

14d ago

Major Versions

1.3.0 → 2.0.02022-10-17

2.0.0 → 3.0.02022-11-11

3.2.0 → 4.0.02024-01-02

4.1.0 → 5.0.02024-01-15

5.5.0 → 6.0.02026-06-19

PHP version history (4 changes)0.1.0PHP &gt;=5.6

1.0.0PHP &gt;=7.4

3.2.0PHP &gt;=8.1

5.5.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/101dbf2551a0709ddab522f97669f13a2c4cc2d0a1e8d009f3af6ba80accb1a9?d=identicon)[Keboola](/maintainers/Keboola)

---

Top Contributors

[![pepamartinec](https://avatars.githubusercontent.com/u/271753?v=4)](https://github.com/pepamartinec "pepamartinec (35 commits)")[![ErikZigo](https://avatars.githubusercontent.com/u/1726727?v=4)](https://github.com/ErikZigo "ErikZigo (28 commits)")[![odinuv](https://avatars.githubusercontent.com/u/4319320?v=4)](https://github.com/odinuv "odinuv (17 commits)")[![tomasfejfar](https://avatars.githubusercontent.com/u/642928?v=4)](https://github.com/tomasfejfar "tomasfejfar (5 commits)")[![MiroCillik](https://avatars.githubusercontent.com/u/1488015?v=4)](https://github.com/MiroCillik "MiroCillik (3 commits)")[![romanbracinik](https://avatars.githubusercontent.com/u/6448364?v=4)](https://github.com/romanbracinik "romanbracinik (3 commits)")[![ujovlado](https://avatars.githubusercontent.com/u/419849?v=4)](https://github.com/ujovlado "ujovlado (3 commits)")[![ondrajodas](https://avatars.githubusercontent.com/u/12143866?v=4)](https://github.com/ondrajodas "ondrajodas (2 commits)")

---

Tags

ajda

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/keboola-billing-api-php-client/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.5k5.9M738](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M386](/packages/easycorp-easyadmin-bundle)[api-platform/core

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

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

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

1.3k1.4M203](/packages/sulu-sulu)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[api-platform/serializer

API Platform core Serializer

274.8M87](/packages/api-platform-serializer)

PHPackages © 2026

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