Shopify using REST API

Tags:

Updated:

6 minute read

Application configuration is an integral activity prior to the process of integration. If your chosen application is Shopify, credentials need to be provided for validating the agent. Here you will find the detailed description on how to configure the agents for the application Shopify, Troubleshooting issues, the attributes and its action.

Shopify is a complete ecommerce platform that lets you start, grow, and manage a business. The adapter of the application Shopify provides the leverage to communicate and adapt with the AEC portal. This section provides you the detailed process of validating the credential of the application Shopify.

Pre-requisites for Shopify Configuration

  1. Create an account in Shopify and Login into it.
  2. Username and Password to access the application.
  3. Click here to know the endpoints of the application.

Creation of Private APP

Steps for Creating Private APP and API KEY

  1. Login to your Shopify Application.
  2. On the Admin Panel, follow the path Settings -> Apps and sales channels -> Develop apps -> Create an app -> . Provide the App name and developer email in the specified text box. Click on Create app.
  3. Newly created app will be displayed along with the app user email and its creation date. Follow the path Configuration -> Admin API integration. Check in all the check-box and click on Save.
  4. Move to API credentials and click on install. Your Access token, API Key and API Secret key will be generated.

On-Premise Agent Configuration

Installation of On-Premise Agent

You need to install the agent on your local server. To Know about On-Premise Agent Configuration, Click here.

Configure the Shopify Application in the Agent

  1. Create a processflow with Shopify as source or destination application, and deploy the processflow in On-Premise agent.
  2. Open the agent and click the checkbox in Settings Panel.
  3. Move into the App Configurational Panel of the agent and configure the details of the respective application.

Steps to Configure Shopify Credential in OP Agent

  1. In the App Configuration panel of the agent, click on the + button, beside the app Shopify.
    shopify_1
  2. On clicking the + button, the credential panel opens for the application Shopify.
    shopify_2
  3. Provide the Base URL, API Key and API Password in the ageent.
  4. After providing the credentials, click on Validate button. After the validating the credentials successfully, click on SAVE.
    shopify_3

Following this process, the Shopify application can be configured in the OP agent.

Note :

  • As per the latest versioning of Shopify API, for validating the Base URL for your Shopify store in APPSeCONNECT Agent, users/implementers need to add admin/api/2019-10/ as the suffix to the URL .
  • This update is available from the On-Premise Agent version 4.4.10.0 & above.
  • The adapter version for the Shopify adapter should be 4.2.2.2.

Cloud Agent Configuration

Configuring the Shopify Application in Cloud Agent

  1. Login to APPSeCONNECT portal with valid credentials.

  2. Navigate to Manage > App. Expand the Shopify application and click on Credential.

  3. Expand the REST node, click on Add New Credential.

  4. Provide the necessary information Credential Name, Base URL, API Key and API Password. Secret Key is an optioanl field.
    shopify_cloud

  5. Click on Save and a toaster message will be displayed confirming the same.

Troubleshooting

Some of the basic troubleshooting issues happens due to improper validations or even if it is accurately validated, the processflow do not sync data properly. This basic issue resolves after removing the Temp and Cache files from the portal and from your system. Therefore after clearing all this, you need to deploy and excute the processflow again to perform the required business integration in a smooth and free-flowing way. For E.g. If the Source Application not Found , remove the Temp and Cache Files. Again re-deploy and execute the processflow.

Attributes and Actions

While defining a connection to a particular API endpoint in Shopify, you require clear understanding about the data requirements and endpoint configurations. You can refer to this document to find all the endpoint details of your shopify installation. To define the endpoint in APPSeCONNECT you need to define Actions and Entities. Actions are specifically targetted for a particular endpoint while schema is the data needed to execute the API. Here are the list of some of the prepackaged API actions defined for you which you can easily plug and play while doing your integrations.

