omnibus / fedex
Omnibus FedEx: rate quotes, labels, tracking and locations - the REST APIs with OAuth2.
Requires
- php: >=8.2
- omnisense/contracts: ^1.0
- omnisense/omnibus: ^2.0
- symfony/http-client: ^6.4|^7.0|^8.0
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
FedEx for omnisense/omnibus: rate quotes (Rate API), shipments and labels (Ship API), tracking (Track API) and drop-off locations (Location API) - the REST APIs with OAuth2 client credentials.
Install and a first call
composer require omnibus/fedex
No account for this first call: FedEx's answer is recorded (Omnibus\Testing\RecordedHttpClient
answers in place of the API), so nothing leaves the process. With your own credentials, give the
factory your HTTP client (or none: it makes its own) and drop the recorded one.
<?php require __DIR__.'/vendor/autoload.php'; use Omnibus\Fedex\FedexGatewayFactory; use Omnibus\Testing\RecordedHttpClient; // FedEx's answer, recorded: no account, and nothing leaves the process. $http = new RecordedHttpClient([ 'POST /oauth/token' => ['access_token' => 'tok', 'expires_in' => 3599], '/track/v1/trackingnumbers' => ['output' => ['completeTrackResults' => [['trackResults' => [['latestStatusDetail' => ['code' => 'IT', 'description' => 'In transit'], 'scanEvents' => [ ['date' => '2026-10-02T08:00:00+02:00', 'eventType' => 'IT', 'eventDescription' => 'In transit', 'scanLocation' => ['city' => 'ROISSY', 'countryCode' => 'FR']], ]]]]]]], ]); $gateway = (new FedexGatewayFactory($http))->create(['client_id' => 'id', 'client_secret' => 'secret', 'account_number' => '510087', 'sandbox' => true]); $tracking = $gateway->track('794644790000'); echo $tracking->status->value, ' - ', $tracking->latest()?->description, "\n"; // in_transit - In transit
A real call needs a FedEx account (the credentials below). The answer is shaped after FedEx's published documentation; the package has not been run against its service yet.
Configuration
$gateway = (new FedexGatewayFactory($http))->create($options); // $http: the application's HTTP client - none given, the factory makes its own; the options below
No framework needed: the package requires omnisense/omnibus and symfony/http-client. In a
Symfony application, the same through the bundle's configuration:
omnibus: gateways: fedex: factory: fedex options: client_id: '%env(FEDEX_CLIENT_ID)%' client_secret: '%env(FEDEX_CLIENT_SECRET)%' account_number: '%env(FEDEX_ACCOUNT)%' sandbox: true rates: [...] # optional: configured prices instead of the Rate API
Shipment options: label_format (PDF, PNG, ZPLII), pickup_type (DROPOFF_AT_FEDEX_LOCATION,
CONTACT_FEDEX_TO_SCHEDULE, USE_SCHEDULED_PICKUP). The service is FedEx's code (FEDEX_INTERNATIONAL_PRIORITY,
INTERNATIONAL_ECONOMY, FEDEX_GROUND...).
Credentials: a project in the FedEx Developer Portal with the Rate, Ship, Track and Location APIs, its client id and secret (test and production are separate), and your FedEx account number.
Built from FedEx's published API documentation and tested on recorded answers; not yet run against the sandbox: that needs the credentials above.
Responsibility
This package is an independent, unofficial client: it is not affiliated with, endorsed by or sponsored by FedEx Corporation. It reaches their service on behalf of whoever runs it, and it does not redistribute their data beyond the short excerpts recorded as test fixtures. Its MIT licence covers this package's code only and grants no right to the service or to its data.
Whoever installs and runs this package is responsible for complying with FedEx's terms (FedEx Developer Portal licence agreement), for obtaining whatever they require (an account, a key, a licence or subscription, an attribution or a citation, a rate limit to respect), and for any use made of what it returns. The authors publish it free of charge, make no commercial use of it, and accept no liability for how it is used (see LICENSE).
License: MIT since 2026-10-09; earlier versions remain published under LGPL-3.0-or-later.