Product API reference
Learn how to make Product API requests to retrieve product data for a site.
Requests
URL
The URL for Product API requests is https://<platform_instance>/productApi
, where <platform_instance>
is the domain name of your Frosmo Platform instance.
To get the URL for your Frosmo Platform instance:
-
In the header, click your username, and select API Access.
-
In the Product API section, copy the URL.
Authentication
The Product API does not require authentication.
Methods
The Product API supports the following standard HTTP methods:
-
GET
-
POST
The only difference between the two is that with GET you provide the product IDs in the request URL, while with POST you provide the product IDs in the request body. If your GET request URL exceeds the maximum URL length, use a POST request instead.
Syntax
GET
To retrieve product data using the GET method, make the following request:
GET https://<platform_instance>/productApi?method=fetch&
origin=<site_origin>&
ids=["<product_1_id>","<product_2_id>","<product_n_id>"]
POST
To retrieve product data using the POST method, make the following request:
POST https://<platform_instance>/productApi?method=fetch&
origin=<site_origin>
# REQUEST BODY
[
"<product_1_id>",
"<product_2_id>",
"<product_n_id>"
]
Parameters
Parameter | Description | Type | Role | Example |
---|---|---|---|---|
| Request type. The possible values are:
| String | Required |
|
| Site origin. To find out your site's origin, see Getting your site origin. | String | Required |
|
| IDs of the products whose data you want to retrieve. note The array must not be empty ( info The API ignores empty values ( info The | Array of strings | Required (GET) | Retrieve the data for one product:
Retrieve the data for three products:
|
| Define whether to also return the data for product variants. If a product has one or more variants, the API returns the full product data for each variant in the The possible values are:
The default value is | Boolean | Boolean |
|
| Define whether to return debugging information for the requested products. warning Use the debugging information only for development and testing purposes. Do not use the information in production, since Frosmo does not guarantee that the information structure and content will remain the same. The debugging information for a product consists of the product ID and a message about the status of the associated product data. The possible values are:
The default value is | Boolean | Boolean |
|
Request examples
GET https://inpref.com/productApi?method=fetch&
origin=shop_company_com&
ids=["123","456","789"]
POST https://inpref.com/productApi?method=fetch&
origin=shop_company_com
# REQUEST BODY
["123","456","789"]
POST https://inpref.com/productApi?method=fetch&
origin=shop_company_com&
variants=true
# REQUEST BODY
["123","456","789"]
POST https://inpref.com/productApi?method=fetch&
origin=shop_company_com&
debug=true
# REQUEST BODY
["123","456","789"]
Responses
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"
}
}
]
}
If a product is a parent product with one or more product variants, and if the request is set to also return variants, the product object includes the variants
array, which contains the full product data for each variant.
# PRODUCT OBJECT WITH PRODUCT VARIANTS
{
"data": [
{
"id": "1001",
"type": "Fashion/Shoes",
"name": "Casual Engineer Boots",
"created_at": "2022-01-14T17:36:37+02:00",
"updated_at": "2022-01-14T17:36:37+02:00",
"attributes": {
"availability": "in stock",
"brand": "Lumberland",
"color": "Black",
"image": "https://shop.company.com/images/products/product-1001.png",
"originalPrice": 350,
"price": 290,
"url": "https://shop.company.com/products/1001"
},
"variants": [
{
"id": "1002",
"type": "Fashion/Shoes",
"name": "Casual Engineer Boots",
"created_at": "2022-01-14T17:36:37+02:00",
"updated_at": "2022-01-14T17:36:37+02:00",
"attributes": {
"availability": "in stock",
"brand": "Lumberland",
"color": "Brown",
"image": "https://shop.company.com/images/products/product-1002.png",
"originalPrice": 350,
"price": 290,
"url": "https://shop.company.com/products/1002"
}
},
{
"id": "1003",
"type": "Fashion/Shoes",
"name": "Casual Engineer Boots",
"created_at": "2022-01-14T17:36:37+02:00",
"updated_at": "2022-01-14T17:36:37+02:00",
"attributes": {
"availability": "in stock",
"brand": "Lumberland",
"color": "White",
"image": "https://shop.company.com/images/products/product-1003.png",
"originalPrice": 350,
"price": 290,
"url": "https://shop.company.com/products/1003"
}
}
]
}
]
}
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
andpromotionLabel
attributes are flattened on to theattributes
object. -
The
data
andpromotionLabel
attributes are also retained as properties of theattributes
object. -
If the
data
andpromotionLabel
attributes contain a property with the same name, only the property fromdata
gets flattened on toattributes
.
# 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.
Error message | Description | Solution |
---|---|---|
| The | Make sure the |
| The value of the | Use |
| The | Make sure the |
| The value of the | Use a valid site origin as the value of the To find out your site's origin, see Getting your site origin. |
| The | Make sure the |
| The value of the | Use a valid JSON array of strings as the value of the Example
|
| The value of the | Define at least one product ID in the Example
|
| The value of the | If you want to return product variant data, set the If you do not want to return product variant data, set the |