Retrieve list of shopify product through API in PHP

Retrieve list of shopify product through API in PHP

If you are new to using the shopify API, you have landed to the right place. This will be a series of posts that explains the implementation of different shopify API in PHP and this post specifically describes retrieving the list of shopify product through the API in PHP.

Pre-requisite:

  • You need to enable curl (if it not enabled by default). To check if curl is enabled or not simply execute below script:

Now search for curl. If it is enabled you will see the enabled status.

  •      To make a read/write request on any shopify store through API you need the access to do so. So the first step of accessing the shopify store data is to create the <b>private app</b> that provide you with the API keys and access token using which you can do shopify API request.
  1. From your shopify admin , go to Apps.
  2. Click Manage private apps.
  3. Click Create a new private app.
  4. In the App details section, enter a name for your private app and a contact email address. …
  5. In the Admin API section, select the areas of your store that you want the app to be able to access.
    Here you need to note the webhook API version, this will be used for API access (This is the recent feature added by shopify. If you want to learn more about this check out here )private_app_creation
  6. Save the App.

Now you will see API Key and password as shown on screenshot below. You will use these keys to do the API call to shopify

api_credentials

After these basic configuration,we are ready to to code.

Below code show the API request to retrieve the product list

In above code replace the value of the variable $SHOPIFY_APP_API_KEY , $SHOPIFY_APP_PASSWORD and $SHOPIFY_SHOP .

The requestUrl contains the webhook API version that you noted earlier.

Other is the basic curl request and as a response shopify returns list of shopify product on variable $json_data.