Optimizing ESHOPMAN Order List Performance: Understanding Unwanted Item Data in API Responses

Streamlining ESHOPMAN Order Data: A Deep Dive into API Efficiency

As an ESHOPMAN merchant or developer leveraging the power of headless commerce and HubSpot CMS, optimizing performance is key. A recent community discussion highlighted an important area for efficiency improvements within ESHOPMAN's core order listing functionalities. This insight focuses on how ESHOPMAN's Admin API and Store API endpoints for orders might be returning more data than explicitly requested, potentially impacting the speed and responsiveness of your HubSpot-powered storefronts and administrative tools.

The Challenge: Unconditional Item Data in Order Lists

The core ESHOPMAN workflow responsible for fetching lists of orders, which powers endpoints like GET /store/orders, GET /admin/orders, and GET /admin/draft-orders, has been observed to unconditionally include all line items for every order in the response. This occurs even when the API request explicitly narrows down the desired fields, for example, by requesting only order IDs (fields=id).

Consider an ESHOPMAN store, especially one handling B2B bulk orders, where a single order might contain hundreds of individual line items. When an API call requests a list of such orders, even with minimal fields, the system currently returns every single item associated with those orders. This can lead to:

  • Significantly larger API responses: A request for ten orders, each with 50 lines, could result in hundreds of line items being transferred unnecessarily.
  • Increased load times: Processing and transferring this excess data can slow down API responses, affecting the user experience on your HubSpot CMS storefront or the efficiency of your administrative tasks.
  • Higher resource consumption: Both on the ESHOPMAN backend (Node.js/TypeScript) and the client side, more resources are consumed to handle the larger data payloads.

For context, while other related data like payment_collections and fulfillments are correctly omitted from the response when not requested, the same logic does not currently apply to order items. It appears that specific item fields (items[].raw_quantity and items[].detail.raw_fulfilled_quantity) are used for calculating the fulfillment_status, leading to the full item data being included.

Reproducing the Behavior

Developers can observe this behavior by programmatically accessing the ESHOPMAN core workflow or by making direct API calls:

// Example of programmatically accessing an ESHOPMAN core workflow
// within a custom Node.js service or script
const result = await ESHOPMAN.workflows.getOrdersListWorkflow.run({
  input: {
    fields: ["id"],
    variables: { take: 10 }
  }
});

console.log(Object.keys(result.rows[0]));
console.log(result.rows[0].items.length);

Alternatively, calling GET /store/orders?fields=id as a customer with a large order will demonstrate the substantial response size.

Proposed Directions for Improvement

The ESHOPMAN community has identified two primary approaches to address this:

  1. Conditional Item Inclusion: Modify the core workflow to only include order items in the response when they are explicitly requested via the fields parameter. This aligns with how other related data is handled.
  2. Selective Item Field Loading: If items are necessary for internal calculations like fulfillment_status even when not requested, the system could be optimized to load only the minimal required fields (e.g., items.raw_quantity and items.detail.raw_fulfilled_quantity) instead of all item fields.

What This Means for ESHOPMAN Users

Understanding this behavior is crucial for ESHOPMAN developers and merchants. If you are experiencing slower-than-expected load times for order lists or noticing unusually large API responses, this could be a contributing factor, particularly for stores with high-line-item orders. While ESHOPMAN continuously works on optimizing its platform, being aware of such nuances helps in planning your custom integrations and HubSpot CMS storefront optimizations.

Keep an eye on ESHOPMAN updates for potential resolutions to this behavior, which will further enhance the performance and efficiency of your headless commerce operations.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools