PHPackages                             shusaura85/fancourier-api - 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. shusaura85/fancourier-api

ActiveLibrary[API Development](/categories/api)

shusaura85/fancourier-api
=========================

Library for FanCourier API v2.0

v2.0.22(3mo ago)273.4k↓34.7%13MITPHPPHP &gt;=7.0

Since Oct 5Pushed 3mo ago2 watchersCompare

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

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

FANCourier API v2.0
===================

[](#fancourier-api-v20)

Table of contents
-----------------

[](#table-of-contents)

- [Information](#information)
- [Installation](#installation)
    - [Requirements](#requirements)
    - [Composer](#composer)
- [Usage](#usage)
    - [Authentication](#authentication)
    - [Get estimated shipping cost](#get-estimated-shipping-cost)
    - [Create AWB](#create-awb)
    - [Create AWB in bulk](#create-awb-in-bulk)
    - [Track AWB](#track-awb)
    - [Track awb in bulk](#track-awb-in-bulk)
    - [FANBox](#fanbox)
    - [Print AWB (PDF)](#print-awb)
    - [Print AWB (ZPL)](#print-awb-zpl)
    - [Print AWB Html](#print-awb-html)
    - [Delete AWB](#delete-awb)
- [License](#license)

Information
-----------

[](#information)

This version of the library is designed for FANCourier API v2.0 (JSON based responses). The code works and there are examples for all API requests, however, the documentation is not yet ready.

All requests have the method `getData()` that returns the unprocessed response of the API. Aditional functions depend on the response object type to return processed data.

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

[](#installation)

### Requirements

[](#requirements)

- PHP &gt;= 7.0

**NOTE** At the moment it's designed to work with PHP 7.0 and newer.
However, the plan is to add type and return type declarations for all functions that will push the requirements to PHP 8.1 at the minimum

### Composer

[](#composer)

Require the package via composer

```
composer require shusaura85/fancourier-api
```

### Manual

[](#manual)

If used without composer, you will need to manually require the `autoload.php` file

```
require_once '/path/to/fancourier-api/src/autoload.php';
```

Usage
-----

[](#usage)

At the moment complete and proper documentation is not yet available. However, there are examples for every request type you can make.
Inside them you will also find comments with complete function list for each `request`, `response` and `object`.

### Authentication

[](#authentication)

Create a new instance of `Fancourier.php` supplying the `client_id`, `username`, `password` and `token`.

```
$clientId = 'your_client_id';
$username = 'your_username';
$password = 'your_password';
$token = 'load from cache or leave as empty string';

$fan = new Fancourier\Fancourier($clientId, $username, $password, $token);
```

Or you can use the test instance static method:

```
$fan = Fancourier\Fancourier::testInstance($token);
```

The generated token has a life time of 24 hours and must be refreshed after this period. You can get the generated token using the function:

```
$force_refresh = false;
$token = $fan->getToken($force_refresh);

```

If the specified token is empty when creating the instance, it will be generated automatically on the first request.

### Get estimated shipping cost

[](#get-estimated-shipping-cost)

Request

```
$request = new Fancourier\Request\GetCosts();
$request
    ->setParcels(1)
    ->setWeight(1)
    ->setCounty('Arad')
    ->setCity('Aciuta')
    ->setDeclaredValue(125);
```

Response

```
if ($response->isOk()) {
    var_dump($response->getData()); // raw data
    // or just the information you want
    echo "extraKmCost: ". $response->getKmCost().'';
    echo "weightCost: ". $response->getWeightCost().'';
    echo "insuranceCost: ". $response->getInsuranceCost().'';
    echo "optionsCost: ". $response->getOptionsCost().'';
    echo "fuelCost: ". $response->getFuelCost().'';
    echo "costNoVAT: ". $response->getCost().'';
    echo "vat: ". $response->getCostVat().'';
    echo "total: ".$response->getCostTotal().'';
} else {
    var_dump($response->getErrorMessage());
    print_r($response->getAllErrors());
}
```

### Create AWB

[](#create-awb)

Request

```
$awb = new Fancourier\Objects\AwbIntern();
$awb
    ->setService('Cont Colector')
    ->setPaymentType(Fancourier\Request\CreateAwb::TYPE_SENDER)
    ->setParcels(1)
    ->setWeight(1)    // in kg
    ->setReimbursement(199.99) // suma de incasat
    ->setDeclaredValue(1000)
    ->setSizes(10,5,1) // in cm
    ->setNotes('testing notes')
    ->setContents('SKU-1, SKU-2')
    ->setRecipientName("John Ivy")
    ->setPhone('0723000000')
    ->setCounty('Arad')
    ->setCity('Aciuta')
    ->setStreet('Str Lunga')
    ->setNumber(1)
    ->addOption('S')
    ->addOption('X');

$request = new Fancourier\Request\CreateAwb();
$request->addAwb($awb);
```

Response

```
$response = $fan->createAwb($request);

if ($response->isOk()) {
    var_dump($response->getData()); // raw data
    // or the AWBIntern objects updated with the response information
    $al = $response->getAll();
    echo "Count: ".count($al)."";
    foreach ($al as $awbr)
        {
        if ($awbr->hasErrors())
            {
            print_r($awbr->getErrors());
            }
        else
            {
            echo "AWB: ".$awbr->getAwb()."";
            }
        }

} else {
    var_dump($response->getErrorMessage());
}
```

### Create AWB in bulk

[](#create-awb-in-bulk)

Unlike the previous version, there is no longer a CreateAwbBulk request. Simply create as many AWBIntern objects and add them to the request

Request

```
$request = new Fancourier\Request\CreateAwb();

// create the first awb
$awb = new Fancourier\Objects\AwbIntern();
$awb
    ->setService('Cont Colector')
    ....
    ->addOption('X');

// add it to the request
$request->addAwb($awb);

// create another awb
$awb = new Fancourier\Objects\AwbIntern();
$awb
    ->setService('Cont Colector')
    ....
    ->addOption('X');

// add it to the request
$request->addAwb($awb);

// create another awb
$awb = new Fancourier\Objects\AwbIntern();
$awb
    ->setService('Cont Colector')
    ....
    ->addOption('X');

// add it to the request
$request->addAwb($awb);
```

Response

```
$response = $fan->createAwb($request);

if ($response->isOk()) {
    var_dump($response->getData()); // raw data
    // or the AWBIntern objects updated with the response information
    $al = $response->getAll();
    echo "Count: ".count($al)."";
    foreach ($al as $awbr)
        {
        if ($awbr->hasErrors())
            {
            print_r($awbr->getErrors());
            }
        else
            {
            echo "AWB: ".$awbr->getAwb()."";
            }
        }

} else {
    var_dump($response->getErrorMessage());
}
```

### Track AWB

[](#track-awb)

Request

```
$request = new Fancourier\Request\TrackAwb();
$request
    ->setAwb('2150900120086');
```

Response

```
$response = $fan->trackAwb($request);

if ($response->isOk()) {
    print_r($response->getData()); // raw data
    print_r($response->getAll()); // array of AwbTracker objects
} else {
    var_dump($response->getErrorMessage());
}
```

### Track awb in bulk

[](#track-awb-in-bulk)

Unlike previous version, you can use the same TrackAwb() object and add as many AWB's as you need to Track

Request

```
$request = new Fancourier\Request\TrackAwb();
$request
    ->addAwb('2150900120084')
    ->addAwb('2150900120085')
    ->addAwb('2150900120086');
```

Response

```
$response = $fan->trackAwb($request);

if ($response->isOk()) {
    print_r($response->getData()); // raw data
    print_r($response->getAll()); // array of AwbTracker objects
} else {
    var_dump($response->getErrorMessage());
}
```

### FANBox

[](#fanbox)

You can now easily get information about available FANBox and PayPoint locations. FAN Courier calls there PUDO (Pick Up Drop Off).
When creating an AWB for them, set the address to the PUDO address as received here as well as calling the function `setPickupLocation(PUDO_ID)` with the ID of the selected PUDO.

Request

```
$request = new Fancourier\Request\GetPudo();
$request
    ->setType(Fancourier\Request\GetPudo::PUDO_FANBOX);
```

Response

```
$response = $fan->getPudo($request);

if ($response->isOk()) {
    print_r($response->getData()); // raw data
    print_r($response->getAll()); // array of PUDO objects
} else {
    var_dump($response->getErrorMessage());
}
```

### Print AWB

[](#print-awb)

The print request can print one or more AWBs using a single request.
You can specify the size of the AWB using the `->setSize()` function. Available options are: *empty*, **A4**, **A5** and **A6**. **A6** can only be used with ePod option.
PDF printing is the default mode of printing.
Please note that you can't request ZPL and PDF at the same time. Using `setPdf()` will automatically disable ZPL option if set.

Request

```
$request = new Fancourier\Request\PrintAwb();
$request
    ->setPdf(true)
    ->setAwb('2150900120086');
```

Response

```
$response = $fan->printAwb($request);
if ($response->isOk()) {
    echo $response->getData();
} else {
    var_dump($response->getErrorMessage());
    print_r($response->getAllErrors());
}
```

### Print AWB ZPL

[](#print-awb-zpl)

You can request the AWB in the ZPL format (Zebra Programming Language) for use with a label printer.
Please note that you can't request ZPL and PDF at the same time. Using `setZpl()` will automatically disable PDF option if set.

Request

```
$request = new Fancourier\Request\PrintAwb();
$request
    ->setZpl(true)
    ->setAwb('2150900120086');
```

Response

```
$response = $fan->printAwb($request);
if ($response->isOk()) {
    echo $response->getData();
} else {
    var_dump($response->getErrorMessage());
    print_r($response->getAllErrors());
}
```

### Print AWB Html

[](#print-awb-html)

If you want the AWB in a HTML format, just use -&gt;setPdf(false) to get HTML data instead of PDF.

Request

```
$request = new Fancourier\Request\PrintAwb();
$request
    ->setPdf(false)
    ->setAwb('2150900120086');
```

Response

```
$response = $fan->printAwb($request);
if ($response->isOk()) {
    echo $response->getData();
} else {
    var_dump($response->getErrorMessage());
    print_r($response->getAllErrors());
}
```

### Delete AWB

[](#delete-awb)

Request

```
$request = new Fancourier\Request\DeleteAwb();
$request->setAwb('2150900120086');
```

Response

```
$response = $fan->deleteAwb($request);
if ($response->isOk()) {
    var_dump($response->getData());
} else {
    var_dump($response->getErrorMessage());
}
```

License
-------

[](#license)

Fancourier Api is open-source software licensed under the [MIT license](./LICENSE).

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance81

Actively maintained with recent releases

Popularity34

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 88.1% 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 ~83 days

Recently: every ~62 days

Total

25

Last Release

99d ago

Major Versions

v1.2.1 → v2.0.02023-12-23

PHP version history (2 changes)1.2.0PHP ^7.0

v1.2.1PHP &gt;=7.0

### Community

Maintainers

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

---

Top Contributors

[![shusaura85](https://avatars.githubusercontent.com/u/35106430?v=4)](https://github.com/shusaura85 "shusaura85 (89 commits)")[![daika7ana](https://avatars.githubusercontent.com/u/11703528?v=4)](https://github.com/daika7ana "daika7ana (8 commits)")[![aemarcuss](https://avatars.githubusercontent.com/u/4222987?v=4)](https://github.com/aemarcuss "aemarcuss (2 commits)")[![horatiua](https://avatars.githubusercontent.com/u/3829689?v=4)](https://github.com/horatiua "horatiua (1 commits)")[![stefanbutura](https://avatars.githubusercontent.com/u/26040792?v=4)](https://github.com/stefanbutura "stefanbutura (1 commits)")

---

Tags

api-clientcourierfanfan-courierfancourierjsonjson-apilibraryphpphp-library

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shusaura85-fancourier-api/health.svg)

```
[![Health](https://phpackages.com/badges/shusaura85-fancourier-api/health.svg)](https://phpackages.com/packages/shusaura85-fancourier-api)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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