Endpoint Action Action Type Schema UI Help API Help
Variants Variants Update PUT Variants Updating Variants in Shopify Variant Update
Transaction Payment Upload POST Transaction Uploading payments to Shopify Payment Add
Order Add Order POST Order Adding Sales Order in Shopify Order Add
Customer customers.xml GET customer Fetching customers from Shopify Customer Add
Order orders.xml GET order Fetching Sales orders from Shopify Order Add

Protip : Customers and Orders can be created and placed from the Front-End also. For Placing orders from front end, visit the E-Commerce store and follow the generic steps for placing orders and creating customers, this one.

Action Filter Implementation

Data is fetched from source application using APIs, and as you are aware of, API provides filters which will allow you to specify a subset of data from the whole bunch of data created in the server, the same can be specified through Actions and Action filters. The Action generally defines the endpoint of the application which is being fetched, while the filters define the search criteria of the data. You can add these parameters in the action filter to define the search criteria.

  • General filters : It represents the overall filter criteria of the API. To define such filters, you do not need to specify anything special, just putting the field name and the value with the condition type is fine.

Let us consider any API of shopify such as customer, the request structure will look like :

{
  "customers": [
    {
      "id": 207119551,
      "email": "bob.norman@mail.example.com",
      "accepts_marketing": false,
      "created_at": "2022-05-26T15:47:46-04:00",
      "updated_at": "2022-05-26T15:47:46-04:00",
      "first_name": "Bob",
      "last_name": "Norman",
      "orders_count": 1,
      "state": "disabled",
      "total_spent": "199.65",
      "last_order_id": 450789469,
      "note": null,
      "verified_email": true,
      "multipass_identifier": null,
      "tax_exempt": false,
      "phone": "+16136120707",
      "tags": "",
      "last_order_name": "#1001",
      "currency": "USD",
      "addresses": [
        {
          "id": 207119551,
          "customer_id": 207119551,
          "first_name": null,
          "last_name": null,
          "company": null,
          "address1": "Chestnut Street 92",
          "address2": "",
          "city": "Louisville",
          "province": "Kentucky",
          "country": "United States",
          "zip": "40202",
          "phone": "555-625-1199",
          "name": "",
          "province_code": "KY",
          "country_code": "US",
          "country_name": "United States",
          "default": true
        }
      ],
      "accepts_marketing_updated_at": "2005-06-12T11:57:11-04:00",
      "marketing_opt_in_level": null,
      "tax_exemptions": [],
      "admin_graphql_api_id": "gid://shopify/Customer/207119551",
      "default_address": {
        "id": 207119551,
        "customer_id": 207119551,
        "first_name": null,
        "last_name": null,
        "company": null,
        "address1": "Chestnut Street 92",
        "address2": "",
        "city": "Louisville",
        "province": "Kentucky",
        "country": "United States",
        "zip": "40202",
        "phone": "555-625-1199",
        "name": "",
        "province_code": "KY",
        "country_code": "US",
        "country_name": "United States",
        "default": true
      }
    }
  ]
}

Since shopify is an ecommerce application, there can be huge number of customers created from UIof the application and stored in respective databases. You can fetch these customers from multiple ones by applying filter on any of the above mentioned fields. While fetching the customers details, you need to mention the fields and their corresponding values as key-value pair in the action filter of every processflow.

Suppose, you need to fetch two customer at a time from the application created on or before a specified date, then you need to mention created_at, ~{CreatedDate}~ and limit, 2 as key and value respectively combined with the logical && operator. limit is used to restrict the number of data fetched from the application. You can use limit with any other endpoints as well such as Order, Products etc. shopifyapp_5

Similarly, to fetch Sales Order as Draft from Shopify, you can use

  • updated_at_min and ~{CreatedDate}~
  • status and any

as key and value respectively combined with the logical && or || operator. status field can take values like any, open or completed depending on the draft otrder status.
shopifyapp_3

For any other APIs, you should provide the action filter as key-value pair, taking the fields from json structure obtained from the application.