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 | 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 | 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 | 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.
- The compiled function can't exceed 256 kB in size.
- You can't debug your function by printing out
STDOUT
, which is reserved for function output. UseSTDERR
instead. Function logs to
STDERR
are truncated after 1 kB. Some Wasm toolchains might crash ifSTDERR
fails to write full logs.The logic of the function must execute in a maximum of 11 million instructions, which can be tested locally using
function-runner
.At runtime, a function can't exceed the following memory limits:
- Linear memory limit: 10 MB
- Stack memory limit: 512 kB
A function's input cannot exceed 64,000 bytes in size.
Refer to input query limitations for more information.
A function's output can't exceed 20 kB in size.
An app can deploy a maximum of 100 functions.
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.
- 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.