On this page
About the API
The Commerce API extends the JSON:API implementation in Drupal core. The official JSON:API integration documentation can be found here: https://www.drupal.org/docs/8/core/modules/jsonapi-module.
The JSON:API module, by defaults, exposes Drupal's direct data structure and naming over the API. The Commerce API module has made modifications to provide an end-user API that does not expose Drupal's underlying data structure.
If you do not want these customizations, you can read the Remove customizations to resource types documentation page to remove these changes.
The API design follows these patterns:
- All resource types will not contain any of the commerce_ prefixes used in the entity type definitions.
- All resource type paths will use a pluralized format for the object type, for instance, orders instead of order and products instead of product.
- No resource types shall expose serial identifiers.
The default Drupal implementation of the JSON:API uses an entity's UUID for identifiers and exposes the serial identifier as drupal_internal__*. This field has been disabled on all Commerce entities to enforce using the UUID.
Resource type alterations
This module has made alterations to the normal JSON:API module resource type representations of entity types. Below is an overview of those changes
| Entity type | Resource type name | Resource path |
commerce_checkout_flow |
checkout-flow |
/jsonapi/checkout-flows |
commerce_currency |
currency |
/jsonapi/currencies |
commerce_number_pattern |
number-pattern |
/jsonapi/number-patterns |
commerce_order_item_type |
order-item-type |
/jsonapi/order-item-types |
commerce_order_item |
order-item |
/jsonapi/order-items/{type} |
commerce_order_type |
order-type |
/jsonapi/order-types |
commerce_order |
order--{type} |
/jsonapi/orders/{type} |
commerce_payment_gateway |
payment-gateway |
/jsonapi/payment-gateways |
commerce_payment_method |
payment-method--{type} |
/jsonapi/payment-methods/{type} |
commerce_payment |
payment--{type} |
/jsonapi/payments/{type} |
commerce_product_attribute_value |
product-attribute-value--{type} |
/jsonapi/product-attribute-values/{type} |
commerce_product_attribute |
product-attributes |
/jsonapi/product-attributes |
commerce_product_type |
product-type |
/jsonapi/product-types |
commerce_product_variation_type |
product-variation-type |
/jsonapi/product-variation-types |
commerce_product_variation |
product-variation--{type} |
/jsonapi/product-variations/{type} |
commerce_product |
product--{type} |
/jsonapi/products/{type} |
commerce_promotion |
promotion |
/jsonapi/promotions |
commerce_promotion_coupon |
promotion-coupon |
/jsonapi/promotion-coupons |
commerce_store_type |
store-type |
/jsonapi/store-types |
commerce_store |
store--{type} |
/jsoanpi/stores/{type} |
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion