About Shopify Function APIs
Shopify Functions allow developers to customize the backend logic that powers parts of Shopify. This guide introduces the available APIs for Shopify Functions.
Availability of Shopify Functions
Anchor link to section titled "Availability of Shopify Functions"All plans: Except as noted below, stores on any plan can use public apps that are distributed through the Shopify App Store and contain functions.
Shopify Plus: Only stores on a Shopify Plus plan can use custom apps that contain Shopify Function APIs.
Function API or feature | Availability |
---|---|
Cart Transform API update operation | Only Shopify Plus stores |
Order Routing Location Rule API | Only custom apps on Shopify Plus stores, by request |
Local Pickup Delivery Option Generator API | Only custom apps on Shopify Plus stores, by request |
Pickup Point Delivery Option Generator API | Only custom apps on Shopify Plus stores, by request |
Discounts Allocator API | Only custom apps on Shopify Plus stores, with the Discounts Allocator developer preview |
Payment Customizations API | Limited. Learn more |
Network access for Shopify Functions | Limited. Learn more. |
Available APIs
Anchor link to section titled "Available APIs"The following Function APIs are available:
Function API | Description | Extension target | Merchant interface |
---|---|---|---|
Delivery Customization API | Rename, reorder, and sort the delivery options available to buyers during checkout. | purchase.delivery-customization.run | Embedded app pages |
Order Discount API | Create a new type of discount that's applied to all merchandise in the cart. | purchase.order-discount.run | Admin UI extensions, Embedded app pages |
Product Discount API | Create a new type of discount that's applied to a particular product or product variant in the cart. | purchase.product-discount.run | Admin UI extensions, Embedded app pages |
Shipping Discount API | Create a new type of discount that's applied to one or more shipping rates at checkout. | purchase.shipping-discount.run | Admin UI extensions, Embedded app pages |
Payment Customization API | Rename, reorder, and sort the payment methods available to buyers during checkout. | purchase.payment-customization.run | Embedded app pages |
Cart Transform API | Expand cart line items and update the presentation of cart line items. | purchase.cart-transform.run | None |
Cart and Checkout Validation API | Provide your own validation of a cart and checkout. | purchase.validation.run | Admin UI extensions |
Fulfillment Constraints API | Provide your own logic for how Shopify should fulfill and allocate an order. | purchase.fulfillment-constraint-rule.run | None |
Local Pickup Delivery Option Generator API | Generate custom local pickup options available to buyers during checkout. | purchase.local-pickup-delivery-option-generator.run | None |
Pickup Point Delivery Option Generator API | Generate custom pickup point options available to buyers during checkout. | purchase.pickup-point-delivery-option-generator.run | None |
APIs in developer preview
Anchor link to section titled "APIs in developer preview"Function API | Description | Extension target | Merchant Interface |
---|---|---|---|
Order Routing Location Rule API | Provide your own ranking of location, for each item, during order routing. | purchase.order-routing-location-rule.run | Admin UI extensions |
Discounts Allocator API | Provide your own logic for how discounts should be calculated and allocated to a given cart. | purchase.discounts-allocator.run | None |
Getting started
Anchor link to section titled "Getting started"Learn how to use Shopify Functions by following one of our use case tutorials:
Developer tools and resources
Anchor link to section titled "Developer tools and resources"Explore the developer tools and resources available for Shopify Functions.
API versions
Anchor link to section titled "API versions"Function APIs are versioned. Updates are released quarterly and supported API versions are listed in the release notes.
Limitations and considerations
Anchor link to section titled "Limitations and considerations"The following limitations and considerations apply to all functions:
- Apps can reference only their own functions in GraphQL Admin API mutations, such as
discountAutomaticAppCreate
andcartTransformCreate
. Referencing a function from another app results in aFunction not found
error. - Shopify doesn't allow nondeterminism in functions, which means that you can't use any randomizing or clock functionality in your functions.
- You can't debug your function by printing out
STDOUT
, which is reserved for function output. UseSTDERR
instead. - Apps that provide dynamic editing and execution of function code aren't permitted on the Shopify App Store.
- Network access is supported for some functions, refer to network access for more information. You can also pre-populate data by using metafields on products and customers, or passing data using cart attributes.
Resource limits
Anchor link to section titled "Resource limits"Fixed limits
Anchor link to section titled "Fixed limits"The following resource limits apply to all functions:
Resource | Limit |
---|---|
Compiled binary size | 256 kB |
Runtime linear memory | 10,000 kB |
Runtime stack memory | 512 kB |
Logs written to STDERR |
1 kB (truncated) |
Dynamic limits
Anchor link to section titled "Dynamic limits"Certain limits are dynamic and scale based on the number of line items in a cart. The following resource limits apply to all functions for carts with up to 200 line items:
Resource | Limit (up to 200 line items) |
---|---|
Execution instruction count | 11 million instructions |
Function input | 128 kB |
Function output | 20 kB |
For carts with more than 200 line items, these values will scale proportionally as the number of cart lines increases. Calculated limits for a function execution are available in your Partner Dashboard and can be tested with Shopify CLI.
- Learn about how Shopify Functions work and the benefits of using Shopify Functions.
- Learn about how data is input to and output from Shopify Functions.