Download the PHP package gnikyt/basic-shopify-api without Composer

On this page you can find all versions of the php package gnikyt/basic-shopify-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package basic-shopify-api

Basic Shopify API

Tests codecov License

A simple, tested, API wrapper for Shopify using Guzzle.

It supports both the sync/async REST and GraphQL API provided by Shopify, basic rate limiting, and request retries.

It contains helpful methods for generating a installation URL, an authorize URL (offline and per-user), HMAC signature validation, call limits, and API requests.

It works with both OAuth and private API apps.

Table of Contents

Installation

The recommended way to install is through composer.

composer require gnikyt/basic-shopify-api

Usage

Public API

This assumes you properly have your app setup in the partner's dashboard with the correct keys and redirect URIs.

REST (sync)

For REST calls, the shop domain and access token are required.

REST (async)

For REST calls, the shop domain and access token are required.

GraphQL (sync)

For GraphQL calls, the shop domain and access token are required.

GraphQL (async)

For GraphQL calls, the shop domain and access token are required.

Getting access (offline)

This is the default mode which returns a permanent token.

After obtaining the user's shop domain, to then direct them to the auth screen use getAuthUrl, as example (basic PHP):

Getting access (per-user)

You can also change the grant mode to be per-user as outlined in Shopify documentation. This will receieve user info from the user of the app within the Shopify store. The token recieved will expire at a specific time.

Verifying HMAC signature

Simply pass in an array of GET params.

Private API

This assumes you properly have your app setup in the partner's dashboard with the correct keys and redirect URIs.

REST

For REST (sync) calls, shop domain, API key, and API password are request

GraphQL

For GraphQL calls, shop domain and API password are required.

Making requests

REST

Requests are made using Guzzle.

You can use the alias restAsync to skip setting sync to false.

If sync is true (regular rest call):

The return value for the request will be an array containing:

Note: request() will alias to rest() as well.

If sync is false (restAsync call):

The return value for the request will be a Guzzle promise which you can handle on your own.

The return value for the promise will be an object containing:

Overriding request type

If you require the need to force a query string for example on a non-GET endpoint, you can specify the type as a key.

Valid keys are query and json.

Passing additional request options

If you'd like to pass additional request options to the Guzzle client created, pass them as the second argument of the constructor.

GraphQL

Requests are made using Guzzle.

The return value for the request will be an object containing:

Example query:

Example mutation:

API Versioning

This library supports versioning the requests, example:

You can override the versioning at anytime for specific API requests, example:

Rate limiting

This library comes with a built-in basic rate limiter which utilizes usleep between applicable calls.

To adjust the default limits, use the option class' setRestLimit and setGraphLimit.

Custom rate limiting

You simply need to disable the built-in rate limiter and push in a custom Guzzle middleware. Example:

page_info / pagination support

2019-07 API version introduced a new Link header which is used for pagination (explained here).

If an endpoint supports page_info, you can use $response->link to grab the page_info value to pass in your next request.

Example:

Isolated API calls

You can initialize the API once and use it for multiple shops. Each instance will be contained to not pollute the others. This is useful for something like background job processing.

$this will be binded to the closure. Example:

Retries

This library utilizes caseyamcl/guzzle_retry_middleware middleware package.

By default, 429, 500 and 503 errors will be retried twice.

For REST calls, it will utilize Shopify's X-Retry-After header to wait x seconds before retrying the call.

When all retries are exhasted, the standard response from the library will return where you can handle the error.

To change the status codes watched or the maximum number of retries, use the option class' setGuzzleOptions:

Errors

This library internally catches only 400-500 status range errors through Guzzle. You're able to check for an error of this type and get its response status code and body.

Middleware

This library takes advantage of using Guzzle middleware for request/response checks and modifications. You're also able to inject middleware.

See Guzzle's documentation on middleware. As well, you can browse this library's middleware for examples.

Storage

For storing the current request times, API limits, request costs, etc. A basic in-memory array store is used Gnikyt\BasicShopifyAPI\Store\Memory.

If you would like to implement a more advananced store such as one with Redis, simply implement Gnikyt\BasicShopifyAPI\Contracts\StateStorage and set the client to use it, example:

Documentation

Code documentation is available here from phpDocumentor via phpdoc -d src -t doc.

LICENSE

This project is released under the MIT license.

Misc

Using Python? Check out basic_shopify_api.


All versions of basic-shopify-api with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3.0
ext-json Version *
caseyamcl/guzzle_retry_middleware Version ^2.3
guzzlehttp/guzzle Version ^6.5 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gnikyt/basic-shopify-api contains the following files

Loading the files please wait ....