PHPackages                             dan-rogers/shiptheory-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. [API Development](/categories/api)
4. /
5. dan-rogers/shiptheory-php

ActiveLibrary[API Development](/categories/api)

dan-rogers/shiptheory-php
=========================

An API client to communicate with the Shiptheory API

v2.2.1(3y ago)22.6k↑121.4%MITPHPPHP &gt;= 5.6

Since Apr 29Pushed 3y ago1 watchersCompare

[ Source](https://github.com/DanRVP/shiptheory-php)[ Packagist](https://packagist.org/packages/dan-rogers/shiptheory-php)[ RSS](/packages/dan-rogers-shiptheory-php/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)DependenciesVersions (18)Used By (0)

Shiptheory API library for PHP
==============================

[](#shiptheory-api-library-for-php)

A Python version exists: [Shiptheory API library for Python](https://github.com/DanRVP/shiptheory-python)

- To create pull requests fork this repository (Please adhere to the guidelines in the pull request template).
- Use GitHub issues to detail any problems encountered.

Features
--------

[](#features)

- Build Shiptheory request bodies and queries with ease.
- Dedicated methods to query each Shiptheory endpoint.
- Automatic token authentication. Just provide your credentials and the library will keep your tokens valid for as long as you need.
- Standardised error messaging.
- Configuration via .env

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

[](#installation)

Require with composer:

```
composer require dan-rogers/shiptheory-php

```

Configuration
-------------

[](#configuration)

The library currently utilises a .env file to configure certain aspects of the library.

IMPORTANT: It does not use any version of phpdotenv and instead uses its own custom implementation to keep it lightweight.

Copy values from `.env.example` into a new or existing .env file in the root of your project.

Currently supported configuration options:

- SHIPTHEORY\_PHP\_LOG\_REQUESTS - (Boolean) When set to `true` requests are logged. When `false` or nonexistent requests are not logged.
- SHIPTHEORY\_PHP\_SSL\_VERIFY\_PEER - (Boolean) When set to `true` SSL verification is enabled. When `false` or nonexistent requests do not use SSL verification.
- SHIPTHEORY\_PHP\_LOG\_PATH - (String) When a string is set it is used as the path to the folder where log files are generated.

Using a Shiptheory Partner Tag
------------------------------

[](#using-a-shiptheory-partner-tag)

*"If you are developing an application that will be used by more than 1 company, or an application that you intend to distribute in anyway, you must include the Shiptheory-Partner-Tag http request header in all of your requests. Please contact Shiptheory support to obtain a partner tag. There is no charge for this, tags are used to provide better support to customers and partners."* - API Docs

In order to add a partner tag to your API requests add it as the third argument when instantiating a new ShiptheoryClient.

```
$client = new ShiptheoryClient('test@test.com', 'Password123!', 'my_partner_tag');
```

Usage
-----

[](#usage)

The workflow is similar for all endpoints, queries and bookings. Examples exist in the file `Examples`. If you want to see all endpoint methods, then look in `src/Http/ShiptheoryClient.php`.

It is recommended that you use the objects provied to build your requests as they will result with a perfect request body every time. However, if you wish you can just provide the query parameters or the JSON body (depending on request type) as a string to the method you are calling.

Example of viewing a shipment
-----------------------------

[](#example-of-viewing-a-shipment)

```
$client = new ShiptheoryClient('test@test.com', 'Password123!');
$result = $client->viewShipment('Test1234')
```

Example of listing shipments
----------------------------

[](#example-of-listing-shipments)

```
$client = new ShiptheoryClient('test@test.com', 'Password123!');
$list_fields = [
    'channel_name' => 'Api',
    'status' => 'Ignored',
    'limit' => 1
];
$list_query = new ListShipmentQuery($list_fields);
$params = $list_query->toQueryParams();
$client->listShipment($params);
```

Example of searching for shipments
----------------------------------

[](#example-of-searching-for-shipments)

```
$client = new ShiptheoryClient('test@test.com', 'Password123!');
$search_fields = [
    'created_from' => '2022-04-01',
    'created_to' => '2022-04-30',
    'include_products' => 1,
];
$search_query = new SearchShipmentQuery($search_fields);
$params = $search_query->toQueryParams();
$client->searchShipment($params);
```

Example of booking a shipment
-----------------------------

[](#example-of-booking-a-shipment)

```
$client = new ShiptheoryClient('test@test.com', 'Password123!');
//Start new shipment data object
$shipment = new Shipment();
$shipment->setReference('Test1234');
$shipment->setReference2('Test5678');

// Set Shipment Details
$shipment_detail = new ShipmentDetail();
$shipment_detail->setWeight(1);
$shipment_detail->setParcels(1);
$shipment_detail->setValue(1);
$shipment_detail->setShippingPrice(2.99);
$shipment_detail->setReference3('ORDERREF3');
$shipment_detail->setSalesSource('My Store');
$shipment_detail->setShipDate('2022-04-30');
$shipment_detail->setCurrencyCode('GBP');

// Set Recipient
$reciever = new Recipient();
$reciever->setCompany('Shiptheory');
$reciever->setFirstname('Test');
$reciever->setLastname('Customer');
$reciever->setAddressLine1('Unit 4.1 Paintworks');
$reciever->setAddressLine2('Bath Road');
$reciever->setCity('Bristol');
$reciever->setCountry('GB');
$reciever->setPostcode('BS4 3EH');
$reciever->setEmail('recipient@test.com');
$reciever->setTelephone('01234567890');
$reciever->setWhat3Words('///what.three.words');
$eori = new TaxNumber('GB205672212000', AddressTaxNumberTypes::EORI);
$vat = new TaxNumber('GB123456789', AddressTaxNumberTypes::VAT);
$reciever->setTaxNumbers([$eori, $vat]);

// Set sender
$sender = new Sender();
$sender->setCompany('Shiptheory');
$sender->setFirstname('Test');
$sender->setLastname('Shipper');
$sender->setAddressLine1('Bristol Old Vic');
$sender->setAddressLine2('King Street');
$sender->setCity('Bristol');
$sender->setCountry('GB');
$sender->setPostcode('BS1 4ED');
$sender->setEmail('sender@test.com');
$sender->setTelephone('01234567890');

// Set Product
$product = new Product();
$product->setName('My Test Product');
$product->setSku('TestProd1');
$product->setQty(1);
$product->setValue(1);
$product->setWeight(1);
$product->setCommodityCode('8443991000');
$product->setCommodityManucountry('PL');

// Add all elements to the shipment
$shipment->setShipmentDetail($shipment_detail);
$shipment->setRecipient($reciever);
$shipment->setSender($sender);
$shipment->setProducts([$product]);

// Send shipment to Shiptheory
$data = $shipment->toJson(true);
$result = $client->bookShipment($data);
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~17 days

Total

17

Last Release

1255d ago

Major Versions

v0.2.0-alpha → v1.0.02022-05-01

v1.1.4 → v2.0.02022-09-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ed92a709dd5111eba2b72a41ea8834256d5cd575b8765404f1f0cd5499268d6?d=identicon)[DanRVP](/maintainers/DanRVP)

---

Top Contributors

[![DanRVP](https://avatars.githubusercontent.com/u/77623109?v=4)](https://github.com/DanRVP "DanRVP (83 commits)")

---

Tags

apiautoloadhelpernamespacephpshiptheoryshiptheory-api

### Embed Badge

![Health badge](/badges/dan-rogers-shiptheory-php/health.svg)

```
[![Health](https://phpackages.com/badges/dan-rogers-shiptheory-php/health.svg)](https://phpackages.com/packages/dan-rogers-shiptheory-php)
```

###  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)
