PHPackages                             y0lk/bigcommerce-api - 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. y0lk/bigcommerce-api

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

y0lk/bigcommerce-api
====================

Enables PHP applications to communicate with the Bigcommerce API.

3.3.2(4y ago)0570MITPHPPHP &gt;=7.0

Since Feb 9Pushed 4y agoCompare

[ Source](https://github.com/Y0lk/bigcommerce-api-php)[ Packagist](https://packagist.org/packages/y0lk/bigcommerce-api)[ RSS](/packages/y0lk-bigcommerce-api/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (5)Versions (36)Used By (0)

Bigcommerce API Client
======================

[](#bigcommerce-api-client)

DISCLAIMER
----------

[](#disclaimer)

This is a fork of the official Bigcommerce PHP SDK. This fork was created because the official repo has been unsupported since 2018, and some minor updates were required to keep it working. I have no real plans to keep updating this package other than fixing issues with it. Feel free to contribute and raise issues, I will certainly look at them. I've published this on packagist under a different name to keep usage simple.

This library only supports the Bigcommerce V2 API, so this fork is only useful if you already have a Bigcommerce implementation an are looking for a quick solution to the few issues the official library has, such as the incompatibility with PSR-4 standard.

For new projects, you should use the Bigcommerce V3 API instead, and there happens to be a great unofficial PHP library for it that is well supported:

Description
-----------

[](#description)

PHP client for connecting to the Bigcommerce V2 REST API.

To find out more, visit the official documentation website:

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

[](#requirements)

- PHP 7.0 or greater
- cUrl extension enabled

To generate an OAuth API token, [follow this guide.](https://support.bigcommerce.com/s/article/Store-API-Accounts)

**To connect to the API with OAuth you will need the following:**

- client\_id
- auth\_token
- store\_hash

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

[](#installation)

Use the following Composer command to install the API client from [the Bigcommerce vendor on Packagist](https://packagist.org/packages/y0lk/bigcommerce-api):

```
 $ composer require y0lk/bigcommerce-api
 $ composer update
```

You can also install composer for your specific project by running the following in the library folder.

```
 $ curl -sS https://getcomposer.org/installer | php
 $ php composer.phar install
 $ composer install
```

Namespace
---------

[](#namespace)

All the examples below assume the `Bigcommerce\Api\Client` class is imported into the scope with the following namespace declaration:

```
use Bigcommerce\Api\Client as Bigcommerce;
```

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

[](#configuration)

To use the API client in your PHP code, ensure that you can access `Bigcommerce\Api`in your autoload path (using Composer’s `vendor/autoload.php` hook is recommended).

Provide your credentials to the static configuration hook to prepare the API client for connecting to a store on the Bigcommerce platform:

### OAuth

[](#oauth)

In order to obtain the auth\_token you would consume `Bigcommerce::getAuthToken` method during an installation of a single-click app. Alternatively, if you already have a token, skip to `Bigcommerce::configure` and provide your credentials.

```
$object = new \stdClass();
$object->client_id = 'xxxxxx';
$object->client_secret = 'xxxxx';
$object->redirect_uri = 'https://app.com/redirect';
$object->code = $request->get('code');
$object->context = $request->get('context');
$object->scope = $request->get('scope');

$authTokenResponse = Bigcommerce::getAuthToken($object);

Bigcommerce::configure(array(
    'client_id' => 'xxxxxxxx',
    'auth_token' => $authTokenResponse->access_token,
    'store_hash' => 'xxxxxxx'
));
```

### Basic Auth (deprecated)

[](#basic-auth-deprecated)

```
Bigcommerce::configure(array(
	'store_url' => 'https://store.mybigcommerce.com',
	'username'	=> 'admin',
	'api_key'	=> 'd81aada4xc34xx3e18f0xxxx7f36ca'
));
```

Connecting to the store
-----------------------

[](#connecting-to-the-store)

To test that your configuration was correct and you can successfully connect to the store, ping the getTime method which will return a DateTime object representing the current timestamp of the store if successful or false if unsuccessful:

```
$ping = Bigcommerce::getTime();

if ($ping) echo $ping->format('H:i:s');
```

Accessing collections and resources (GET)
-----------------------------------------

[](#accessing-collections-and-resources-get)

To list all the resources in a collection:

```
$products = Bigcommerce::getProducts();

foreach ($products as $product) {
	echo $product->name;
	echo $product->price;
}
```

To access a single resource and its connected sub-resources:

```
$product = Bigcommerce::getProduct(11);

echo $product->name;
echo $product->price;
```

To view the total count of resources in a collection:

```
$count = Bigcommerce::getProductsCount();

echo $count;
```

Paging and Filtering
--------------------

[](#paging-and-filtering)

All the default collection methods support paging, by passing the page number to the method as an integer:

```
$products = Bigcommerce::getProducts(3);
```

If you require more specific numbering and paging, you can explicitly specify a limit parameter:

```
$filter = array("page" => 3, "limit" => 30);

$products = Bigcommerce::getProducts($filter);
```

To filter a collection, you can also pass parameters to filter by as key-value pairs:

```
$filter = array("is_featured" => true);

$featured = Bigcommerce::getProducts($filter);
```

See the API documentation for each resource for a list of supported filter parameters.

Updating existing resources (PUT)
---------------------------------

[](#updating-existing-resources-put)

To update a single resource:

```
$product = Bigcommerce::getProduct(11);

$product->name = "MacBook Air";
$product->price = 99.95;
$product->update();
```

You can also update a resource by passing an array or stdClass object of fields you want to change to the global update method:

```
$fields = array(
	"name"  => "MacBook Air",
	"price" => 999.95
);

Bigcommerce::updateProduct(11, $fields);
```

Creating new resources (POST)
-----------------------------

[](#creating-new-resources-post)

Some resources support creation of new items by posting to the collection. This can be done by passing an array or stdClass object representing the new resource to the global create method:

```
$fields = array(
	"name" => "Apple"
);

Bigcommerce::createBrand($fields);
```

You can also create a resource by making a new instance of the resource class and calling the create method once you have set the fields you want to save:

```
$brand = new Bigcommerce\Api\Resources\Brand();

$brand->name = "Apple";
$brand->create();
```

Deleting resources and collections (DELETE)
-------------------------------------------

[](#deleting-resources-and-collections-delete)

To delete a single resource you can call the delete method on the resource object:

```
$category = Bigcommerce::getCategory(22);
$category->delete();
```

You can also delete resources by calling the global wrapper method:

```
Bigcommerce::deleteCategory(22);
```

Some resources support deletion of the entire collection. You can use the deleteAll methods to do this:

```
Bigcommerce::deleteAllOptionSets();
```

Using The XML API
-----------------

[](#using-the-xml-api)

By default, the API client handles requests and responses by converting between JSON strings and their PHP object representations. If you need to work with XML you can switch the API into XML mode with the useXml method:

```
Bigcommerce::useXml();
```

This will configure the API client to use XML for all subsequent requests. Note that the client does not convert XML to PHP objects. In XML mode, all object parameters to API create and update methods must be passed as strings containing valid XML, and all responses from collection and resource methods (including the ping, and count methods) will return XML strings instead of PHP objects. An example transaction using XML would look like:

```
Bigcommerce::useXml();

$xml = "

		 	Apple
		 	computers laptops
		";

$result = Bigcommerce::createBrand($xml);
```

Handling Errors And Timeouts
----------------------------

[](#handling-errors-and-timeouts)

For whatever reason, the HTTP requests at the heart of the API may not always succeed.

Every method will return false if an error occurred, and you should always check for this before acting on the results of the method call.

In some cases, you may also need to check the reason why the request failed. This would most often be when you tried to save some data that did not validate correctly.

```
$orders = Bigcommerce::getOrders();

if (!$orders) {
	$error = Bigcommerce::getLastError();
	echo $error->code;
	echo $error->message;
}
```

Returning false on errors, and using error objects to provide context is good for writing quick scripts but is not the most robust solution for larger and more long-term applications.

An alternative approach to error handling is to configure the API client to throw exceptions when errors occur. Bear in mind, that if you do this, you will need to catch and handle the exception in code yourself. The exception throwing behavior of the client is controlled using the failOnError method:

```
Bigcommerce::failOnError();

try {
	$orders = Bigcommerce::getOrders();

} catch(Bigcommerce\Api\Error $error) {
	echo $error->getCode();
	echo $error->getMessage();
}
```

The exceptions thrown are subclasses of Error, representing client errors and server errors. The API documentation for response codes contains a list of all the possible error conditions the client may encounter.

Verifying SSL certificates
--------------------------

[](#verifying-ssl-certificates)

By default, the client will attempt to verify the SSL certificate used by the Bigcommerce store. In cases where this is undesirable, or where an unsigned certificate is being used, you can turn off this behavior using the verifyPeer switch, which will disable certificate checking on all subsequent requests:

```
Bigcommerce::verifyPeer(false);
```

Connecting through a proxy server
---------------------------------

[](#connecting-through-a-proxy-server)

In cases where you need to connect to the API through a proxy server, you may need to configure the client to recognize this. Provide the URL of the proxy server and (optionally) a port to the useProxy method:

```
Bigcommerce::useProxy("http://proxy.example.com", 81);
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~360 days

Total

34

Last Release

1536d ago

Major Versions

2.0.7 → 3.x-dev2014-06-06

PHP version history (2 changes)2.0.0PHP &gt;=5.3.0

3.1.1PHP &gt;=7.0

### Community

Maintainers

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

---

Top Contributors

[![maetl](https://avatars.githubusercontent.com/u/24809?v=4)](https://github.com/maetl "maetl (97 commits)")[![aleachjr](https://avatars.githubusercontent.com/u/3844269?v=4)](https://github.com/aleachjr "aleachjr (38 commits)")[![bookernath](https://avatars.githubusercontent.com/u/8922457?v=4)](https://github.com/bookernath "bookernath (23 commits)")[![saranyan](https://avatars.githubusercontent.com/u/607071?v=4)](https://github.com/saranyan "saranyan (17 commits)")[![Lewiscowles1986](https://avatars.githubusercontent.com/u/2605791?v=4)](https://github.com/Lewiscowles1986 "Lewiscowles1986 (12 commits)")[![bc-bfenton](https://avatars.githubusercontent.com/u/11280604?v=4)](https://github.com/bc-bfenton "bc-bfenton (11 commits)")[![zvuki](https://avatars.githubusercontent.com/u/381924?v=4)](https://github.com/zvuki "zvuki (8 commits)")[![kubawerlos](https://avatars.githubusercontent.com/u/9282069?v=4)](https://github.com/kubawerlos "kubawerlos (6 commits)")[![bc-ruth](https://avatars.githubusercontent.com/u/9205109?v=4)](https://github.com/bc-ruth "bc-ruth (6 commits)")[![lord2800](https://avatars.githubusercontent.com/u/715922?v=4)](https://github.com/lord2800 "lord2800 (5 commits)")[![two16D](https://avatars.githubusercontent.com/u/33282148?v=4)](https://github.com/two16D "two16D (5 commits)")[![watermark](https://avatars.githubusercontent.com/u/1056975?v=4)](https://github.com/watermark "watermark (4 commits)")[![mattolson](https://avatars.githubusercontent.com/u/168657?v=4)](https://github.com/mattolson "mattolson (3 commits)")[![Gemorroj](https://avatars.githubusercontent.com/u/885731?v=4)](https://github.com/Gemorroj "Gemorroj (3 commits)")[![msznaper](https://avatars.githubusercontent.com/u/18124153?v=4)](https://github.com/msznaper "msznaper (3 commits)")[![PascalZajac](https://avatars.githubusercontent.com/u/813373?v=4)](https://github.com/PascalZajac "PascalZajac (3 commits)")[![zackkatz](https://avatars.githubusercontent.com/u/870979?v=4)](https://github.com/zackkatz "zackkatz (3 commits)")[![SebastianSzturo](https://avatars.githubusercontent.com/u/2699745?v=4)](https://github.com/SebastianSzturo "SebastianSzturo (2 commits)")[![splittingred](https://avatars.githubusercontent.com/u/233334?v=4)](https://github.com/splittingred "splittingred (2 commits)")[![BVMiko](https://avatars.githubusercontent.com/u/873521?v=4)](https://github.com/BVMiko "BVMiko (2 commits)")

---

Tags

httpapirestbusinessecommerce

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/y0lk-bigcommerce-api/health.svg)

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

###  Alternatives

[bigcommerce/api

Enables PHP applications to communicate with the Bigcommerce API.

1501.1M8](/packages/bigcommerce-api)[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.2M267](/packages/nategood-httpful)[quickbooks/payments-sdk

The Official PHP SDK for QuickBooks Online Payments API

2758.2k2](/packages/quickbooks-payments-sdk)[jsor/hal-client

A lightweight client for consuming and manipulating Hypertext Application Language (HAL) resources.

2425.9k1](/packages/jsor-hal-client)[highsidelabs/walmart-api

A PHP client for Walmart's Marketplace, 1P Supplier, and Content Provider APIs.

308.0k](/packages/highsidelabs-walmart-api)

PHPackages © 2026

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