PHPackages                             vladimircatrici/shopify-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. vladimircatrici/shopify-api

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

vladimircatrici/shopify-api
===========================

Library to operate with Shopify data via REST API

v0.2.8(2y ago)02751[1 issues](https://github.com/VladimirCatrici/shopify-api/issues)[1 PRs](https://github.com/VladimirCatrici/shopify-api/pulls)proprietaryPHPPHP &gt;=7.1

Since Nov 4Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/VladimirCatrici/shopify-api)[ Packagist](https://packagist.org/packages/vladimircatrici/shopify-api)[ RSS](/packages/vladimircatrici-shopify-api/feed)WikiDiscussions master Synced today

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

Shopify API
===========

[](#shopify-api)

This is a simple PHP library that provides a quick and easy way to work with Shopify REST API. It uses Guzzle as HTTP client.

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

[](#installation)

```
composer require vladimircatrici/shopify
```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

```
require_once 'vendor/autoload.php';
use VladimirCatrici\Shopify;
Shopify\ClientManager::setConfig('default', [
    'domain' => 'your-shop-handle',
    'access_token' => 'your-access-token',
]);
$api = Shopify\ClientManager::get('default');
```

### Configuration

[](#configuration)

There are a few additional options you can pass to the ClientManager.

- `api_version` (default: `the oldest stable supported version`) The Shopify API version you want to use.
    Read more about [API versioning at Shopify](https://help.shopify.com/en/api/versioning).
- `max_attempts_on_server_errors` (default: `1`)
    Number of attempts trying to execute the request. It's useful because sometimes Shopify may respond with 500 error. I would recommend set this to `2` or `3`. The default value is `1` though.
- `max_attempts_on_rate_limit_errors` (default: `1`)
    Number of attempts trying to execute the request on getting `429 Too Many Connections` error. This might be useful if the same API key is used by other apps which may lead to exceeding the rate limit. The recommended value would be somewhere under the 10.
- `max_limit_rate` (default: `0.5`)
    Number between 0 and 1 describing the maximum limit rate the client should reach before going sleep. See `max_limit_rate_sleep_sec` option.
- `max_limit_rate_sleep_sec` (default: `1`)
    Number of seconds to sleep when API reaches the maximum API limit rate specified in `max_limit_rate` option.

### Basic usage

[](#basic-usage)

The client implements all 4 HTTP methods that Shopify REST API supports. Method names are:

- get(*string* $endpoint, *array* $options)
- post(*string* $endpoint, *array* $data)
- put(*string* $endpoint, *array* $data)
- delete(*string* $endpoint)

The `$endpoint` parameter must always be a string that represents a Shopify API endpoint. It should not contain the `/admin/api/#{api_version}/` part in the beginning. The `.json` is not necessary in the end of the path as well. For example if Shopify documentations shows the endpoint path as `GET /admin/api/#{api_version}/orders.json`, you can just use:

```
$api->get('orders');
```

See more examples below:

#### Get items

[](#get-items)

```
$numProducts = $api->get('products/count'); // int
$products = $api->get('products'); // array
foreach ($products as $product) {
  echo sprintf('#%d. %s',
    $product['id'], $product['title']);
}
```

#### Get `id` and `title` fields of 250 items from the 2nd page

[](#get-id-and-title-fields-of-250-items-from-the-2nd-page)

```
$products = $api->get('products', [
  'fields' => 'id,title',
  'limit' => 250,
  'page' => 2
]);
```

#### Get single item

[](#get-single-item)

```
$product = $api->get('products/123456789');
echo sprintf('#%d. %s', $product['id'], $product['title']);
```

#### Update item

[](#update-item)

```
$product = $api->put('products/123456789', [
    'title' => 'New title'
]);
echo sprintf('#%d. %s', $product['id'], $product['title']); // #1. New title
```

#### Create item

[](#create-item)

```
$product = $api->post('products', [
    'title' => 'New product'
]);
```

#### Delete item

[](#delete-item)

```
$api->delete('products/123456789');
if ($api->respCode == 200) {
    // Item has been successfully removed
}
```

Collection
----------

[](#collection)

You can use Collection object to get all the items from the specific endpoint. This library works fine with both page-based and cursor-based pagination and switches between them based on API version.

```
use VladimirCatrici\Shopify\ClientManager;
$api = ClientManager::get('default');
$products = new Collection($api, 'products');
foreach ($products as $product) {
    printf('#%d. %s [$%f],
        $product['id'], $product['title'], $product['price']
    );
}
```

Webhooks
--------

[](#webhooks)

You can use this library to listen for shop's webhooks.

```
use VladimirCatrici\Shopify;
if (Shopify\Webhook::validate('your-webhook-token')) {
    printf('`%s` webhook triggered on your store (%s). Data received: %s',
        Shopify\Webhook::getTopic(),
        Shopify\Webhook::getShopDomain(),
        Shopify\Webhook::getData()
    );
} else {
    // Invalid request | Unauthorized webhook | Data corrupted
}

// You can also get webhook data as array right away
$data = Shopify\Webhook::getDataAsArray();
printf('Product ID#%d, product title: %s',
    $data['id'], $data['title']
);
```

Troubleshooting
---------------

[](#troubleshooting)

```
use VladimirCatrici\Shopify\Exception\RequestException;
try {
    $products = $api->get('products');
} catch (RequestException $e) {
    $request = $e->getRequest(); // PSR-7/Request object

    $response = $e->getResponse(); // PSR-7/Response object
    $code = $response->getStatusCode(); // int
    $headers = $response->getHeaders(); // array
    $bodyStream = $response->getBody(); // Stream (PSR-7/StreamInterface)
    $bodyContent = (string) $response->getBody(); // string (or $body->__toString())

    // Details of the errors including exception message, request and response details
    echo $e->getDetailsJson();
}
```

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.3% 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 ~128 days

Recently: every ~367 days

Total

13

Last Release

842d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/736923fb26633c6a53346da0fafa718a68804d84faf664c910bbc34a584047f7?d=identicon)[Vladici](/maintainers/Vladici)

---

Top Contributors

[![VladimirCatrici](https://avatars.githubusercontent.com/u/2182381?v=4)](https://github.com/VladimirCatrici "VladimirCatrici (82 commits)")[![VladimirCyberDev](https://avatars.githubusercontent.com/u/87959398?v=4)](https://github.com/VladimirCyberDev "VladimirCyberDev (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

composerapirestpackageshopify

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vladimircatrici-shopify-api/health.svg)

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

###  Alternatives

[gnikyt/basic-shopify-api

A basic Shopify API wrapper with REST and GraphQL support, powered by Guzzle.

245514.8k5](/packages/gnikyt-basic-shopify-api)[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.3M14](/packages/xeroapi-xero-php-oauth2)[whatarmy/fedex-rest

New FedEx Rest API wrapper

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

Laravel package for the Wordpress JSON REST API

1310.3k](/packages/threesquared-laravel-wp-api)

PHPackages © 2026

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