Skip to main content

Product Price

This article provides comprehensive information and documentation on a set of API methods specifically designed to handle product prices. By leveraging these methods, users can retrieve, search, and create product prices, allowing for seamless integration and management of product price 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 price API.

Get Product Price

Product Price is used to assign a price to a product. Product price objects relate to a price list. Thus, a catalog item can have a price via relation between the catalog, price list and product price.

ParameterData TypeInDescription
api_tokenstringheaderThe API key of the customer 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 product prices by default.

Request GET

GET request is used for reading current product prices from Omnitron (both i1 and v1 can be used). This request is expected to return all product prices data according to page and limit parameters.

‘content_type’ header represents the response type.

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

Path: product_price/


import requests

url = "https://{customer_api_url}/api/v1/product_price/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

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

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

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

Response

Returns product prices as paginated. Successful response status is expected to be HTTP-200 OK. If ‘i1’ is used in the request, the response may not contain some of the below fields (properties).

Resource properties are in Python format.

PropertyData TypeDescription
productRelated product id (product_sku for i1)Related product ID (product_sku for i1)
pricefloatProduct price
currency_typestring enumCurrency of the price field, default currency is ‘try’
tax_ratefloatAd valorem tax rate (Ex: 18.00)
retail_pricefloatRetail price
price_listidPrice list which includes this product
discount_percentagefloat(retail_price-price)/retail_price)*100
extra_fieldJsonCampaign and discount info regarding the price
modified_datedatetimeLast modified date of the product price
created_datedatetimeShows the date when the product price was created

“count” shows how many product prices exist in the system.

“next” shows the next cursor url to retrieve the desired product prices.

“previous” shows the previous page url to retrieve the desired product prices.

“results” shows every product price property with detailed field descriptions for the current page.


{
"count": 1013,
"next": "https://{customer_api_url}/api/v1/product_price/?limit=2&page=2",
"previous": null,
"results": [
{
"pk": 2,
"product": 913,
"price": "62.44",
"price_list": 1,
"currency_type": "try",
"tax_rate": "8.00",
"retail_price": "249.75",
"extra_field": {},
"discount_percentage": "75.00",
"modified_date": "2017-01-23T18:29:23.716095Z",
"created_date": "2017-01-23T00:20:46.274433Z"
},
{
"pk": 3,
"product": 911,
"price": "62.44",
"price_list": 1,
"currency_type": "try",
"tax_rate": "8.00",
"retail_price": "249.75",
"extra_field": {},
"discount_percentage": "75.00",
"modified_date": "2017-01-23T18:29:22.861177Z",
"created_date": "2017-01-23T00:20:46.321359Z"
},
{
"pk": 4,
"product": 910,
"price": "62.44",
"price_list": 1,
"currency_type": "try",
"tax_rate": "8.00",
"retail_price": "249.75",
"extra_field": {},
"discount_percentage": "75.00",
"modified_date": "2017-01-23T18:29:22.390819Z",
"created_date": "2017-01-23T00:20:46.370001Z"
}
]
}

Create or Update Product Price

This service has the upsert logic. If the price list has the product SKU, the price of the product will be updated with the given parameters. If there is no product SKU available in the price list, a price will be created in the list with the product SKU.

To create or update the price of the product, it is necessary to know the ID of the price list. How to get the price list ID and other details are explained under this section.

ParameterData TypeDescription
ididProduct Price ID
productid stringRelated product ID (product_sku for i1)
pricefloatSale price
price_listidPrice list which includes this product
currency_typestring enumCurrency unit
tax_ratefloatBody
retail_pricefloatRetail price
discount_percentagefloat(retail_price-price)/retail_price)*100
extra_fieldJsonCampaign and discount info for regarding price

Request POST

POST request is used to create a new product price object. ‘Product’ and ‘price_list’ are unique_together fields.

‘content_type’ header represents the response type.

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

Path: i1/product_price/


import requests
import json

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

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

