PHPackages                             fulfillment/api-wrapper - 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. fulfillment/api-wrapper

ActiveLibrary[API Development](/categories/api)

fulfillment/api-wrapper
=======================

A barebones wrapper for the FDC api to facailitate easier authentication and communication

0.2.0(5y ago)022.8k1[1 PRs](https://github.com/Fulfillment-dot-com/api-wrapper-php/pulls)2MITPHP

Since Aug 22Pushed 9mo ago5 watchersCompare

[ Source](https://github.com/Fulfillment-dot-com/api-wrapper-php)[ Packagist](https://packagist.org/packages/fulfillment/api-wrapper)[ RSS](/packages/fulfillment-api-wrapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (11)Used By (2)

api-wrapper-php
===============

[](#api-wrapper-php)

A barebones wrapper to ease authentication and low-level communication with FDC API

Example
-------

[](#example)

```
use Fulfillment\Api\Api;

$data = [
    'endpoint' => $endPoint,
    'clientId' => $clientId,
    'clientSecret' => $clientSecret,
    'accessToken' => $accessToken,
    'username' => $username,
    'password' => $password
];

$apiClient = new Api($data);

$newPostageClient = [
    'email' => 'some@email.com',
    'clientId' => 2
];

$returnedUser = $apiClient->post('users', $newPostageClient); //POST request with body as json

$apiClient->get('users', ['clientId' => '2']); //GET request with query string ?clientId=2
```

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

[](#installation)

```
composer require fulfillment/api-wrapper

```

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

[](#configuration)

### Authentication Configuration

[](#authentication-configuration)

Minimum requirements for auth -- you must have:

- client id
- client secret
- username
- password
- scope -- To use provide multiple scopes pass each scope delimited by a space EX `oms postage`

**AND/OR**

- access token

Note that if the access token expires re-authentication cannot occur if credentials are not present.

Auth can be parsed using several options:

**Array**

```
$data = [
    'endpoint'     => $endPoint,
    'clientId'     => $clientId,
    'clientSecret' => $clientSecret,
    'accessToken'  => $accessToken,
    'username'     => $username,
    'password'     => $password,
    'scope'        => 'oms'
];

$apiClient = new Api($config)
```

**DotEnv**

Use a `.env` file compatible with [phpdotenv](https://github.com/vlucas/phpdotenv) library. Simply specify the absolute path to the folder containing your `.env` file as an argument in the constructor.

```
$fileLocation = __DIR__ . DIRECTORY_SEPARATOR . '.env';

$apiClient = new Api($fileLocation);
```

**Environmental Variables**

Use environmental variables (available in `$_ENV`)

- **USERNAME**
- **PASSWORD**
- **CLIENT\_ID**
- **CLIENT\_SECRET**
- **ACCESS\_TOKEN**
- **API\_ENDPOINT**
- **SCOPE**

```
$apiClient = new Api();
```

**NOTE:** If an access token is generated the package will store a copy of the token either at `__DIR__ . /logs` or the location returned by `storage_path('logs/')`

### Logging Configuration

[](#logging-configuration)

The package defaults to console output or file if STDOUT is not available. You may use your own logger by passing an object that implements [`League\CLImate\Util\Writer\WriterInterface`](http://climate.thephpleague.com/output/)

```
$apiClient = new Api($config, $logger);
```

### Guzzle Configuration

[](#guzzle-configuration)

You may use your own `guzzle` instance by passing it into the constructor

```
$apiClient = new Api($config, $logger, $guzzle)
```

If no instance is passed a new one is created.

Usage
-----

[](#usage)

If credentials are provided the client can(will) authenticate itself if an access token is not present or invalid.

Basic requests are by using HTTP verbs methods:

- **get($url, $queryString = null)**
- **post($url, $body, $queryString = null)**
- **patch($url, $body, $queryString = null)**
- **delete($url, $queryString = null)**

```
$apiClient->get($url, $queryString);
$apiClient->post($url, $body, $queryString);
$apiClient->patch($url, $body, $queryString);
$apiClient->delete($url, $queryString);
```

- **$url** is the relative url from the endpoint, it is concatenated before the request is sent -- `$fullURl = $endPoint . '/' . $url;`
- **$body** is an array or object that can be jsonified.
- **$queryString** is represented as a key/value array -- `$queryString = ['myKey' => 'myValue']` is equivalent to `http://endpoint/url?myKey=myValue`

### Helpers

[](#helpers)

Two functions are available to make response parsing more convenient:

**parseError**

This function will json decode `RequestException` thrown by Guzzle and return the error object used by FDC as a standard object.

```
RequestParser::parseError($r)
```

**getErrorCode**

This will do the same as above will be only return an error code if one is present on the error.

```
RequestParser::getErrorCode($r)
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance40

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.6% 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 ~801 days

Total

3

Last Release

1952d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e034a2b4c63a810f72067441ec19dce7d9993a7fad0f1b27dd5734a4a2ad8070?d=identicon)[FoxxMD](/maintainers/FoxxMD)

![](https://www.gravatar.com/avatar/2263993374fa87b36ce7376802b73d5fd26d7a420ffc61bcf9049e7692526004?d=identicon)[Fulfillment.com](/maintainers/Fulfillment.com)

---

Top Contributors

[![FoxxMD](https://avatars.githubusercontent.com/u/4663766?v=4)](https://github.com/FoxxMD "FoxxMD (43 commits)")[![MikeGarde](https://avatars.githubusercontent.com/u/1537877?v=4)](https://github.com/MikeGarde "MikeGarde (2 commits)")

### Embed Badge

![Health badge](/badges/fulfillment-api-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/fulfillment-api-wrapper/health.svg)](https://phpackages.com/packages/fulfillment-api-wrapper)
```

###  Alternatives

[netflie/whatsapp-cloud-api

The first PHP SDK to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform

640431.7k4](/packages/netflie-whatsapp-cloud-api)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[hardcastle/xrpl_php

PHP SDK / Client for the XRP Ledger

129.7k5](/packages/hardcastle-xrpl-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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