PHPackages                             janar/smartpost-shipping-php - 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. janar/smartpost-shipping-php

ActiveLibrary

janar/smartpost-shipping-php
============================

Simple client library for PHP to create shipments using smartpost web service

0.91(9y ago)5202[1 issues](https://github.com/janar/smartpost-shipping-php/issues)[1 PRs](https://github.com/janar/smartpost-shipping-php/pulls)PHPPHP ^5.3

Since Aug 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/janar/smartpost-shipping-php)[ Packagist](https://packagist.org/packages/janar/smartpost-shipping-php)[ Docs](https://github.com/janar/smartpost-shipping-php)[ RSS](/packages/janar-smartpost-shipping-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Note
====

[](#note)

API changed in 2023 Q1 I have not tested that does this implementation here still work.

Client library for Itella Smartpost API written in PHP.
=======================================================

[](#client-library-for-itella-smartpost-api-written-in-php)

Simple PHP client for creating Itella Smartpost () parcels via web API. Can be used to automate parcel creation and getting shipping labels for them.

Communication is done using XML. Original Smartpost API documents can be found here:

Currently this library is in development, but shipments to parcel terminals (Estonia and Finland) work. Also you can request shipping labels from API. So you would never have to enter Smartpost client area.

- Uses CURL for requests.
- Many requests and features not here yet.

---

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

[](#installation)

Easiest way to install the library is through [Composer](http://getcomposer.org):

```
$ composer require janar/smartpost-shipping-php
```

Basic usage
===========

[](#basic-usage)

Most basic and useful feature in this library would be creating shipments on your own server. Removes need for manual exporting/importing CSV files to Smartpost environment.

Creating shipments:
-------------------

[](#creating-shipments)

```
$spApi = new Client( "smartpost username", "smartpost password" );

//create shipments
$shipment = new Shipment();
$shipment->setRecipient( new Recipient( "John Doe", "56666661", "john.doe@doe123.com" ) );
$shipment->setReference( '[MyAwsomeWebShop] - test #1' );
$shipment->setDestination( new ParcelTerminal( 172 ) );
$spApi->addShipment( $shipment );

$shipment = new Shipment();
$shipment->setRecipient( new Recipient( "John Doe2", "56666662", "john.doe2@doe123.com" ) );
$shipment->setReference( '[MyAwsomeWebShop] - test #2' );
$shipment->setDestination( new ParcelTerminal( 171 ) );
$spApi->addShipment( $shipment );

$shipment = new Shipment();
$shipment->setRecipient( new Recipient( "John Doe3", "56666663", "john.doe3@doe123.com" ) );
$shipment->setDestination( new ParcelTerminal( null, "3202", "00215" ) );
$spApi->addShipment( $shipment );

$result = $spApi->postShipments();
```

Creating shipments result:
--------------------------

[](#creating-shipments-result)

[![Alt text](https://cloud.githubusercontent.com/assets/893499/17436624/ffff0786-5b20-11e6-8107-4b967971af61.png "Creating shipments result")](https://cloud.githubusercontent.com/assets/893499/17436624/ffff0786-5b20-11e6-8107-4b967971af61.png)

Shipments in Smartpost dashboard:
---------------------------------

[](#shipments-in-smartpost-dashboard)

[![Alt text](https://cloud.githubusercontent.com/assets/893499/17436622/fffa4caa-5b20-11e6-8c34-dee707488b22.png "Shipments in Smartpost dashboard")](https://cloud.githubusercontent.com/assets/893499/17436622/fffa4caa-5b20-11e6-8c34-dee707488b22.png)

---

3. Retrieving shipping labels (as pdf document)
-----------------------------------------------

[](#3-retrieving-shipping-labels-as-pdf-document)

Shipping labels are generated on Smartpost side and they are in pdf format. Only format and barcode(s) / tracking codes are needed to get labels on pdf. Formats are following:

FormatDescriptionA51 label on A5 sized paperA61 label on A6 sized paperA6-44 labels fitted on A6 sized paperA71 label on A7 sized paperA7-88 labels fitted on A7 sized paperA61 label on A6 sized paperLabels are on one continuous pdf document. You can choose what to do with result. Save as file or view in browser.

```
$spApi = new Client( "smartpost username", "smartpost password" );
$trackingCodes = array( '6895100008876963', '6895100008876964' );
$result = $spApi->getShippingLabels( $trackingCodes, 'A6-4' );

if( $result === false  ){
  echo $spApi->getLastError() . "";
} else {
  //Here we stream pdf directly to browser, but you may also save returned content as file for local use.
  header("Content-type:application/pdf");
  header("Content-Disposition:inline;filename='shipping-labels.pdf'");
  echo $result;
  exit;
}
```

Results would look something like this:

[![Alt text](https://cloud.githubusercontent.com/assets/893499/17839835/75d10ef8-67fd-11e6-8733-a2727ec6d8ce.png "Labels ready for printing")](https://cloud.githubusercontent.com/assets/893499/17839835/75d10ef8-67fd-11e6-8733-a2727ec6d8ce.png)

---

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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

Unknown

Total

1

Last Release

3550d ago

### Community

---

Top Contributors

[![janar-give](https://avatars.githubusercontent.com/u/263973930?v=4)](https://github.com/janar-give "janar-give (15 commits)")[![janar](https://avatars.githubusercontent.com/u/893499?v=4)](https://github.com/janar "janar (1 commits)")

### Embed Badge

![Health badge](/badges/janar-smartpost-shipping-php/health.svg)

```
[![Health](https://phpackages.com/badges/janar-smartpost-shipping-php/health.svg)](https://phpackages.com/packages/janar-smartpost-shipping-php)
```

PHPackages © 2026

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