PHPackages                             tijsverkoyen/bpost - 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. tijsverkoyen/bpost

ActiveLibrary[API Development](/categories/api)

tijsverkoyen/bpost
==================

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

3.0.3(9y ago)2843.1k50[5 issues](https://github.com/tijsverkoyen/bpost/issues)[3 PRs](https://github.com/tijsverkoyen/bpost/pulls)BSDPHPPHP &gt;=5.3.0

Since May 9Pushed 4y ago6 watchersCompare

[ Source](https://github.com/tijsverkoyen/bpost)[ Packagist](https://packagist.org/packages/tijsverkoyen/bpost)[ Docs](https://github.com/tijsverkoyen/bpost)[ RSS](/packages/tijsverkoyen-bpost/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (7)Used By (0)

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

[](#bpost-api-client)

[![Build Status](https://camo.githubusercontent.com/3ddbd2c396f35b0b1069f1d241352501d8fdd66a1928a03fc5abb1d00f3a0e7e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416e7469646f742d62652f62706f73742d6170692d6c6962726172792f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Antidot-be/bpost-api-library)[![Latest Stable Version](https://camo.githubusercontent.com/9304d2fcae33671fe6629a4da90bbe8a729535e6ceecd27d0898eb6ce792f9ad/68747470733a2f2f706f7365722e707567782e6f72672f616e7469646f742d62652f62706f73742d6170692d6c6962726172792f762f737461626c65)](https://packagist.org/packages/antidot-be/bpost-api-library)[![Latest Unstable Version](https://camo.githubusercontent.com/e8a3b82c96aa7c6d1dc7ec17b53ac7245f84dae7cfc1f25b45f060afd155bd58/68747470733a2f2f706f7365722e707567782e6f72672f616e7469646f742d62652f62706f73742d6170692d6c6962726172792f762f756e737461626c65)](https://packagist.org/packages/antidot-be/bpost-api-library)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/dc7fdd56bb2be39da591c046b3c59e974e9b98e4cf80948b9645911d233e5d4f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416e7469646f742d62652f62706f73742d6170692d6c6962726172792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Antidot-be/bpost-api-library)[![Code Coverage](https://camo.githubusercontent.com/18d947b9fbf28da7828a1885ac93523d7201155c2c0cc2a47d7a6bda94b8293d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416e7469646f742d62652f62706f73742d6170692d6c6962726172792f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Antidot-be/bpost-api-library)[![Total Downloads](https://camo.githubusercontent.com/182cddda515f50cf503b990a244761564c122a29c8afc7675444aa9deab795f8/68747470733a2f2f706f7365722e707567782e6f72672f616e7469646f742d62652f62706f73742d6170692d6c6962726172792f646f776e6c6f616473)](https://packagist.org/packages/antidot-be/bpost-api-library)[![License](https://camo.githubusercontent.com/ee4361ce79b3216a82cef5ad2cd46078878a83767fd9998109ef550d5d89ff6a/68747470733a2f2f706f7365722e707567782e6f72672f616e7469646f742d62652f62706f73742d6170692d6c6962726172792f6c6963656e7365)](https://packagist.org/packages/antidot-be/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 antidot-be/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_*
);
```

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

37

—

LowBetter than 83% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 54.5% 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 ~200 days

Total

5

Last Release

3587d ago

### Community

Maintainers

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

---

Top Contributors

[![tijsverkoyen](https://avatars.githubusercontent.com/u/250042?v=4)](https://github.com/tijsverkoyen "tijsverkoyen (114 commits)")[![kouinkouin](https://avatars.githubusercontent.com/u/3999492?v=4)](https://github.com/kouinkouin "kouinkouin (82 commits)")[![langemeijer](https://avatars.githubusercontent.com/u/1193933?v=4)](https://github.com/langemeijer "langemeijer (4 commits)")[![hannesvdvreken](https://avatars.githubusercontent.com/u/1410358?v=4)](https://github.com/hannesvdvreken "hannesvdvreken (3 commits)")[![twarlop](https://avatars.githubusercontent.com/u/2856082?v=4)](https://github.com/twarlop "twarlop (1 commits)")[![BenCavens](https://avatars.githubusercontent.com/u/497668?v=4)](https://github.com/BenCavens "BenCavens (1 commits)")[![veloxy](https://avatars.githubusercontent.com/u/491675?v=4)](https://github.com/veloxy "veloxy (1 commits)")[![Filipvds](https://avatars.githubusercontent.com/u/1713243?v=4)](https://github.com/Filipvds "Filipvds (1 commits)")[![Lambik](https://avatars.githubusercontent.com/u/467373?v=4)](https://github.com/Lambik "Lambik (1 commits)")[![toonevdb](https://avatars.githubusercontent.com/u/2579951?v=4)](https://github.com/toonevdb "toonevdb (1 commits)")

### Embed Badge

![Health badge](/badges/tijsverkoyen-bpost/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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