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

ActiveProject[API Development](/categories/api)

dan/shopify
===========

Shopify API with Laravel integrations using latest Guzzle.

v5.0.0(3y ago)2325.6k9[1 issues](https://github.com/danrichards/shopify/issues)MITPHPPHP &gt;=8.0

Since Jul 19Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/danrichards/shopify)[ Packagist](https://packagist.org/packages/dan/shopify)[ RSS](/packages/dan-shopify/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (9)Dependencies (5)Versions (65)Used By (0)

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

[](#shopify-api)

A fluent and object-oriented approach for using the Shopify API.

Supported Objects / Endpoints:
------------------------------

[](#supported-objects--endpoints)

- [Asset](https://help.shopify.com/en/api/reference/online-store/asset)
- [Customer](https://help.shopify.com/en/api/reference/customers/customer)
- [Dispute](https://help.shopify.com/en/api/reference/shopify_payments/dispute)
- [Fulfillment](https://help.shopify.com/en/api/reference/shipping-and-fulfillment/fulfillment)
- [FulfillmentService](https://help.shopify.com/en/api/reference/shipping-and-fulfillment/fulfillmentservice)
- [Image](https://help.shopify.com/en/api/reference/products/product-image)
- [Metafield](https://shopify.dev/docs/admin-api/rest/reference/metafield?api)
- [Order](https://help.shopify.com/api/reference/orders)
- [Product](https://help.shopify.com/api/reference/products)
- [Risk](https://help.shopify.com/en/api/reference/orders/order-risk)
- [Shop](https://shopify.dev/docs/admin-api/rest/reference/store-properties/shop)
- [Theme](https://help.shopify.com/en/api/reference/online-store/theme)
- [Variant](https://help.shopify.com/en/api/reference/products/product-variant)
- [Webhook](https://help.shopify.com/en/api/reference/events/webhook)

Versions
--------

[](#versions)

PHPPackage85.0.\*74.0.\*YOLOdev-masterComposer
--------

[](#composer)

```
composer require dan/shopify
```

Basic Usage
-----------

[](#basic-usage)

The APIs all function alike, here is an example of usage of the products API.

```
$api = Dan\Shopify\Shopify::make($shop = 'shop-name.myshopify.com', $token = 'shpua_abc123');

// Shop information
$api->shop(); // array dictionary

// List of products
$api->products->get(); // array of array dictionaries

// Attach query parameters to a get request
$api->products->get(['created_at_min' => '2023-03-25']); // array of array dictionaries

// A specific product
$api->products('123456789')->get(); // array dictionary

// Get all variants for a product
$api->products('123456789')->variants->get(); // array of array dictionaries

// Get a specific variant for a specific product
$s->api2()->products('123456789')->variants('567891234')->get(); // array dictionary

// Append URI string to a get request
$api->orders('123456789')->get([], 'risks'); // array dictionary

// Create a product.
// See https://shopify.dev/docs/api/admin-rest/2023-01/resources/product#post-products
$api->products->post(['title' => 'Simple Test']); // array dictionary

// Update something specific on a product
$api->products('123456789')->put(['title' => 'My title changed.']); // array dictionary
```

Basic (very basic) GraphQL
--------------------------

[](#basic-very-basic-graphql)

The collection and model utilities that are available `->find(...)` and `->findMany(...)` for RESTful endpoints are NOT available for GraphQL.

Some endpoints are only available through Shopify's GraphQL library. This makes me sad because GraphQL is not as readable or intuitive as RESTful APIs, less people understand it, and it's harder to train people on. That said, if you want to jam out with your graphql, there is a client method to assist you.

For example, fetch delivery profiles (only available in GraphQL).

> Note: You can safely use the `graphql(...)` helper method without any concern of changing the state on the `Dan\Shopify\Shopify::class`.

```
$query = "{
  deliveryProfiles (first: 3) {
    edges {
      node {
        id,
        name,
      }
    }
  }
}"

$api->graphql($query); // hipster
```

Using cursors
-------------

[](#using-cursors)

> Shopify doesn't jam with regular old pagination, sigh ...

As of the `2019-10` API version, Shopify has removed per page pagination on their busiest endpoints.
With the deprecation of the per page pagination comes a new cursor based pagination.
You can use the `next` method to get paged responses.
Example usage:

```
// First call to next can have all the usual query params you might want.
$api->orders->next(['limit' => 100, 'status' => 'closed');

// Further calls will have all query params preset except for limit.
$api->orders->next(['limit' => 100]);
```

### Metafields!

[](#metafields)

There are multiple endpoints in the Shopify API that have support for metafields.
In effort to support them all, this API has been updated to allow chaining `->metafields` from any endpoint.

This won't always work as not every endpoint supports metafields, and any endpoint that doesn't support metafields will result in a `404`.

Below are examples of all the endpoints that support metafields.

```
// Get our API
$api = Dan\Shopify\Shopify::make($shop, $token);

// Store metafields
$api->metafields->get();

// Metafields on an Order
$api->orders($order_id)->metafields->get();

// Metafields on a Product
$api->products($product_id)->metafields->get();

// Metafields on a Variant
$api->products($product_id)->variants($variant_id)->metafields->get();

// Metafields on a Customer
$api->customers($customer_id)->metafields->get();

// Metafields can also be updated like all other endpoints
$api->products($product_id)->metafields($metafield_id)->put($data);
```

Usage with Laravel
------------------

[](#usage-with-laravel)

### Single Store App

[](#single-store-app)

In your `config/app.php`

### Add the following to your `providers` array:

[](#add-the-following-to-your-providers-array)

Requires for private app (env token) for single store usage of oauth (multiple stores)

```
Dan\Shopify\Integrations\Laravel\ShopifyServiceProvider::class,
```

### Add the following to your `aliases` array:

[](#add-the-following-to-your-aliases-array)

If your app only interacts with a single store, there is a Facade that may come in handy.

```
'Shopify' => Dan\Shopify\Integrations\Laravel\ShopifyFacade::class,
```

### For facade usage, replace the following variables in your `.env`

[](#for-facade-usage-replace-the-following-variables-in-your-env)

```
SHOPIFY_DOMAIN=your-shop-name.myshopify.com
SHOPIFY_TOKEN=your-token-here
```

### Optionally replace following variables in your `.env`

[](#optionally-replace-following-variables-in-your-env)

Empty or `admin` defaults to oldest supported API, [learn more](https://help.shopify.com/en/api/versioning)

```
SHOPIFY_API_BASE="admin/api/2022-07"
```

### Using the Facade gives you `Dan\Shopify\Shopify`

[](#using-the-facade-gives-you-danshopifyshopify)

> It will be instantiated with your shop and token you set up in `config/shopify.php`

Review the `Basic Usage` above, using the Facade is more or less the same, except you're only interacting with the one store in your config.

```
// Facade same as $api->shop(), but for just the one store.
Shopify::shop();

// Facade same as $api->products->get(), but for just the one store.
Shopify::products()->get();

// Facade same as $api->products('123456789')->get(), but for just the one store.
Shopify::products('123456789')->get();
```

Oauth Apps
----------

[](#oauth-apps)

Making a public app using oauth, follow the Shopify docs to make your auth url, and use the following helper to retrieve your access token using the code from your callback.

### Get a token for a redirect response.

[](#get-a-token-for-a-redirect-response)

```
Shopify::getAppInstallResponse(
    'your_app_client_id',
    'your_app_client_secret',
    'shop_from_request',
    'code_from_request'
);

// returns (object) ['access_token' => '...', 'scopes' => '...']
```

### Verify App Hmac (works for callback or redirect)

[](#verify-app-hmac-works-for-callback-or-redirect)

```
Dan\Shopify\Util::validAppHmac(
    'hmac_from_request',
    'your_app_client_secret',
    ['shop' => '...', 'timestamp' => '...', ...]
);
```

### Verify App Webhook Hmac

[](#verify-app-webhook-hmac)

```
Dan\Shopify\Util::validWebhookHmac(
    'hmac_from_request',
    'your_app_client_secret',
    file_get_contents('php://input')
);
```

Contributors
------------

[](#contributors)

- [Diogo Gomes](https://github.com/diogogomeswww)
- [Hiram Cruz](https://github.com/forgiv)

Todo
----

[](#todo)

- Artisan Command to create token

License
-------

[](#license)

MIT.

###  Health Score

52

↑

FairBetter than 96% of packages

Maintenance59

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

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

Recently: every ~10 days

Total

60

Last Release

1147d ago

Major Versions

v1.0.0.11 → v2.0.02018-03-02

v2.9.8 → v3.0.02021-03-26

v3.0.2 → v4.0.02022-08-11

v4.0.8 → v5.0.02023-03-25

PHP version history (5 changes)v1.0.0.0PHP &gt;=5.6.4

v4.0.0PHP &gt;=7.0

v4.0.2PHP &gt;=7.1

v4.0.8PHP ^7.1|^7.2|^7.3|^7.4

v5.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/219?v=4)[Dan Benjamin](/maintainers/dan)[@dan](https://github.com/dan)

---

Top Contributors

[![diogogomeswww](https://avatars.githubusercontent.com/u/11543163?v=4)](https://github.com/diogogomeswww "diogogomeswww (66 commits)")[![danrichards](https://avatars.githubusercontent.com/u/470255?v=4)](https://github.com/danrichards "danrichards (60 commits)")[![forgiv](https://avatars.githubusercontent.com/u/49741676?v=4)](https://github.com/forgiv "forgiv (14 commits)")[![erikgall](https://avatars.githubusercontent.com/u/8866568?v=4)](https://github.com/erikgall "erikgall (7 commits)")[![colepizzarella](https://avatars.githubusercontent.com/u/10200684?v=4)](https://github.com/colepizzarella "colepizzarella (1 commits)")[![squatto](https://avatars.githubusercontent.com/u/748444?v=4)](https://github.com/squatto "squatto (1 commits)")

---

Tags

apilaravelwebhooksshopify

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[dan/shopify-api

Shopify API for PHP

218.1k](/packages/dan-shopify-api)

PHPackages © 2026

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