data = {
"product": 1,
"price": "62.44",
"price_list": 6,
"currency_type": "usd",
"tax_rate": "8.00",
"retail_price": "249.75"
}

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

Response

Returns the created object data after successfully creating the object. Successful response status is expected to be HTTP-201 Created.

Resource properties are in Python format.

PropertyData TypeDescription
idintegerID number of product price
product_skustringProduct SKU
pricefloatProduct price
currency_typestring enumCurrency of the price field, default currency is ‘try’
tax_ratefloatAd valorem tax rate (Ex: 18.00)
retail_pricefloatRetail price
price_listidPrice list which includes this product
extra_fieldJsonCampaign and discount info for regarding price

{
"pk": 12842,
"product": 1,
"price": "62.44",
"price_list": 6,
"currency_type": "usd",
"tax_rate": "8.00",
"retail_price": "249.75",
"extra_field": {},
}

Bad Request Responses

When the requested action cannot be executed, API gives an explanation about the request.

When creating a product price, product and price_list combination should be unique. Otherwise, the below error appears (‘product’ and ‘price_list’ are unique_together fields).

{
u'non_field_errors': [ErrorDetail(string=u'The fields product, price_list must make a unique set.', code=u'unique')]
}

name and code fields should be unique.

{
'name': [ErrorDetail(string=u'price list with this name already exists.', code=u'unique')]
}
{
'code': [ErrorDetail(string=u'price list with this code already exists.', code=u'unique')]
}

Bulk Create or Update Product Price

This service has the same logic as the Create or Update Product Price Service. The only difference is that this service accepts a maximum of 10 instances to be updated or created at a time. It also accepts batch_id as a parameter which is described in the table below.

ParameterData TypeDescriptionRequired
product__skustringProduct SKU fieldYES
pricefloatSale priceYES
price_listidPrice list which includes this productYES
currency_typestring enumCurrency unitNO. Default is ‘try’
tax_ratefloatBodyNO
retail_pricefloatRetail priceNO
discount_percentagefloat(retail_price-price)/retail_price)*100NO
extra_fieldJsonCampaign and discount info regarding the priceNO
batch_idstringEnables to track your actions. The value does not insert in the Omnitron Database. It will return in the response.NO

Request POST

POST request is used to create a new product price object. ‘Product’ and ‘price_list’ are unique_together fields.

‘content_type’ header represents the response type.

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

Path: /api/i1/product_price/bulk_upsert/


import requests
import json

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

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

data = [
{
"product_sku": "SKU-001",
"price": "62.44",
"price_list": 6,
"currency_type": "usd",
"tax_rate": "8.00",
"retail_price": "249.75",
"batch_id": "2423uh2u-234-234-23-42342"
},
{
"product_sku": "SKU-001",
"price": "62.44",
"price_list": 6,
"currency_type": "usd",
"tax_rate": "8.00",
"retail_price": "249.75",
"batch_id": "2423uh2u-234-234-23-42342"
},
{
"product_sku": "SKU-003",
"price": "62.44",
"price_list": 6,
"currency_type": "usd",
"tax_rate": "8.00",
"retail_price": "249.75",
"batch_id": "2423uh2u-234-234-23-42342"
},
]

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

Response

Returns each object status information. Successful response status is expected to be HTTP-200 Successful.

Resource properties are in Python format.

PropertyData TypeDescription
product__skustringProduct SKU
created_or_updatedbooleanTrue means Product Price is created. False means Product Price is updated.
successbooleanShows whether the operation is successfully completed or not.
batch_idstringGiven batch_id
errorsstringIf the operation has failed, it shows the reason.
[
{
"sku": "SKU-001",
"created_or_updated": False,
"success": True,
"batch_id": "2423uh2u-234-234-23-42342"
},
{
"product_sku": "SKU-002",
"created_or_updated": True,
"success": True,
"batch_id": "2423uh2u-234-234-23-42342"
},
{
"product_sku": "SKU-003",
"error": "Error Message",
"success": False,
"batch_id": "2423uh2u-234-234-23-42342"
},
]