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

ActiveLibrary[API Development](/categories/api)

firewizard/fancourier-api
=========================

Consumer for FanCourier API

v2.1.1(2y ago)71.2k4MITPHPPHP ^7.0

Since Jun 25Pushed 2y ago2 watchersCompare

[ Source](https://github.com/firewizard/fancourier-api)[ Packagist](https://packagist.org/packages/firewizard/fancourier-api)[ RSS](/packages/firewizard-fancourier-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (16)Used By (0)

FANCourier API v2
=================

[](#fancourier-api-v2)

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

[](#table-of-contents)

- [Installation](#installation)
    - [Requirements](#composer)
    - [Composer](#composer)
- [Usage](#usage)
    - [Authentication](#authentication)
    - [Get estimated shipping cost](#get-estimated-shipping-cost)
    - [Create AWB](#create-awb)
    - [Create AWB in bulk](#create-awb-bulk)
    - [Track AWB](#track-awb)
    - [Print AWB](#print-awb)
    - [Print AWB Html](#print-awb-html)
    - [Delete AWB](#delete-awb)
    - [Track AWB in bulk](#track-awb-in-bulk)
    - [Get cities](#get-cities)
    - [Get counties](#get-counties)
    - [Get services](#get-services)
- [Features not implemented](#features-not-implemented)
- [Contributing](#contributing)
- [License](#license)

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

[](#installation)

### Requirements

[](#requirements)

- PHP &gt;= 7.0
- ext-curl
- ext-json

### Composer

[](#composer)

Require the package via composer

```
composer require firewizard/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';
```

Breaking changes from v1
------------------------

[](#breaking-changes-from-v1)

- removed Auth class
- removed SendsFile trait
- getCities city array keys have changed (*county* instead of *judet*, *name* instead of *localitate*, *exteriorKm* instead of *km*)
- CreateAwbBulk response body is now an array of AWBs instead of an array of CreateAwb response objects
- trackAwb now returns the full events list, as an array, not just the last message
- trackAwbBulk now returns the full events list, as an array, with info about all AWBs in the request. It's up to you to group by AWB

Usage
-----

[](#usage)

### Authentication

[](#authentication)

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

```
$clientId = 'your_client_id';
$username = 'your_username';
$password = 'your_password';

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

Or you can use the test instance static method:

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

### Caching the auth token

[](#caching-the-auth-token)

By default, authentication is always called, which means for every regular request, there will be an extra request to obtain the auth token. You can fix this and cache the auth token in your app.

First, you need to create a new class that implements `Fancourier\AuthTokenCacheContract`:

```
class FancourierAuthCache implements AuthTokenCacheContract
{
    const CACHE_KEY = 'fancourier_auth_token';
    const CACHE_LIFETIME = 43200; //12 hrs

    public function get()
    {
        return Cache::get(static::CACHE_KEY);
    }

    public function set($value)
    {
        Cache::put(static::CACHE_KEY, $value, static::CACHE_LIFETIME);
    }
}
```

Then, pass this to the main Fancourier object:

```
$api = new Fancourier(...);
$api->useAuthTokenCache(new FancourierAuthCache());
```

*Note*: Tokens change every 24 hours according to Fan Courier, so might want to use a lower cache TTL.

### Get estimated shipping cost

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

Request

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

Response

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

### Create AWB

[](#create-awb)

Request

```
$request = new Fancourier\Request\CreateAwb();
$request
    ->setParcels(1)
    ->setWeight(2)
    ->setReimbursement(125)
    ->setDeclaredValue(125)
    ->setNotes('testing notes')
    ->setContents('SKU-1, SKU-2')
    ->setRecipient("John Ivy")
    ->setPhone('0723000000')
    ->setRegion('Arad')
    ->setCity('Aciuta')
    ->setStreet('Str Lunga nr 1');
```

Response

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

### Create AWB Bulk

[](#create-awb-bulk)

Request

```
$batchRequest = new Fancourier\Request\CreateAwbBulk();
$request = new Fancourier\Request\CreateAwb();
$request
    ->setParcels(1)
    ->setWeight(2)
    ->setReimbursement(125)
    ->setDeclaredValue(125)
    ->setNotes('testing notes')
    ->setContents('SKU-1, SKU-2')
    ->setRecipient("John Ivy")
    ->setPhone('0723000000')
    ->setRegion('Arad')
    ->setCity('Aciuta')
    ->setStreet('Str Lunga nr 1')
;
$batchRequest->append($request);

$request
    ->setParcels(1)
    ->setWeight(1.5)
    ->setReimbursement(50)
    ->setDeclaredValue(50)
    ->setContents('SKU-7')
    ->setRecipient("Tester Testerson")
    ->setPhone('0722111000')
    ->setRegion('Sibiu')
    ->setCity('Sibiu')
    ->setStreet('Calea Bucuresti nr 1')
;
$batchRequest->append($request);

$response = $fan->createAwbBulk($batchRequest);
if (!$response->isOk()) {
    //general error
    die($response->getErrorMessage());
}

foreach ($response->getBody() as $awb) {
    echo $awb . "\n";
}
```

### Track AWB

[](#track-awb)

Request

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

Response

```
$response = $fan->trackAwb($request);
if ($response->isOk()) {
    print_r($response->getBody());
} else {
    print_r($response->getErrorMessage());
}
```

### Print AWB

[](#print-awb)

Request

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

Response

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

### Print AWB Html

[](#print-awb-html)

Request

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

Response

```
$response = $fan->printAwbHtml($request);
if ($response->isOk()) {
    echo $response->getBody();
} else {
    var_dump($response->getErrorMessage());
}
```

### Delete AWB

[](#delete-awb)

Request

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

Response

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

### Track awb in bulk

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

Request

```
$request = new Fancourier\Request\TrackAwbBulk();
$request->setAwbs(['2162900120047']);
```

Response

```
$response = $fan->trackAwbBulk($request);
if ($response->isOk()) {
    print_r($response->getBody());
} else {
    var_dump("ERROR: " . $response->getErrorMessage());
}
```

### Get cities

[](#get-cities)

Request - There's no request for this method

Response - will return an array of cities (and other info)

```
$response = $fan->getCities();
if ($response->isOk()) {
    print_r($response->getBody());
} else {
    var_dump("ERROR: " . $response->getErrorMessage());
}
```

### Get counties

[](#get-counties)

Request - There's no request for this method

Response - will return an array of counties

```
$response = $fan->getCounties();
if ($response->isOk()) {
    print_r($response->getBody());
} else {
    var_dump("ERROR: " . $response->getErrorMessage());
}
```

### Get services

[](#get-services)

Request - There's no request for this method

Response - will return an array with all services

```
$response = $fan->getServices();
if ($response->isOk()) {
    print_r($response->getBody());
} else {
    var_dump("ERROR: " . $response->getErrorMessage());
}
```

Features not implemented
------------------------

[](#features-not-implemented)

Feel free to open a pull request for the following features:

- get pudo
- get streets
- external functions
- create carrier request
- delete carrier request
- summary
- get awb tracking events
- bank transfers
- orders functions
- branches

Contributing
------------

[](#contributing)

Thank you for considering contributing to the Fancourier API, all pull requests are appreciated.

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~124 days

Recently: every ~8 days

Total

15

Last Release

776d ago

Major Versions

v1.x-dev → v2.0.02024-02-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/35505409f9e5afadb08ba22c146d224a1ec9af6f3c4acd83c4adeee0f3288c26?d=identicon)[firewizard](/maintainers/firewizard)

---

Top Contributors

[![firewizard](https://avatars.githubusercontent.com/u/1143980?v=4)](https://github.com/firewizard "firewizard (24 commits)")[![adrianbarbos](https://avatars.githubusercontent.com/u/6648011?v=4)](https://github.com/adrianbarbos "adrianbarbos (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)[facebook/php-business-sdk

PHP SDK for Facebook Business

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

PHP wrapper for the Meilisearch API

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

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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