PHPackages                             zangra/bpost-api-library - 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. zangra/bpost-api-library

ActiveLibrary[API Development](/categories/api)

zangra/bpost-api-library
========================

bpost API library is a PHP library to communicate with the bpost API.

5.1.1(9mo ago)227.7k↓32.7%1[1 PRs](https://github.com/zangra-dev/bpost-api-library/pulls)BSD-3-ClausePHPPHP ^8.1 || ^8.4CI failing

Since May 9Pushed 9mo agoCompare

[ Source](https://github.com/zangra-dev/bpost-api-library)[ Packagist](https://packagist.org/packages/zangra/bpost-api-library)[ Docs](https://github.com/Antidot-be/bpost-api-library)[ RSS](/packages/zangra-bpost-api-library/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (2)Versions (31)Used By (0)

bpost API client
================

[](#bpost-api-client)

[![Latest Stable Version](https://camo.githubusercontent.com/0a5f75b2abf60f1c82b033c9b9a98eb070efa6885aa64bd3b9b90e09ff552cd4/687474703a2f2f706f7365722e707567782e6f72672f7a616e6772612f62706f73742d6170692d6c6962726172792f76)](https://packagist.org/packages/zangra/bpost-api-library)[![Build Status](https://camo.githubusercontent.com/206e61ac91b32e184aa5ae5e4ee63ed5dc9770762cfbed4b056e509a848f3b31/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7a616e6772612d6465762f62706f73742d6170692d6c6962726172792f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/zangra-dev/bpost-api-library/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e23f16692ad11d80d3b3aaabf847b9ef1cd1947c8dc70c6a543721341998f021/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7a616e6772612d6465762f62706f73742d6170692d6c6962726172792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/zangra-dev/bpost-api-library/?branch=master)[![License](https://camo.githubusercontent.com/feca496ae2afb24a7038bce1f06fc93435250f14411fc7d112555f12aae1b6b7/687474703a2f2f706f7365722e707567782e6f72672f7a616e6772612f62706f73742d6170692d6c6962726172792f6c6963656e7365)](https://packagist.org/packages/zangra/bpost-api-library)

About
-----

[](#about)

*bpost API library* is a PHP library which permit to your PHP application to communicate with the [bpost API](http://bpost.be).

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

[](#installation)

```
composer require zangra/bpost-api-library
```

Usages
------

[](#usages)

### Orders

[](#orders)

#### Common objects

[](#common-objects)

```
/* Call the Composer autoloader */
require '../vendor/autoload.php';

use Bpost\BpostApiClient\Bpost;
use Bpost\BpostApiClient\Bpost\Order;
use Bpost\BpostApiClient\Bpost\Order\Address;
use Bpost\BpostApiClient\Bpost\Order\Box;
use Bpost\BpostApiClient\Bpost\Order\Box\AtBpost;
use Bpost\BpostApiClient\Bpost\Order\Box\AtHome;
use Bpost\BpostApiClient\Bpost\Order\Box\CustomsInfo\CustomsInfo;
use Bpost\BpostApiClient\Bpost\Order\Box\International;
use Bpost\BpostApiClient\Bpost\Order\Box\Option\Insured;
use Bpost\BpostApiClient\Bpost\Order\Box\Option\Messaging;
use Bpost\BpostApiClient\Bpost\Order\Line;
use Bpost\BpostApiClient\Bpost\Order\PugoAddress;
use Bpost\BpostApiClient\Bpost\Order\Receiver;
use Bpost\BpostApiClient\Bpost\ProductConfiguration\Product;
use Bpost\BpostApiClient\BpostException;
use Psr\Log\LoggerInterface;

$apiUrl = 'https://shm-rest.bpost.cloud/services/shm';
$apiUsername = "107423";
$apiPassword = "MyGreatApiPassword";

$bpost = new Bpost($apiUsername, $apiPassword, $apiUrl);

/* We set the receiver postal address, without the name */
$receiverAddress = new Address();
$receiverAddress->setStreetName("Rue du Grand Duc");
$receiverAddress->setNumber(13);
$receiverAddress->setPostalCode(1040);
$receiverAddress->setLocality("Etterbeek");
$receiverAddress->setCountryCode("BE"); // ISO2

/* We set the receiver postal address, without the name */
$receiver = new Receiver();
$receiver->setAddress($receiverAddress);
$receiver->setName("Alma van Appel");
$receiver->setPhoneNumber("+32 2 641 13 90");
$receiver->setEmailAddress("alma@antidot.com");

$orderReference = "ref_0123456789"; // An unique order reference
$order = new Order($orderReference);

/**
 * A order line is an order item, like a article
 */
$order->addLine(
    new Line("Article description", 1)
);
$order->addLine(
    new Line("Some others articles", 5)
);

/**
 * A box is used to split your shipping in many packages
 * The box weight must be littlest than to 30kg
 */
$box = new Box();

/**
 * Available boxes for national box:
 * - AtHome: Delivered at the given address
 * - AtBpost: Delivered in a bpost office
 * - BpostOnAppointment: Delivered in a shop
 *
 * Available boxes for international box:
 * - International: Delivered at the given address
 */
$atHome = new AtHome();
$atHome->setProduct(Product::PRODUCT_NAME_BPACK_24H_BUSINESS);
$atHome->setReceiver($receiver);

/* Add options */
$atHome->addOption(
    new Insured(
        Insured::INSURANCE_TYPE_ADDITIONAL_INSURANCE,
        Insured::INSURANCE_AMOUNT_UP_TO_2500_EUROS
    )
);

$box->setNationalBox($atHome);

$order->addBox($box);
```

#### Create an order

[](#create-an-order)

We use the variables set before.

```
$bpost->createOrReplaceOrder($order); // The order is created with status Box::BOX_STATUS_PENDING
```

#### Update order status

[](#update-order-status)

```
$bpost->modifyOrderStatus($orderReference, Box::BOX_STATUS_OPEN);
```

#### Get order info

[](#get-order-info)

```
$order = $bpost->fetchOrder($orderReference);

$boxes = $order->getBoxes();
$lines = $order->getLines();
```

### Labels

[](#labels)

#### Get labels from an order

[](#get-labels-from-an-order)

```
$labels = $bpost->createLabelForOrder(
    $orderReference,
    Bpost::LABEL_FORMAT_A6, // $format
    false, // $withReturnLabels
    true // $asPdf
);
foreach ($labels as $label) {
    $barcode = $label->getBarcode();
    $mimeType = $label->getMimeType(); // Label::LABEL_MIME_TYPE_*
    $bytes = $label->getBytes();
    file_put_contents("$barcode.pdf", $bytes);
}
```

#### Get labels from an existing barcode

[](#get-labels-from-an-existing-barcode)

```
$labels = $bpost->createLabelForOrder(
    $boxBarcode,
    Bpost::LABEL_FORMAT_A6, // $format
    false, // $withReturnLabels
    true // $asPdf
);
foreach ($labels as $label) {
    $barcode = $label->getBarcode(); // Can be different than $boxBarcode if this is a return label
    $mimeType = $label->getMimeType(); // Label::LABEL_MIME_TYPE_*
    $bytes = $label->getBytes();
    file_put_contents("$barcode.pdf", $bytes);
}
```

#### Get labels from an existing barcode

[](#get-labels-from-an-existing-barcode-1)

```
$labels = $bpost->createLabelInBulkForOrders(
    array(
        $orderReference1,
        $orderReference2,
    ),
    Bpost::LABEL_FORMAT_A6, // $format
    false, // $withReturnLabels
    true // $asPdf
);
foreach ($labels as $label) {
    $barcode = $label->getBarcode(); // Can be different than $boxBarcode if this is a return label
    $mimeType = $label->getMimeType(); // Label::LABEL_MIME_TYPE_*
    $bytes = $label->getBytes();
    file_put_contents("$barcode.pdf", $bytes);
}
```

### Geo6 services

[](#geo6-services)

```
$geo6Partner = '999999';
$geo6AppId = 'A001';
$geo6 = new Geo6($geo6Partner, $geo6AppId);
```

#### Get nearest points

[](#get-nearest-points)

```
$points = $geo6->getNearestServicePoint(
    'Grand Place', // Street name
    '3', // Street number
    '1000', // Zip code
    'fr', // Language: 'fr' or 'nl'
    3, // Point types: Sum of some Geo6::POINT_TYPE_*
    5 // Points number
);
foreach ($points as $point) {
    $distance = $point['distance']; // float
    /** @var Poi $poi */
    $poi = $point['poi'];
}
```

#### Get point details

[](#get-point-details)

```
/** @var Poi $poi */
$poi = $geo6->getServicePointDetails(
    200000, // Point ID
    'fr', // Language: 'fr' or 'nl'
    3 // Point types: Sum of some Geo6::POINT_TYPE_*
);
```

#### Get point map URL

[](#get-point-map-url)

```
$url = $geo6->getServicePointPageUrl(
    200000, // Point ID
    'fr', // Language: 'fr' or 'nl'
    3 // Point types: Sum of some Geo6::POINT_TYPE_*
);
```

Sites using this class
----------------------

[](#sites-using-this-class)

- [Each site based on the Web Retail Shop Platform](http://www.webretailcompany.be)
- [The bpost plugin for WordPress](https://wordpress.org/plugins/bpost-shipping)

Would like contribute ?
-----------------------

[](#would-like-contribute-)

You can read the [CONTRIBUTING.md](https://github.com/Antidot-be/bpost-api-library/blob/master/CONTRIBUTING.md) file

###  Health Score

54

—

FairBetter than 96% of packages

Maintenance56

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity91

Battle-tested with a long release history

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

Recently: every ~0 days

Total

23

Last Release

294d ago

Major Versions

3.4.7 → 4.52024-02-15

4.6.2 → 5.0.02025-09-11

PHP version history (2 changes)3.0.x-devPHP &gt;=5.3.0

4.6.1aPHP ^8.1 || ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/54976150?v=4)[zangra-dev](/maintainers/zangra-dev)[@zangra-dev](https://github.com/zangra-dev)

---

Top Contributors

[![kouinkouin](https://avatars.githubusercontent.com/u/3999492?v=4)](https://github.com/kouinkouin "kouinkouin (133 commits)")[![tijsverkoyen](https://avatars.githubusercontent.com/u/250042?v=4)](https://github.com/tijsverkoyen "tijsverkoyen (113 commits)")[![lgnap](https://avatars.githubusercontent.com/u/915876?v=4)](https://github.com/lgnap "lgnap (25 commits)")[![zangra-dev](https://avatars.githubusercontent.com/u/54976150?v=4)](https://github.com/zangra-dev "zangra-dev (5 commits)")[![langemeijer](https://avatars.githubusercontent.com/u/1193933?v=4)](https://github.com/langemeijer "langemeijer (4 commits)")[![Cryde](https://avatars.githubusercontent.com/u/1662950?v=4)](https://github.com/Cryde "Cryde (3 commits)")[![hannesvdvreken](https://avatars.githubusercontent.com/u/1410358?v=4)](https://github.com/hannesvdvreken "hannesvdvreken (3 commits)")[![michielkalle](https://avatars.githubusercontent.com/u/14213930?v=4)](https://github.com/michielkalle "michielkalle (2 commits)")[![stijnster](https://avatars.githubusercontent.com/u/27271?v=4)](https://github.com/stijnster "stijnster (2 commits)")[![JMVzn](https://avatars.githubusercontent.com/u/116563045?v=4)](https://github.com/JMVzn "JMVzn (1 commits)")[![JeroenVanOort](https://avatars.githubusercontent.com/u/5616838?v=4)](https://github.com/JeroenVanOort "JeroenVanOort (1 commits)")[![basselin](https://avatars.githubusercontent.com/u/890510?v=4)](https://github.com/basselin "basselin (1 commits)")[![nils-m](https://avatars.githubusercontent.com/u/666276?v=4)](https://github.com/nils-m "nils-m (1 commits)")[![BenCavens](https://avatars.githubusercontent.com/u/497668?v=4)](https://github.com/BenCavens "BenCavens (1 commits)")[![StijnVrolijk](https://avatars.githubusercontent.com/u/442529?v=4)](https://github.com/StijnVrolijk "StijnVrolijk (1 commits)")[![Filipvds](https://avatars.githubusercontent.com/u/1713243?v=4)](https://github.com/Filipvds "Filipvds (1 commits)")[![toonevdb](https://avatars.githubusercontent.com/u/2579951?v=4)](https://github.com/toonevdb "toonevdb (1 commits)")[![twarlop](https://avatars.githubusercontent.com/u/2856082?v=4)](https://github.com/twarlop "twarlop (1 commits)")[![veloxy](https://avatars.githubusercontent.com/u/491675?v=4)](https://github.com/veloxy "veloxy (1 commits)")[![webcraft](https://avatars.githubusercontent.com/u/56675?v=4)](https://github.com/webcraft "webcraft (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zangra-bpost-api-library/health.svg)

```
[![Health](https://phpackages.com/badges/zangra-bpost-api-library/health.svg)](https://phpackages.com/packages/zangra-bpost-api-library)
```

###  Alternatives

[sylius/sylius

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

8.5k5.9M736](/packages/sylius-sylius)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)[keboola/storage-api-client

Keboola Storage API PHP Client

10405.9k39](/packages/keboola-storage-api-client)[flowwow/cloudpayments-php-client

cloudpayments api client

21101.2k](/packages/flowwow-cloudpayments-php-client)

PHPackages © 2026

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