Skip to main content

Product

This article provides comprehensive information and documentation on a set of API methods specifically designed to handle products. By leveraging these methods, users can retrieve, create, update, and search products, allowing for seamless integration and management of product data within the system.

The article includes detailed explanations, parameter descriptions, and usage examples for each API method, empowering developers to effectively utilize the capabilities provided by the product API.

Get Products

Retrieves products from the system. For filtering the results, check the “Product Search” section.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer’s account
limitintegerqueryAmount of items per page that will be returned
pagestringqueryPage number to return

Note: If limit and page parameters are not sent, response returns 10 products by default.

Request GET

Retrieves all of the products in the system.

‘content_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api_token with login.

‘Accept-language’ header determines translatable fields responses.

Path:products/


import requests

url = "https://{customer_api_url}/api/i1/products/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token),
'Accept-language':'en-us'
}

params = {
'limit': '2',
'page': '1'
}

response = requests.get(url, headers=headers , params=params)
print(response.text)

Response

Response contains all product data. Resource properties are in Python format.

PropertyData TypeDescription
namestringProduct name
base_codedictProduct base code
skustringStock keeping unit
product_typeenumProduct type (simple: 0, product_meta: 1, bundle: 2, grouped: 3, miscellaneous: 4)
is_activebooleanDefines if the product is active or passive
attribute_setidID of the related attribute set
attributesdictAttribute list
custom_attribute_setintegerAdditional attribute set ID
attributes_kwargsdictDetails of the attributes attached to the product
keydictAttribute name attached to the product
valuestringAttribute value attached to the product
data_typestringAttribute data type attached to the product
labelstringAttribute label attached to the product
extra_attributesdictAdditional attributes

“count” shows how many products exist in the system.

“next” shows the next cursor url to retrieve the desired products.

“previous” shows the previous cursor url to retrieve the desired products.

“results” shows every product detail.


{
"count": 298501,
"next": "https://{customer_api_url}/api/i1/products/?limit=2&page=2",
"previous": null,
"results": [
{
"id": 3,
"name": "Guitar",
"base_code": "1020583",
"sku": "1020583031",
"product_type": "0",
"is_active": true,
"custom_attribute_set": 480,
"attribute_set": 151,
"attributes": {},
"attributes_kwargs": {},
"extra_attributes": {},
},
{
"id": 43,
"name": "Orchid Flower",
"base_code": "1184770",
"sku": "1184770001",
"product_type": "0",
"is_active": true,
"custom_attribute_set": null,
"attribute_set": 7,
"attributes": {
"varyant_size": "36",
"airway_volume": "1"
},
"attributes_kwargs": {
"varyant_size": {
"value": "36",
"data_type": "dropdown",
"label": "36"
}
},
"extra_attributes": {},
}
]
}

Get Product Detail

To be able to retrieve the product details, a user needs to know the SKU of the product.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account.
skuintegerqueryProduct SKU

Request GET

Retrieves an instance detail of the product.

‘content_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api_token with login.

Path:products/{sku}


import requests

url = "https://{customer_api_url}/api/i1/products/{sku}"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

response = requests.get(url, headers=headers)
print(response.text)

Response

Response contains all product details data.

The explanation of the fields in the response body is provided in the table below.

Resource properties are in Python format.

PropertyData TypeDescription
namestringProduct name
base_codedictProduct base code
skustringStock keeping unit
product_typeenumProduct type (simple: 0, product_meta: 1, bundle: 2, grouped: 3, miscellaneous: 4)
is_activebooleanDefines if the product is active or passive
attribute_setidID of the related attribute set
attributesdictAttribute list
custom_attribute_setintegerAdditional attribute set ID
attributes_kwargsdictDetails of the attributes attached to the product

{
"id": 49,
"name": "Orchid Flower 80 x 35 CM",
"base_code": "1185158",
"sku": "1185158001",
"product_type": "0",
"is_active": true,
"custom_attribute_set": null,
"attribute_set": 7,
"attributes": {
"erp_ProductDetailName": "Flower",
"integration_OriginalColor": "Colorless",
"integration_ProductionPlace": "China",
"erp_Size": "000",
"integration_Lenght": "35.0",
"integration_Description": "<p> </p><p>Width: 35</p><p>Size: 80</p><p>Hight: 0</p><p>Origin: China</p>",
"color": "colorless",
"erp_PrimaryColor": "X",
"integration_SizeHeight": "0.0",
"size_height": "0.0",
"erp_SizeWidth": "35.0",
"erp_SizeHeight": "80.0",
"erp_Season": "Continuous",
"integration_Gender": "General",
"erp_ProductClassName": "PLANT GROUP",
"erp_Msb": "False",
"erp_ProductGroupName": "CONCEPT",
"integration_ModelNo": "None",
"integration_MainProductType": "0",
"variant_color": "colorless",
"erp_ProductionPlace": "China",
"erp_Description": "<p> </p><p>Width: 35</p><p>Size: 80</p><p>Hight: 0</p><p>Origin: China</p>",
"size_weight": "0.0",
"integration_Outlet": "False",
"erp_ProductSubGroupName": "DECORATIVE",
"airway_volume": "1",
"integration_Year": "2017",
"integration_SizeWeight": "0.0",
"integration_Size": "000",
"erp_MainProductType": "0",
"adjust-attempt": "cms/2020/06/29/2086b0fe-1d47-4647-98f6-dcf886c93efc.jpg",
"integration_TechnicalDetail": "None",
"integration_Season": "Continuous",
"size": "Standart",
"erp_SizeHeight": "0.0",
"erp_VariantNo": "1185158-000",
"erp_SizeWeight": "0.0",
"size_width": "35.0",
"integration_ProductSubGroupName": "Flower Group",
"integration_PrimaryColor": "X",
"erp_Outlet": "False",
"integration_ProductDetailName": "POTTED FLOWERS",
"integration_Msb": "False",
"integration_ProductSubGroupName": "DECORATIVE",
"erp_PrimaryColor": "Colorless",
"integration_SizeHeight": "80.0",
"size_height": "80.0",
"erp_ProductSubGroupName": "Flower Group",
"gender": "General",
"erp_Gender": "General",
"integration_Product": "PLANT GROUP",
"integration_VariantNo": "1185158-000",
"integration_ProductGroupName": "CONCEPT",
"erp_Year": "2017"
},
"attributes_kwargs": {
"erp_ProductDetailName": {
"value": "POTTED FLOWERS",
"data_type": "dropdown",
"label": "POTTED FLOWERS"
},
"adjust-attempt": {
"url": "https://akinon.akinoncdn.com/cms/2020/06/29/2086b0fe-1d47-4647-98f6-dcf886c93efc.jpg",
"value": "cms/2020/06/29/2086b0fe-1d47-4647-98f6-dcf886c93efc.jpg",
"data_type": "image"
},
"erp_Msb": {
"value": "False",
"data_type": "dropdown",
"label": "False"
},
"erp_PrimaryColor": {
"value": "X",
"data_type": "dropdown",
"label": "X"
},
"erp_Size": {
"value": "000",
"data_type": "dropdown",
"label": "000"
},
"erp_MainProductType": {
"value": "0",
"data_type": "dropdown",
"label": "0"
},
"color": {
"value": "COLORLESS",
"data_type": "dropdown",
"label": "COLORLESS"
},
"variant_color": {
"value": "COLORLESS",
"data_type": "dropdown",
"label": "COLORLESS"
},
"size": {
"value": "Standard",
"data_type": "dropdown",
"label": "Standart"
},
"erp_ProductionPlace": {
"value": "CHINA",
"data_type": "dropdown",
"label": "CHINA"
},
"erp_Outlet": {
"value": "False",
"data_type": "dropdown",
"label": "False"
},
"gender": {
"value": "General",
"data_type": "dropdown",
"label": "General"
},
"erp_ProductSubClassName": {
"value": "FLOWER GROUP",
"data_type": "dropdown",
"label": "FLOWER GROUP"
},
"erp_Gender": {
"value": "General",
"data_type": "dropdown",
"label": "General"
},
"erp_ProductClassName": {
"value": "FLOWER GROUP",
"data_type": "dropdown",
"label": "FLOWER GROUP"
},
"erp_PrimaryColor": {
"value": "COLORLESS",
"data_type": "dropdown",
"label": "COLORLESS"
},
"erp_ProductGroupName": {
"value": "CONCEPT",
"data_type": "dropdown",
"label": "CONCEPT"
},
"erp_ProductSubGroupName": {
"value": "DECORATIVE",
"data_type": "dropdown",
"label": "DECORATIVE"
}
},
"extra_attributes": {}
}

Search Product

GET request is used to search the products based on the provided parameters. If you don't add parameters for the filter, all products in the system will be returned. The filtering options are listed in the table below.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer account
limitintegerdataAmount of line items per page that will be returned
pageintegerdataPage number to return
namestringdataProduct name
product_typeintegerdataProduct type (simple: 0, product_meta: 1, bundle: 2, grouped: 3, miscellaneous: 4)
is_activebooleanbodyTrue or False
skustringdataStock keeping unit

Request GET

This sample request is for filtering products based on their SKU and name.

‘content_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api_token with login.

‘Accept-language’ header determines translatable fields responses.

Path: products/


import requests

url = "https://{customer_api_url}/api/i1/products/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token),
'Accept-language':'en-us'
}

params = {
#'sku':'1020170001'
'name': 'Sofa'
}

response = requests.get(url, headers=headers , params=params)
print(response.text)

Response

Response contains all product data with search parameters. Response status is expected to be HTTP-200 Successful.

The table below shows the response properties in Python format. Every field has been explained in the description section of the table.

PropertyData TypeDescription
namestringProduct name
base_codedictProduct base code
skustringStock keeping unit
product_typeenumProduct type (simple: 0, product_meta: 1, bundle: 2, grouped: 3, miscellaneous: 4)
is_activebooleanDefines if the product is active or passive
attribute_setidID of the related attribute set
attributesdictAttribute list
custom_attribute_setintegerAdditional attribute set ID
attributes_kwargsdictDetails of the attributes attached to the product
keydictAttribute name attached to the product
valuestringAttribute value attached to the product
data_typestringAttribute data type attached to the product
labelstringAttribute label attached to the product
extra_attributesdictAdditional attributes

“count” shows how many products exist in the system.

“next” shows the next cursor url to retrieve the desired products.

“previous” shows the previous cursor url to retrieve the desired products.

“results” shows product’s every detail.


{
"count": 2,
"next": "{customer_api_url}/api/i1/products/?name=Sofa&page=2",
"previous": null,
"results": [
{
"id": 14249,
"name": "Example SOFA - 121x106 cm",
"base_code": "1020170",
"sku": "1020170001",
"product_type": "0",
"is_active": true,
"custom_attribute_set": null,
"attribute_set": 8,
"attributes": {
"erp_DetailName": "SOFA",
"erp_TechnichDetail": "%100 Ferforje",
"integration_Origin": "China",
"erp_Size": "000",
"integration_Width": "121.0",
"color": "Colorless",
"integration_Heighth": "106.0",
"size_height": "106.0",
"size_width": "121.0",
"erp_depth": "48.0",
"integration_gender": "General",
"erp_ModelNo": "157A027005",
"erp_groupname": "CONCEPT",
"integration_ModelNo": "157A027005",
"erp_Year": "2007"
},
"attributes_kwargs": {
"erp_MainColor": {
"value": "X",
"data_type": "dropdown",
"label": "X"
},
"erp_Size": {
"value": "000",
"data_type": "dropdown",
"label": "000"
},
"color": {
"value": "COLORLESS",
"data_type": "dropdown",
"label": "COLORLESS"
},
"size": {
"value": "Standart",
"data_type": "dropdown",
"label": "Standart"
},
"erp_Origin": {
"value": "China",
"data_type": "dropdown",
"label": "China"
},
"gender": {
"value": "General",
"data_type": "dropdown",
"label": "General"
},
"erp_groupname": {
"value": "CONCEPT",
"data_type": "dropdown",
"label": "CONCEPT"
}
},
"extra_attributes": {}
},
{
"id": 15081,
"name": "LOREM SOFA NATUREL 260X126X80CM",
"base_code": "1021564",
"sku": "1021564001",
"product_type": "0",
"is_active": false,
"custom_attribute_set": null,
"attribute_set": 8,
"attributes": {
"erp_DetailName": "SOFA",
"integration_Origin": "VİETNAM",
"erp_Size": "000",
"integration_Width": "0.0",
"color": "Colorless",
"integration_Heighth": "0.0",
"size_height": "0.0",
"size_width": "0.0",
"size_depth": "0.0",
"integration_gender": "Genel",
"erp_ModelNo": "029A028010",
"erp_MalGrupAdi": "CONCEPT",
"integration_ModelNo": "029A028010",
"gender": "General",
"erp_Cinsiyet": "General",
"erp_groupname": "CONCEPT",
"erp_Year": "2008"
},
"attributes_kwargs": {
"erp_Size": {
"value": "000",
"data_type": "dropdown",
"label": "000"
},
"color": {
"value": "COLORLESS",
"data_type": "dropdown",
"label": "COLORLESS"
},
"size": {
"value": "Standart",
"data_type": "dropdown",
"label": "Standart"
},
"erp_Origin": {
"value": "China",
"data_type": "dropdown",
"label": "China"
},
"gender": {
"value": "General",
"data_type": "dropdown",
"label": "General"
},
"erp_groupname": {
"value": "CONCEPT",
"data_type": "dropdown",
"label": "CONCEPT"
}
},
"extra_attributes": {}
}
]
}

