PHPackages                             ktscript/fedex-rest - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. ktscript/fedex-rest

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ktscript/fedex-rest
===================

Fedex REST API project, adapted for php &gt;=7.2.5, Laravel 7-12+, guzzle&gt;=7

v1.2.5(2mo ago)214.2k↓45.5%1MITPHPPHP &gt;=7.2.5

Since Dec 31Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/ktscript/fedex_rest_api)[ Packagist](https://packagist.org/packages/ktscript/fedex-rest)[ RSS](/packages/ktscript-fedex-rest/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (11)Used By (0)

FedEx REST API
==============

[](#fedex-rest-api)

PHP package for integrating with FedEx REST API. This package provides a simple and intuitive interface for working with FedEx services including tracking, shipping, and address validation.

Features
--------

[](#features)

- 🚀 **Easy Integration** - Simple, fluent API for interacting with FedEx services
- 🔐 **OAuth 2.0 Support** - Built-in authorization handling
- 📦 **Shipping Labels** - Create shipping labels and track packages
- 📍 **Address Validation** - Validate addresses using FedEx API
- 📌 **Location Search** - Find FedEx pickup/dropoff locations by address, coordinates, or phone
- 🔄 **Environment Switching** - Switch between sandbox and production environments easily
- 🎯 **Laravel Compatible** - Works seamlessly with Laravel 7-12+ using Conditionable trait
- 🔧 **Fluent Interface** - Chainable methods for building requests

Requirements
------------

[](#requirements)

- PHP &gt;= 7.2.5
- Laravel 7-12+ (or illuminate/support package)
- Guzzle HTTP Client ^6|^7
- JSON extension

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

[](#installation)

Install the package via Composer:

```
composer require ktscript/fedex-rest
```

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

[](#configuration)

### Getting FedEx API Credentials

[](#getting-fedex-api-credentials)

1. Register for a FedEx Developer account at [FedEx Developer Portal](https://developer.fedex.com/)
2. Create a new application to get your `client_id` and `client_secret`
3. Choose between sandbox (testing) or production environment

Usage
-----

[](#usage)

### Authorization

[](#authorization)

First, you need to obtain an access token using your FedEx credentials:

```
use FedexRest\Authorization\Authorize;

$authorize = new Authorize();
$authorize->setClientId('your_client_id')
    ->setClientSecret('your_client_secret')
    ->useProduction() // Use production environment (optional, defaults to sandbox)
    ->authorize();

$token = $authorize->access_token;
```

### Tracking Packages

[](#tracking-packages)

Track one or multiple packages by tracking number:

```
use FedexRest\Services\Track\TrackByTrackingNumberRequest;

$tracking = new TrackByTrackingNumberRequest();
$tracking->setAccessToken($token)
    ->setTrackingNumber('1234567890') // Single tracking number
    ->includeDetailedScans() // Optional: include detailed scan information
    ->useProduction() // Optional: use production environment
    ->request();

// Or track multiple packages
$tracking->setTrackingNumber(['1234567890', '0987654321'])
    ->request();
```

### Creating Shipping Labels

[](#creating-shipping-labels)

Create shipping labels for packages:

```
use FedexRest\Services\Ship\CreateTagRequest;
use FedexRest\Entity\Person;
use FedexRest\Entity\Address;
use FedexRest\Entity\Item;
use FedexRest\Entity\Weight;
use FedexRest\Services\Ship\Type\ServiceType;
use FedexRest\Services\Ship\Type\PackagingType;
use FedexRest\Services\Ship\Type\PickupType;

// Create shipper address
$shipperAddress = new Address();
$shipperAddress->setStreetLines('123 Main St')
    ->setCity('Memphis')
    ->setStateOrProvince('TN')
    ->setPostalCode('38116')
    ->setCountryCode('US');

// Create shipper
$shipper = new Person();
$shipper->setPersonName('John Doe')
    ->setPhoneNumber(1234567890)
    ->withAddress($shipperAddress);

// Create recipient address
$recipientAddress = new Address();
$recipientAddress->setStreetLines('456 Oak Ave')
    ->setCity('Los Angeles')
    ->setStateOrProvince('CA')
    ->setPostalCode('90001')
    ->setCountryCode('US');

// Create recipient
$recipient = new Person();
$recipient->setPersonName('Jane Smith')
    ->setPhoneNumber(9876543210)
    ->withAddress($recipientAddress);

// Create item weight
$weight = new Weight();
$weight->setUnit('LB')
    ->setValue(5);

// Create item
$item = new Item();
$item->setItemDescription('Sample Product')
    ->setWeight($weight);

// Create shipping label
$shipment = new CreateTagRequest();
$shipment->setAccessToken($token)
    ->setAccountNumber(123456789)
    ->setShipper($shipper)
    ->setRecipients($recipient)
    ->setLineItems($item)
    ->setServiceType(ServiceType::_FEDEX_GROUND)
    ->setPackagingType(PackagingType::_FEDEX_BOX)
    ->setPickupType(PickupType::_USE_SCHEDULED_PICKUP)
    ->setShipDatestamp('2024-01-15')
    ->useProduction() // Optional: use production environment
    ->request();
```

### Address Validation

[](#address-validation)

Validate addresses using FedEx address validation service:

```
use FedexRest\Services\AddressValidation\AddressValidation;
use FedexRest\Entity\Address;

$address = new Address();
$address->setStreetLines('123 Main St')
    ->setCity('Memphis')
    ->setStateOrProvince('TN')
    ->setPostalCode('38116')
    ->setCountryCode('US');

$validation = new AddressValidation();
$validation->setAccessToken($token)
    ->setAddress($address)
    ->useProduction() // Optional: use production environment
    ->request();
```

### Location Search (FedEx Location API)

[](#location-search-fedex-location-api)

Search for FedEx pickup and dropoff locations by address, coordinates, or phone:

```
use FedexRest\Services\Location\LocationSearchRequest;
use FedexRest\Services\Location\Type\LocationType;
use FedexRest\Entity\Address;

// Search by address
$address = new Address();
$address->setStreetLines('123 Main St')
    ->setCity('Memphis')
    ->setStateOrProvince('TN')
    ->setPostalCode('38116')
    ->setCountryCode('US');

$locationSearch = new LocationSearchRequest();
$result = $locationSearch->setAccessToken($token)
    ->setAddress($address)
    ->setDistance(10, LocationSearchRequest::UNITS_KM)
    ->setLocationTypes([LocationType::FEDEX_OFFICE, LocationType::FEDEX_SELF_SERVICE_LOCATION])
    ->setResultsLimit(15)
    ->useProduction()
    ->request();

// Or search by coordinates
$result = $locationSearch->setAccessToken($token)
    ->setCoordinates(35.1495, -90.0490)
    ->setDistance(5, LocationSearchRequest::UNITS_MI)
    ->request();

// Or search by phone number
$result = $locationSearch->setAccessToken($token)
    ->setPhoneNumber('9015551234')
    ->request();
```

The response is a decoded object. Main keys:

- `output.totalResults`, `output.resultsReturned` — count of locations
- `output.locationDetailList` — array of locations (each has `distance`, `contactAndAddress` with `address`/`contact`/`displayName`, `locationId`, `storeHours`, `carrierDetailList`, `locationType`, `locationCapabilities`, etc.)
- `output.nearestLocation`, `output.latestLocation` — single location objects when applicable
- `output.matchedAddress` — normalized search address
- `output.alerts` — optional messages

### Environment Switching

[](#environment-switching)

The package supports easy switching between sandbox (testing) and production environments:

```
// Use sandbox (default)
$request->request();

// Use production
$request->useProduction()->request();

// Using Laravel's Conditionable trait (when available)
$request->when($isProduction, fn($req) => $req->useProduction())
    ->request();
```

### Raw Response

[](#raw-response)

Get raw HTTP response instead of decoded JSON:

```
$response = $request->asRaw()->request();
// Returns GuzzleHttp\Psr7\Response object
```

Available Service Types
-----------------------

[](#available-service-types)

Use constants from `FedexRest\Services\Ship\Type\ServiceType`:

- `ServiceType::_FEDEX_GROUND`
- `ServiceType::_FEDEX_2_DAY`
- `ServiceType::_STANDARD_OVERNIGHT`
- `ServiceType::_PRIORITY_OVERNIGHT`
- `ServiceType::_INTERNATIONAL_PRIORITY`
- And many more...

Available Packaging Types
-------------------------

[](#available-packaging-types)

Use constants from `FedexRest\Services\Ship\Type\PackagingType`:

- `PackagingType::_YOUR_PACKAGING`
- `PackagingType::_FEDEX_BOX`
- `PackagingType::_FEDEX_ENVELOPE`
- `PackagingType::_FEDEX_PAK`
- And more...

Available Pickup Types
----------------------

[](#available-pickup-types)

Use constants from `FedexRest\Services\Ship\Type\PickupType`:

- `PickupType::_USE_SCHEDULED_PICKUP`
- `PickupType::_DROPOFF_AT_FEDEX_LOCATION`
- `PickupType::_CONTACT_FEDEX_TO_SCHEDULE`

Exception Handling
------------------

[](#exception-handling)

The package throws specific exceptions for missing required data:

- `MissingAccessTokenException` - When access token is not provided
- `MissingAuthCredentialsException` - When client credentials are missing
- `MissingTrackingNumberException` - When tracking number is not provided
- `MissingAccountNumberException` - When account number is missing
- `MissingLineItemException` - When line items are not provided

```
use FedexRest\Exceptions\MissingAccessTokenException;

try {
    $response = $request->request();
} catch (MissingAccessTokenException $e) {
    // Handle missing access token
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Request Parameters

[](#custom-request-parameters)

For shipping labels, you can customize request parameters:

```
$shipment = new CreateTagRequest();
$params = $shipment->getRequestParams();
// Modify $params array as needed
$shipment->setRequestParams($params)
    ->setAccessToken($token)
    ->request();
```

Laravel Integration
-------------------

[](#laravel-integration)

This package works seamlessly with Laravel 7-12+. The `switchableEnv` trait uses Laravel's `Conditionable` trait, allowing you to use the `when()` method:

```
use FedexRest\Services\Track\TrackByTrackingNumberRequest;

$tracking = new TrackByTrackingNumberRequest();
$tracking->setAccessToken($token)
    ->setTrackingNumber('1234567890')
    ->when(config('app.env') === 'production', fn($req) => $req->useProduction())
    ->request();
```

Support
-------

[](#support)

For issues, questions, or contributions, please visit:

- [GitHub Issues](https://github.com/ktscript/fedex_rest_api/issues)
- [Telegram: @ktscript](https://t.me/ktscript) — contact the author

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Credits
-------

[](#credits)

Special thanks to [Sinnbeck](http://github.com/Sinnbeck) for the help and contributions.

Changelog
---------

[](#changelog)

### 1.2.1-1.2.5

[](#121-125)

- Fix Location API
- Add `LocationType` constants
- Add `LocationSearchRequest`
- Add `LocationSearchResponse`
- Add `LocationSearchResponseItem`

### 1.2.0

[](#120)

- FedEx Location API: search pickup/dropoff locations by address, coordinates, or phone
- `LocationSearchRequest` and `LocationType` constants
- Support contact: Telegram [@ktscript](https://t.me/ktscript) added to README and composer.json

### 1.0.0

[](#100)

- Initial stable release
- Support for Laravel 7-12+
- OAuth 2.0 authorization
- Package tracking
- Shipping label creation
- Address validation
- Environment switching (sandbox/production)
- Fluent interface with method chaining

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance83

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

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

Recently: every ~0 days

Total

10

Last Release

85d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.0

v1.1.0PHP &gt;=7.2.5

### Community

Maintainers

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

---

Top Contributors

[![ktscript](https://avatars.githubusercontent.com/u/63599041?v=4)](https://github.com/ktscript "ktscript (18 commits)")

---

Tags

apirestshippingFedEx

### Embed Badge

![Health badge](/badges/ktscript-fedex-rest/health.svg)

```
[![Health](https://phpackages.com/badges/ktscript-fedex-rest/health.svg)](https://phpackages.com/packages/ktscript-fedex-rest)
```

###  Alternatives

[whatarmy/fedex-rest

New FedEx Rest API wrapper

2440.5k1](/packages/whatarmy-fedex-rest)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[onesignal/onesignal-php-api

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

34170.2k2](/packages/onesignal-onesignal-php-api)[ivanmitrikeski/laravel-shipping

Shipping package for Laravel. Supported providers: CanadaPost, USPS, UPS, FedEx and Purolator.

206.8k2](/packages/ivanmitrikeski-laravel-shipping)[ory/hydra-client

Documentation for all of Ory Hydra's APIs.

17435.9k](/packages/ory-hydra-client)[dreamfactory/df-core

DreamFactory(tm) Core Components

1651.7k20](/packages/dreamfactory-df-core)

PHPackages © 2026

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