Shopify Functions APIs reference
Shopify Functions allow developers to customize the backend logic that powers parts of Shopify. This guide introduces the available APIs for Shopify Functions.
Available APIs
Anchor link to section titled "Available APIs"The following Function APIs are available:
Function API | Description |
---|---|
Delivery Customization API | Rename, reorder, and sort the delivery options available to buyers during checkout. |
Order Discount API | Create a new type of discount that's applied to all merchandise in the cart. |
Product Discount API | Create a new type of discount that's applied to a particular product or product variant in the cart. |
Payment Customization API | Rename, reorder, and sort the payment methods available to buyers during checkout. |
APIs in developer preview
Anchor link to section titled "APIs in developer preview"Function API | Description |
---|---|
Cart and Checkout Validation API | Provide your own validation of a cart and checkout. |
Fulfillment Constraints API | Provide your own logic for how Shopify should fulfill and allocate an order. |
Order Routing Location Rule API | Provide your own ranking of location, for each item, during order routing. |
Shipping Discount API | Create a new type of discount that's applied to one or more shipping rates at checkout. |
Function API | Description |
---|---|
Cart Transform API | Expand cart line items and update the presentation of cart line items. |
Getting started
Anchor link to section titled "Getting started"Learn how to use Shopify Functions by following one of our use case tutorials:
Limitations
Anchor link to section titled "Limitations"The following limitations apply to all functions:
- 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 50 functions.
Network access isn't supported. For example, you can't send HTTP requests to your app's backend as part of the function's logic. However, you can 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.