Create Product

This service has upsert logic. If a given ‘product_sku’ exists in the system, the product will be updated with the given parameters. If there is no matching product_sku, a new product will be created.

alt_text

Fig 1: Create Product Decision Flowchart

Note: Before a product is created, the required attribute values for color and size must be created.

ParameterData TypeInRequiredDescription
api_tokenstringheaderYESThe API key of the customer account
django_languagestringcookiesLanguage code for translation
namestringbodyYESProduct name
base_codedictbodyYESProduct base code
skustringbodyYESStock keeping unit
product_typeenumbodyYESProduct type (simple: 0, product_meta: 1, bundle: 2, grouped: 3, miscellaneous: 4)
is_activebooleanbodyDefines if the product is active or passive. If the parameter is False, the product is removed from all sales channels.
attribute_setidbodyYESID of the related attribute set
attributesdictbodyAttribute list
custom_attribute_setintegerbodyAdditional attribute set ID
attributes_kwargsdictbodyDetails of the attributes attached to the product
extra_attributesdictbodyYESThis parameter is used neither in the backend (Omnitron) nor on the website. It can be used as an additional attribute note such as attribute ID in the ERP side.

If Attribute type is ‘text’ or ‘textarea’ and the attribute will be used in a different language, ‘is_localizable’ parameter should be _True. In order to send language translation for an attribute, the Accept-Language parameter needs to be added to the header. Accept-Language parameter is an optional parameter. If it is not sent, Omnitron's default language will be defined.

Note: Before sending language translation for a product, the product must be first created in Omnitron's default language.

Request POST

POST request is used to create a new product.

‘content_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api_token with login.

In this example, the product will be created in Turkish ("tr-tr"), which is Omnitron's default language.

Path:products/


import requests
import json

url = "https://{customer_api_url}/api/i1/products/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token),
}

data = {
'base_code': '1020583001',
'sku': '102058302219001',
'product_type': '0',
'name': 'Sofa Adi',
'is_active': True,
'attribute_set': 644,
'attributes': {
'akinon_filterable_size':'L',
'brand':'Adidas',
},
'extra_attributes': {}
}

response = requests.post(url, headers=headers,data=json.dumps(data))
print(response.text)

Response

Returns the created product data. Response status is expected to be HTTP-201 Created.

Resource properties are in Python format.

PropertyData TypeDescription
idintProduct ID
namestringProduct name
base_codedictProduct base code
skustringStock keeping unit
product_typeenumProduct type (simple: 0, product_meta: 1, bundle: 2, grouped: 3, miscellaneous: 4)
is_activebooleanDefines whether the product is active or passive
attribute_setidID of the related attribute set
attributesdictAttribute list
custom_attribute_setintegerAdditional attribute set ID
attributes_kwargsdictDetails of the attributes attached to the product
extra_attributesdictAdditional attributes

{
"id": 357467,
"name": "Sofa Adi",
"base_code": "1020583001",
"sku": "102058302219001",
"product_type": "0",
"is_active": true,
"custom_attribute_set": null,
"attribute_set": 644,
"attributes": {
"brand": "Adidas",
"akinon_filterable_size": "L"
},
"attributes_kwargs": {
"akinon_filterable_size": {
"value": "L",
"data_type": "dropdown",
"label": "L"
}
},
"extra_attributes": {}
}

Request POST

POST request is used to create a new product.

‘content_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api_token with login.

In this example, the product will be updated with the second language - English ("en-us"), therefore we need to use the django_language field or the Accept-Language header.

Path: products/


import requests
import json

url = "https://{customer_api_url}/api/i1/products/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token),
}

cookies = {
'django_language':'en-us'
}

data = {
'base_code': '1020583',
'sku': '102058302219',
'product_type': '0',
'name': 'Sofa EN',
'is_active': True,
'attribute_set': 151,
'language':'en-us',
'attributes': {
'color': '0001',
'description':'cotton sofa',
'attribute_set': "151",
'erp_color': "22",
'erp_define': "single sofa",
'erp_pattern': "009",
'erp_brand': "096",
},

'extra_attributes': {}
}

