billbee / billbee-api
The official Billbee API SDK for PHP
Installs: 107 080
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 8
Forks: 25
Open Issues: 14
Requires
- php-64bit: ^7.3 || ^8.0
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.4.0
- jms/serializer: ^3.18
- psr/log: ^1.1.0 || ^2.0.0 || ^3.0.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15
- phpstan/phpstan: ^1.8.2
- phpunit/phpunit: ^9.4.1
This package is auto-updated.
Last update: 2025-02-10 12:49:14 UTC
README
Billbee API
With this package you can implement the official Billbee API in your application.
Prerequisites
- For accessing the Billbee API you need an API Key. To get an API key, send a mail to support@billbee.de and send us a short note about what you are building.
- The API module must be activated in the account (https://app.billbee.io/app_v2/settings/api/general)
Install
You can add this package as composer dependency
$ composer require billbee/billbee-api
Official API Documentation
https://app.billbee.io/swagger/ui/index
Usage
Simply instantiate a client object for accessing the api:
<?php use BillbeeDe\BillbeeAPI\Client; $user = 'Your Billbee username'; $apiPassword = 'Your Billbee API Password'; // https://app.billbee.io/de/settings/api $apiKey = 'Your Billbee API Key'; $client = new Client($user, $apiPassword, $apiKey);
Example: Retrieve a list of products
<?php use BillbeeDe\BillbeeAPI\Client; $user = 'Your Billbee username'; $apiPassword = 'Your Billbee API Password'; // https://app.billbee.io/de/settings/api $apiKey = 'Your Billbee API Key'; $client = new Client($user, $apiPassword, $apiKey); /** @var \BillbeeDe\BillbeeAPI\Response\GetProductsResponse $productsResponse */ $productsResponse = $client->products()->getProducts($page = 1, $pageSize = 10); /** @var \BillbeeDe\BillbeeAPI\Model\Product $product */ foreach ($productsResponse->data as $product) { echo sprintf("Id: %s, SKU: %s, Price: %f\n", $product->id, $product->sku, $product->price); }
Example: Batch requests
<?php use BillbeeDe\BillbeeAPI\Client; use BillbeeDe\BillbeeAPI\Response; $user = 'Your Billbee username'; $apiPassword = 'Your Billbee API Password'; // https://app.billbee.io/de/settings/api $apiKey = 'Your Billbee API Key'; $client = new Client($user, $apiPassword, $apiKey); $client->enableBatchMode(); $client->products()->getProducts(1, 1); # Adds the request to the batch pool / returns null $client->orders()->getOrders(1, 1); # Adds the request to the batch pool / returns null $client->events()->getEvents(1, 1); # Adds the request to the batch pool / returns null $results = $client->executeBatch(); # Results contain all responses in the added order /** @var Response\GetProductsResponse $productsResult */ $productsResult = $results[0]; /** @var Response\GetOrdersResponse $ordersResult */ $ordersResult = $results[1]; /** @var Response\GetEventsResponse $eventsResult */ $eventsResult = $results[2];
Testing
Run phpunit
Contributing
Feel free to fork the repository and create pull-requests