PHPackages                             foxycart/foxyclient - 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. foxycart/foxyclient

ActiveLibrary[API Development](/categories/api)

foxycart/foxyclient
===================

FoxyClient - a PHP Guzzle based API Client for working with the Foxy Hypermedia API

2.0.1(9y ago)843.5k11[1 issues](https://github.com/FoxyCart/foxyclient-php/issues)[2 PRs](https://github.com/FoxyCart/foxyclient-php/pulls)1MITPHPPHP &gt;=5.5

Since May 24Pushed 3y ago7 watchersCompare

[ Source](https://github.com/FoxyCart/foxyclient-php)[ Packagist](https://packagist.org/packages/foxycart/foxyclient)[ Docs](https://github.com/FoxyCart/foxyclient-php)[ RSS](/packages/foxycart-foxyclient/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (2)Versions (13)Used By (1)

FoxyClient PHP
==============

[](#foxyclient-php)

FoxyClient - a PHP Guzzle based API Client for working with the Foxy Hypermedia API

Please see [the Foxy Hypermedia API documentation](https://api.foxycart.com/docs) for more information.

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

[](#installation)

The best way to get started with FoxyClient is to run the [foxyclient-php-example](https://github.com/FoxyCart/foxyclient-php-example) code.

Once you're familiar with how it works, you can add it as a composer package to your application as the example code does or via Packagist:

- Install Composer

`curl -sS https://getcomposer.org/installer | php`

- Add to your project

`php composer.phar require foxycart/foxyclient:~1.0`

If you need Guzzle 6 instead of Guzzle 5, use:

`php composer.phar require foxycart/foxyclient:~2.0`

Usage
-----

[](#usage)

As mentioned above, begin by getting familiar with [the example code](https://github.com/FoxyCart/foxyclient-php-example). The [bootstrap.php file](https://github.com/FoxyCart/foxyclient-php-example/blob/master/bootstrap.php) in particular is useful for configuring FoxyClient within your application. Please note how it takes advantage of HTTP caching and CSRF protection which are important for the performance and security of your application.

FoxyClient supports all HTTP methods for our Hypermedia API. It also automatically handles OAuth token refreshes and handles authorization code grants. It does not specify a persistance layer for storing OAuth tokens so you can implement that however you want. You can also support a static service with no database which would only use the client\_id, client\_secret, and refresh\_token to obtain a new access\_token as needed.

Tests
-----

[](#tests)

For Behat tests, please see the [the example code](https://github.com/FoxyCart/foxyclient-php-example/blob/master/features/).

### Config Options

[](#config-options)

- use\_sandbox: Set to true to work with . This is highly recomended when first getting familiar with the system (defaults to false).
- client\_id: Your OAuth Client id.
- client\_secret: Your OAuth Client Secret.
- access\_token: Your OAuth Acccess Token.
- access\_token\_expires: A timestamp for when the access\_token needs to be refreshed. If you happen to already have a stored token, you can set this here. It will be maintained via time() + expires\_in.
- refresh\_token: OAuth Refresh Token.
- handle\_exceptions: Defaults to true. Set to false to let Guzzle exceptions bubble up to your application so you can handle them directly.
- api\_home: Used internally for Foxy testing.
- authorization\_endpoint: Used internally for Foxy testing.

### HTTP methods

[](#http-methods)

- get($uri, $post = null)
- post($uri, $post = null)
- patch($uri, $post = null)
- put($uri, $post = null)
- delete($uri, $post = null)
- options($uri, $post = null)
- head($uri, $post = null)

### API Methods

[](#api-methods)

- updateFromConfig($config): Update configuration options via an array
- clearCredentials(): Clear all credentials so you can connect to the API with no OAuth
- getLink($link\_rel\_string): Used to get the href of a given link relationship such as "self" or "fx:store". It also supports the short version of just "store".
- getLinks(): Returns an array of link relationships the client has seen so far in the rel =&gt; href format. Each request stores the links in the links array.
- clearLinks(): Clear saved links from previous API calls. Helpful for link relationships like "checkout\_types" which can be returned from both a store resource and as a property helper.
- setAccessToken($access\_token) / getAccessToken(): OAuth access token
- setAccessTokenExpires($access\_token\_expires) / getAccessTokenExpires(): OAuth expiration times
- setRefreshToken($refresh\_token) / getRefreshToken(): OAuth refresh token
- setClientId($client\_id) / getClientId(): OAuth client id
- setClientSecret($client\_secret) / getClientSecret(): OAuth client secret
- setUseSandbox($use\_sandbox) / getUseSandbox(): boolean for connecting to the API sandbox
- getApiHome(): the API starting homepage
- getErrors($data): Given a response payload, it will normalize errors and return an array of them (or any empty array).
- getLastStatusCode(): Returns the last HTTP status code.
- getLastResponseHeader($header): Get a header (such as "Location") from the previous response.
- setAcceptContentType($accept\_content\_type): Set the Accept header content type used for the all future requests. All supported json content types on the FoxyCart API are supported such as application/hal+json and application/vnd.siren+json.
- getAcceptContentType(): get the Accept header content type
- getAuthorizationEndpoint(): The [Authorization Code Grant](https://tools.ietf.org/html/rfc6749#section-4.1) server endpoint url. You'll need to forward users to this to let them grant your application access to their store or user.
- getOAuthTokenEndpoint(): The OAuth token endpoint. Note: you shouldn't have to use this as the library takes care of all OAuth functionality for you.
- getAccessTokenFromAuthorizationCode($code): Used when returning from our Authorization server in order to obtain an access\_token and refresh\_token.
- getAccessTokenFromClientCredentials(): If we don't have a refresh token, we can use this method to obtain an access\_token using just the client credentials.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 95.2% 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 ~320 days

Recently: every ~522 days

Total

9

Last Release

1127d ago

Major Versions

1.0.0 → 2.02017-03-20

1.0.1 → 2.0.12017-04-07

2.0.1 → 3.0-beta.22017-09-12

PHP version history (3 changes)1.0.0PHP &gt;=5.3.3

2.0PHP &gt;=5.5

3.0-betaPHP ^7.2.5 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/97fb70c6145d319cc4fbfe9688d5470582fab0c1abe3e08553830eb85122e7df?d=identicon)[lukestokes](/maintainers/lukestokes)

---

Top Contributors

[![lukestokes](https://avatars.githubusercontent.com/u/344748?v=4)](https://github.com/lukestokes "lukestokes (40 commits)")[![jedau](https://avatars.githubusercontent.com/u/4092668?v=4)](https://github.com/jedau "jedau (1 commits)")[![samifiaz](https://avatars.githubusercontent.com/u/4672587?v=4)](https://github.com/samifiaz "samifiaz (1 commits)")

---

Tags

hypermediafoxyFoxycart

### Embed Badge

![Health badge](/badges/foxycart-foxyclient/health.svg)

```
[![Health](https://phpackages.com/badges/foxycart-foxyclient/health.svg)](https://phpackages.com/packages/foxycart-foxyclient)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1943.1k5](/packages/aimeos-prisma)

PHPackages © 2026

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