APIEase Integrated With Shopify Flow - Cat Image Inventory

Kevin Wilde

Last Update منذ ٨ أيام

See this example in action:

Demo store password: eacoht

https://apiease-demo.myshopify.com/pages/flow-cat-api


This page demonstrates how you can connect your Shopify store to external services and perform backend tasks like updating inventory — all without building or hosting your own app.


Using Shopify Flow for logic and APIEase for secure API communication, you can create custom workflows that act on external data. Your API credentials are stored safely in APIEase, and everything runs directly within your Shopify environment.


This example is placed on a storefront page for demo purposes. You could simply execute the flow from the APIEase admin page by clicking the Execute API Call button for the "Flow - Cat Images - Get Cat" request.

Step-by-Step: How This Demo Works
  1. You click "Update Cat Image Inventory" on the storefront
    This triggers a request to the APIEase app via a custom app proxy endpoint.
  2. APIEase sends a request to The Cat API
    APIEase calls The Cat API to retrieve a random cat image, including its dimensions (width and height).
  3. The response is passed to Shopify Flow via a chained request from APIEase. APIEase delivers the cat image data to a pre-configured Shopify Flow using the APIEase Flow trigger.
  4. Shopify Flow runs your custom logic
    Inside Flow, a Run Code action analyzes the image width:
    • If width < 400 → size is Small
    • If 400 ≤ width < 800 → size is Medium
    • If width ≥ 800 → size is Large
  5. Flow identifies the correct inventory item
    Based on the determined size, Flow finds the corresponding product variant by title.
  6. Flow returns a response to a third and final chained request in APIEase
    The result from the Run Code action — including locationId and inventoryItemId — is passed back to APIEase.
  7. The third request securely calls a Shopify GraphQL mutation to adjust inventory using the inventoryAdjustQuantities mutation. APIEase increases the inventory count by 1 for the correct size and location.
  8. The storefront displays a success or error message once the mutation is complete. Because inventory changes can take a moment to propagate across Shopify’s systems, the user is prompted to refresh the page to see the updated inventory.
APIEase Request Chain
    There are 3 chained requests in APIEase to support this demo.


    Request #1: The Cat API

    The Cat API returns random images of cats that includes their size.


    APIEase Response:

    This response is sent with the name "previousRequestResponse" to the Shopify Flow request named "Flow - Cat Images - Add Cat" so that the data in the response can be used within the flow.

    Request #2: Shopify Flow - APIEase Flow Trigger
    • Name: Flow - Cat Images - Add Cat
    • Type: flow
    • Next Request: Flow - Cat Images - Increment Inventory

    APIEase sends the cat image data to Shopify Flow using the APIEase Flow trigger.


    APIEase Flow Trigger Incoming Flow Parameters:

    The workflow uses this data to decide if the image is small, medium or large and adds the data necessary to update the relevant variant inventory. Details of the workflow are provided below.


    APIEase Flow Action Outgoing Flow Parameters:

    APIEase Response:

    Request #3: Shopify GraphQL

    APIEase posts the increment inventory data to the Shopify GraphQL endpoint. It will replace {incrementInventoryParameter.inventoryItemId} and {incrementInventoryParameter.location} with the values from the Flow response. This is the default behaviour of chained requests. The response data of the previous request can be used to replace variables surrounded with curly brackets {} that match previous response data.


    GraphQL Body:

    Shopify Flow Workflow Steps
    1. The workflow was created in Shopify flow and the apiease-flow-trigger is added.
    2. A "Check if" condition is added to ensure that the request being processed is indeed the expected flow request.
    3. The Shopify provided "Get location data" Action is conveniently available to get location and product variant data.
    4. A Flow "Run Code" action contains the logic to categorize the image as small, medium or large based on the image width.
    5. After "Run Code" the apiease-flow-action is added with the required Flow Parameters set to {{runCode.message}}.
    Run Code Step

    Define inputs for Run Code Step:

    Write Code for Run Code Step

    The Runcode determines if the image is small, medium or large based on width. It then adds location and inventoryItemId to the flow parameters as incrementInventoryParameter. APIEase with then dynamically use incrementInventoryParameter.location and incrementInventoryParameter.inventoryItemId in the Shopify GraphQL request in APIEase.


    APIEase Flow Action

    Was this article helpful?

    0 out of 0 liked this article