response = requests.post(url, headers=headers, cookies=cookies , data=json.dumps(data))
print(response.text)

Response

Returns the created product data. Response status is expected to be HTTP-201 Created. Resource properties are in Python format.

PropertyData TypeDescription
idintProduct ID
namestringProduct name
base_codedictProduct base code
skustringStock keeping unit
product_typeenumProduct type (simple: 0, product_meta: 1, bundle: 2, grouped: 3, miscellaneous: 4)
is_activebooleanDefines if the product is active or passive
attribute_setidID of the related attribute set
attributesdictAttribute list
custom_attribute_setintegerAdditional attribute set ID
attributes_kwargsdictDetails of the attributes attached to the product
extra_attributesdictAdditional attributes

{
"id": 357170,
"name": "Sofa EN",
"base_code": "1020583",
"sku": "102058302219",
"product_type": "0",
"is_active": true,
"custom_attribute_set": null,
"attribute_set": 151,
"attributes": {
"l_name": "Sofa EN"
},
"attributes_kwargs": {},
"extra_attributes": {}
}

Language Support

To create products with translations, you need to add an Accept-Language header. The given language in the header determines the translatable fields behavior. ‘Name’ and ‘attributes’ that have is_localizable parameter True (Check the Attributes section for more info) are translatable. Users can add other language behavior by updating products with a desirable language.

Request POST

Below request creates a product and their translatable fields in the English language.

‘content_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api_token with login.

‘Accept-language’ header determines translatable fields responses.

Path:products/


import requests
import json

url = "https://{customer_api_url}/api/i1/products/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token)
'Accept-Language': 'en-us'

}

data = {
'base_code': '1020583',
'sku': '1020583099',
'product_type': '0',
'name': 'Test Rock Guitar',
'is_active': True,
'attribute_set': 151,
'attributes': {
'color': 'blue',
},
'extra_attributes': {}
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.text)

Response

Response contains all product data. Response status is expected to be HTTP-201 Created.

{
"id": 357103,
"name": "Test Rock Guitar",
"base_code": "1020583",
"sku": "1020583099",
"product_type": "0",
"is_active": true,
"custom_attribute_set": null,
"attribute_set": 151,
"attributes": {},
"attributes_kwargs": {},
"extra_attributes": {}
}

Update Product

Updates the existing product based on its SKU by setting updated values of the parameters. How to get an SKU and other details are explained under Search Product section.

PropertyData TypeInDescription
api_tokenstringheaderThe API key of the customer account
namestringbodyProduct name
base_codedictbodyProduct base code
skustringbodyStock keeping unit
product_typeenumbodyProduct type (simple: 0, product_meta: 1, bundle: 2, grouped: 3, miscellaneous: 4)
is_activebooleanbodyDefines if the product is active or passive. If it is passive, the product is removed from all sales channels.
attribute_setidbodyID of the related attribute set
attributesdictbodyAttribute list
custom_attribute_setintegerbodyAdditional attribute set ID
attributes_kwargsdictbodyDetails of the attributes attached to the product
extra_attributesdictbodyAdditional attributes

Request POST

Sample POST request for updating a product is shown below. It is an update request since the given SKU already exists in the system.

‘content_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api_token with login.

Path:products/


import requests
import json

url = "https://{customer_api_url}/api/i1/products/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}

data = {
'base_code': '1020583',
'sku': '1020583099',
'product_type': '0',
'name': 'Test Rock Guitar',
'is_active': True,
'attribute_set': 151,
'attributes': {
'color': 'blue',
},
'extra_attributes': {}
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.text)

Response

Returns the updated product fields. The table below shows the response properties in Python format. Every field has been explained in the description section of the table.

PropertyData TypeDescription
idintProduct ID
namestringProduct name
base_codedictProduct base code
skustringStock keeping unit
product_typeenumProduct type (simple: 0, product_meta: 1, bundle: 2, grouped: 3, miscellaneous: 4)
is_activebooleanDefines if the product is active or passive
attribute_setidID of the related attribute set
attributesdictAttribute list
custom_attribute_setintegerAdditional attribute set ID
attributes_kwargsdictDetails of the attributes attached to the product
extra_attributesdictAdditional attributes

{
"id": 357103,
"name": "Test Rock Guitar",
"base_code": "1020583",
"sku": "1020583099",
"product_type": "0",
"is_active": true,
"custom_attribute_set": null,
"attribute_set": 151,
"attributes": {},
"attributes_kwargs": {},
"extra_attributes": {}
}