PHPackages                             jrebs/easyship-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. jrebs/easyship-php

ActiveLibrary[API Development](/categories/api)

jrebs/easyship-php
==================

A PHP library to simplify integration with the Easyship API

v1.4(5y ago)259721MITPHPPHP &gt;=7.2

Since Apr 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/jrebs/easyship-php)[ Packagist](https://packagist.org/packages/jrebs/easyship-php)[ RSS](/packages/jrebs-easyship-php/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (1)

easyship-php
============

[](#easyship-php)

[![codecov](https://camo.githubusercontent.com/5f3553be9077c5a4c348898fc4bab35bd4e7abfbae0292b364e468060931aad1/68747470733a2f2f636f6465636f762e696f2f67682f6a726562732f65617379736869702d7068702f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4f4b354841504a31595a)](https://codecov.io/gh/jrebs/easyship-php)[![License](https://camo.githubusercontent.com/8ba10ffdd1eafee9d5f210e910d11850196587cdd610d544ba90d9dd8efa762c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a726562732f65617379736869702d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jrebs/easyship-php)

A PHP library to make PHP calls to the [Easyship](https://www.easyship.com)API. This library wraps some of the repetitive/ugly work like creating an HTTP client, building and sending requests. The end user will just need to assemble arrays of the appropriate payload data and then evaluate the responses.

This package comprises two distinct sets of functionality. The first is the API communication component, which allows the user to easily write code for sending outbound API calls to the Easyship API. The second is support for receiving inbound webhook posts from Easyship, allowing the user to easily pass those calls into a dispatching handler and have their payloads passed off to custom code attached to the handler using listeners. Webhooks are an optional feature of Easyship's API and there's you can completely ignore them if it's not part of your implementation plan.

#### API Version

[](#api-version)

Until `v1.4`, this library only supported the Easyship API `v1`. `v2` was never supported because for the longest time it was incomplete and marked unstable. Since `v1.4` of this library, `v2023-01` is the only supported version. You can just install an earlier build if you need to use old calls for some reason.

- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Webhooks](#webhooks)
- [Roadmap](#roadmap)
- [Support](#support)
- [License](#license)

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

[](#installation)

Unless using [Laravel](https://laravel.com), install with [composer](https://getcomposer.org) like normal:

```
composer require jrebs/easyship-php
```

If using the library in a [Laravel](https://laravel.com) application, then you'll probably find it more convenient to install the companion package, [easyship-laravel](https://github.com/jrebs/easyship-laravel) (which will also require this package as a dependency).

In this case, instead run:

```
composer require jrebs/easyship-laravel
```

See the [easyship-laravel](https://github.com/jrebs/easyship-laravel) page for documentation specific to this method.

Usage
=====

[](#usage)

```
// Create the EasyshipAPI object
$token = getenv('EASYSHIP_TOKEN');
$api = new Easyship\EasyshipAPI($token);

// Get a list of categories
$response = $api->categories()->list();

// Get a shipment
$response = $api->shipments()->get('ESTEST10001');

// Buy a label for a shipment
$response = $api->labels()->request(['easyship_shipment_id' => 'ESTEST10001']);
```

All methods return an instance of an object implementing `Psr\Http\Message\ResponseInterface`, typically `GuzzleHttp\Psr7\Response`, which can be used as needed [see the Guzzle documentation for more](https://docs.guzzlephp.org/en/stable/quickstart.html#using-responses).

By default, all of the calls are made using the request option `'http_errors' => true`, which means that exceptions will be thrown if any requests fail. The `EasyshipAPI::request()` method docblock shows which exceptions you can expect to be thrown. The library allows all exceptions to bubble up to the application so that the developer can choose how to handle them at implementation. You can override this option in the options array passed into the `EasyshipAPI` constructor, if you prefer.

```
/**
 * @throws \GuzzleHttp\Exception\ConnectException on network error
 * @throws \GuzzleHttp\Exception\ClientException on 400-level errors
 * @throws \GuzzleHttp\Exception\ServerException on 500-level errors
 */
```

Of course, if you're using another PSR7-compatible client, then you'll presumably get some exception based on `\RuntimeException`. Using other clients isn't fully tested but in theory should work.

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

[](#configuration)

Typically the only thing you need is to configure an api key, which you'll get from your easyship account interface. If you haven't made one yet, go to  and look for `API Integration` near the bottom of the list.

For each integration you create, there will be two access tokens created, one that starts with `prod_` and one that starts with `sand_`. The latter is your sandbox key and is the one you should use for testing and developing your integrations. It uses the same live endpoints but works off a separate set of test-only data.

The apiToken on the EasyshipAPI is optional, as a single customer may often be making api calls with different tokens.

#### Providing Request Options to the HTTP client

[](#providing-request-options-to-the-http-client)

The `EasyshipAPI` constructor accepts an array of request options that will be merged into the options that are passed to the HTTP client when requests are sent to the API endpoints. See the [guzzle request options](https://docs.guzzlephp.org/en/stable/request-options.html) documentation for possibilities.

```
// Pass custom options that will be used by the client
$api = new Easyship\EasyshipAPI($token, [
    'verify' => false, // don't verify ssl certificate
    'connect_timeout' => 30, // wait maximum 30 seconds before giving up
]);
```

#### Overriding the API host

[](#overriding-the-api-host)

For testing/development you may want to override the target host so that the calls you submit will be sent to your own server for inspection.

```
// Force all the calls from this API object to a localhost server
$api->setApiHost('http://localhost:8080/');
```

Webhooks
--------

[](#webhooks)

See [WEBHOOKS.md](WEBHOOKS.md).

Roadmap
-------

[](#roadmap)

- More complete/useful testing.

Support
-------

[](#support)

If you're getting unexpected results from your API calls, the most likely case is that your payload is not valid and you'll want to consult the [Easyship reference docs](https://developers.easyship.com/v1.0/reference). Note that you can plug values into the forms on that page, including your sandbox token, and run the tests from the interface. If you find an issue where the exact same call is working in Easyship's test page but failing with this library, please raise an issue with a very detailed explanation of the problem and include a copy of the exact code being run (at least the payload of test data being passed in) so that the issue can be easily reproduced. Please also include a copy of the incorrect response you're getting back.

License
-------

[](#license)

This software was written by me, [Justin Rebelo](https://github.com/jrebs), and is released under the [MIT license](LICENSE.md).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

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 ~3 days

Total

5

Last Release

1832d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7be6aa129cd8860ec177bd2820612c277dd9a80c904a8e814c46fdccdca2e6fa?d=identicon)[jrebs](/maintainers/jrebs)

---

Top Contributors

[![jrebs](https://avatars.githubusercontent.com/u/4203789?v=4)](https://github.com/jrebs "jrebs (20 commits)")

---

Tags

phpapieasyship

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jrebs-easyship-php/health.svg)

```
[![Health](https://phpackages.com/badges/jrebs-easyship-php/health.svg)](https://phpackages.com/packages/jrebs-easyship-php)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

762.6k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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