Pages

Learn about Product API responses:

See also Product API: Requests.

Success

On a success, the Product API returns the requested product data in the JSON format. The response status code is 200.

The response body is an object that contains the data array. Each item in the data array is an object that stores the data for a single product.

{
  "data": [
    {<product 1 data>},
    {<product 2 data>},
    ...
    {<product n data>}
  ]
}

Each product object contains the full set of product data tracked for the product on the site. The main product attributes (id, type, name, created_at, updated_at) are direct properties of the object, while all other product attributes are stored as properties of the attributes object.

# PRODUCT OBJECT

{
  "data": [
    {
      "id": "123",
      "type": "Food/Fruits",
      "name": "Coconut",
      "created_at": "2021-06-08T13:25:06+03:00",
      "updated_at": "2021-06-08T13:59:08+03:00",
      "attributes": {
        "availability": "in stock",
        "brand": "Mr. Fruit",
        "image": "https://company.com/images/products/product-123.png",
        "originalPrice": 5,
        "price": 3,
        "url": "https://company.com/products/123"
      }
    }
  ]
}

Legacy product data

If you're tracking products using the legacy product data structure, which is now deprecated, note the following about the returned data:

  • The contents of the data and promotionLabel attributes are flattened on to the attributes object.
  • The data and promotionLabel attributes are also retained as properties of the attributes object.
  • If the data and promotionLabel attributes contain a property with the same name, only the property from data gets flattened on to attributes.
# data and promotionLabel both contain discountPrice

"attributes": {
  "data": "{\"onSale\":true,\"discountPrice\":10}",
  "promotionLabel": "{\"discountPrice\":13,\"color\":\"red\"}",
  "onSale": true,
  "discountPrice": 10,
  "color": "red"
}

# data and promotionLabel do not contain overlapping properties

"attributes": {
  "data": "{\"onSale\":true}",
  "promotionLabel": "{\"discountPrice\":13,\"color\":\"red\"}",
  "onSale": true
  "discountPrice": 13,
  "color": "red",
}

Error

On an error, the Product API returns the response status code 400 and an error message.

Table: Product API error messages

Error messageDescriptionSolution
parameter 'method' missing
The method query parameter is missing from the request URL or its value is empty.Make sure the method query parameter is properly defined.
invalid method '<parameter_value>'
The value of the method query parameter, <parameter_value>, is invalid.Use fetch as the value of the method query parameter.
parameter 'origin' missing
The origin query parameter is missing from the request URL or its value is empty.Make sure the origin query parameter is properly defined.
invalid origin parameter '<parameter_value>'
The value of the origin query parameter, <parameter_value>, is invalid.

Use a valid site origin as the value of the origin query parameter.

To find out your site's origin, see Getting your site origin.

parameter 'ids' missing
The ids query parameter is missing from the request URL or its value is empty.Make sure the ids query parameter is properly defined.
parameter 'ids' contains invalid JSON: failed to parse
The value of the ids query parameter is not a valid JSON array of strings.

Use a valid JSON array of strings as the value of the ids query parameter.

Example
ids=["123","456","789"]
must provide at least one product id
The value of the ids query parameter is an empty array.

Define at least one product ID in the ids parameter.

Example
ids=["123"]