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

On this page you can find all versions of the php package seka19/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

Build Status Coverage Status StyleCI License

A simple, tested, API wrapper for Shopify using Guzzle. It supports both the REST and GraphQL API provided by Shopify, and basic rate limiting abilities. 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.

Also supported: asynchronous requests through Guzzle's promises.

This library required PHP >= 7.

Table of Contents

Installation

The recommended way to install is through composer.

$ composer require ohmybrew/basic-shopify-api

Usage

Add use OhMyBrew\BasicShopifyAPI; to your imports.

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

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 object 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:

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:

Checking API limits

After each request is made, the API call limits are updated. To access them, simply use:

For GraphQL, additionally there will be the following values: restoreRate, requestedCost, actualCost.

To quickly get a value, you may pass an optional parameter to the getApiCalls method:

Rate Limiting

This library comes with a built-in basic rate limiter, disabled by default. It will sleep for x microseconds to ensure you do not go over the limit for calls with Shopify. On non-Plus plans, you get 1 call every 500ms (2 calls a second), for Plus plans you get 2 calls every 500ms (4 calls a second).

By default the cycle is set to 500ms, with a buffer for safety of 100ms added on.

Enable Rate Limiting

Setup your API instance as normal, with an added:

This will turn on rate limiting with the default 500ms cycle and 100ms buffer. To change this, do the following:

This will set the cycle to 250ms and 0ms buffer.

Disabiling Rate Limiting

If you've previously enabled it, you simply need to run:

Checking Rate Limiting Status

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:

Getting Timestamps

The library will track timestamps from the previous and current (last) call. To see information on this:

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 current API. Example:

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.

Logging

This library accepts a PSR-compatible logger.

Documentation

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

LICENSE

This project is released under the MIT license.


All versions of basic-shopify-api with dependencies

PHP Build Version
Package Version
No informations.
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 seka19/basic-shopify-api contains the following files

Loading the files please wait ....