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

ActiveLibrary[API Development](/categories/api)

sengentobv/bpost-api-library
============================

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

4.0.0(4y ago)03BSD-3-ClausePHPPHP ^7.4||^8.0

Since Nov 18Pushed 4y agoCompare

[ Source](https://github.com/SengentoBV/bpost-api-library)[ Packagist](https://packagist.org/packages/sengentobv/bpost-api-library)[ Docs](https://github.com/SengentoBV/bpost-api-library)[ RSS](/packages/sengentobv-bpost-api-library/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

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

[](#bpost-api-client)

[![Latest Stable Version](https://camo.githubusercontent.com/29315cc06f675ebb3ae14dbe8d1c70b430bb2b636a7fd51e278597b278d1b961/687474703a2f2f706f7365722e707567782e6f72672f73656e67656e746f62762f62706f73742d6170692d6c6962726172792f76)](https://packagist.org/packages/sengentobv/bpost-api-library)[![Total Downloads](https://camo.githubusercontent.com/76f1f3c3f6897e5d64b8754ae82d3fa83e87dd365e3de4e563d9c6779803731b/687474703a2f2f706f7365722e707567782e6f72672f73656e67656e746f62762f62706f73742d6170692d6c6962726172792f646f776e6c6f616473)](https://packagist.org/packages/sengentobv/bpost-api-library)[![Latest Unstable Version](https://camo.githubusercontent.com/4ea08e789d4f73413083236ce2380b26082e75ef45322c3c0c0359bf769e7687/687474703a2f2f706f7365722e707567782e6f72672f73656e67656e746f62762f62706f73742d6170692d6c6962726172792f762f756e737461626c65)](https://packagist.org/packages/sengentobv/bpost-api-library)[![License](https://camo.githubusercontent.com/7a62a7777fee8cb3075c3346d25b6531ab6baeeaccf097f3a8ee9fb0b5aaceaf/687474703a2f2f706f7365722e707567782e6f72672f73656e67656e746f62762f62706f73742d6170692d6c6962726172792f6c6963656e7365)](https://packagist.org/packages/sengentobv/bpost-api-library)[![PHP Version Require](https://camo.githubusercontent.com/073f9d2f36820a844a9a826ee06f023657ee80ebde17d1cf4991effc86f98261/687474703a2f2f706f7365722e707567782e6f72672f73656e67656e746f62762f62706f73742d6170692d6c6962726172792f726571756972652f706870)](https://packagist.org/packages/sengentobv/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 sengentobv/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\Insurance;
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://api.bpost.be/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 Insurance(
        Insurance::INSURANCE_TYPE_ADDITIONAL_INSURANCE,
        Insurance::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_*
);
```

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

[](#would-like-contribute-)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1633d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a59f45bacb65b32313f783ecc9baeddc08f00734eb2434b0dd0e4ebb235b057?d=identicon)[mylemans](/maintainers/mylemans)

---

Top Contributors

[![tijsverkoyen](https://avatars.githubusercontent.com/u/250042?v=4)](https://github.com/tijsverkoyen "tijsverkoyen (113 commits)")[![kouinkouin](https://avatars.githubusercontent.com/u/3999492?v=4)](https://github.com/kouinkouin "kouinkouin (109 commits)")[![lgnap](https://avatars.githubusercontent.com/u/915876?v=4)](https://github.com/lgnap "lgnap (25 commits)")[![mylemans](https://avatars.githubusercontent.com/u/749261?v=4)](https://github.com/mylemans "mylemans (11 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)")[![stijnster](https://avatars.githubusercontent.com/u/27271?v=4)](https://github.com/stijnster "stijnster (2 commits)")[![michielkalle](https://avatars.githubusercontent.com/u/14213930?v=4)](https://github.com/michielkalle "michielkalle (2 commits)")[![webcraft](https://avatars.githubusercontent.com/u/56675?v=4)](https://github.com/webcraft "webcraft (1 commits)")[![basselin](https://avatars.githubusercontent.com/u/890510?v=4)](https://github.com/basselin "basselin (1 commits)")[![xewl](https://avatars.githubusercontent.com/u/245041?v=4)](https://github.com/xewl "xewl (1 commits)")[![BenCavens](https://avatars.githubusercontent.com/u/497668?v=4)](https://github.com/BenCavens "BenCavens (1 commits)")[![Filipvds](https://avatars.githubusercontent.com/u/1713243?v=4)](https://github.com/Filipvds "Filipvds (1 commits)")[![JeroenVanOort](https://avatars.githubusercontent.com/u/5616838?v=4)](https://github.com/JeroenVanOort "JeroenVanOort (1 commits)")[![Lambik](https://avatars.githubusercontent.com/u/467373?v=4)](https://github.com/Lambik "Lambik (1 commits)")[![StijnVrolijk](https://avatars.githubusercontent.com/u/442529?v=4)](https://github.com/StijnVrolijk "StijnVrolijk (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)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M647](/packages/sylius-sylius)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69333.0M113](/packages/algolia-algoliasearch-client-php)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[alexacrm/dynamics-webapi-toolkit

Web API toolkit for Microsoft Dynamics 365 and Dynamics CRM

81324.1k1](/packages/alexacrm-dynamics-webapi-toolkit)[comgate/sdk

Comgate PHP SDK

13327.8k](/packages/comgate-sdk)

PHPackages © 2026

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