Attribute Value

This article provides comprehensive information and documentation on a set of API methods specifically designed to handle product attribute values. By leveraging these methods, users can retrieve, create, update, and search product attribute values, 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 attribute value API.

Get Attribute Values

To get attribute values from the system, you can send the GET request. To filter, you can add parameters such as value, value_exact, attribute as in QueryString. If you don't add parameters for the filter, all attribute values in the system will be returned.

Parameter

Data Type

In

Description

value

string

query

It searches attributes that include the value

value__exact

string

query

It searches attributes that match the value exactly

attribute

string

query

The ID of the attribute to which the attribute value is related

Request GET

GET request is used for retrieving current attribute values from the system. This request is expected to return all attribute value 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.

‘limit’ determines how many attribute values are shown in the page. Default value is 10.

‘page’ determines the page of the retrieved results. Default value is 1.

Path:attribute_value/

import requests

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

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

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

Response

Response contains all attribute value data with given parameters. Response status is expected to be HTTP-200 Successful.

Resource properties are in Python format.

Parameter

Data Type

Description

attribute

id

The id of the attribute to which the attribute value is related

value

string

Attribute's value

label

string

Attribute's label. It is used on the back office frontend.

order

int

Order

erp_code

string

Attribute's value code in ERP

“count” shows how many attribute values exist in the system.

“next” shows the next cursor url to retrieve the desired attribute values.

“previous” shows the previous cursor url to retrieve the desired attribute values.

“results” shows every attribute value detail.

Search Attribute Value

Filter attribute values in the system with allowed fields using a GET request. The table below shows the filtering options with details. If a user doesn’t add any filtering options in the query, all of the attribute values will be returned in the system.

Parameter

Data Type

In

Description

value

string

query

It searches attributes that include the value

value__exact

string

query

It searches attributes that match the value exactly

attribute

string

query

The ID of the attribute to which the attribute value is related

label

string

query

It searches the attribute values that include the label

erp_code

string

query

It searches the attribute values that include the erp_code

Request GET

‘content_type’ header represents the response type.

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

‘django_language’ cookies allow you to retrieve desired language values. ‘Attribute Value’ field is a translatable field. If there are no translations with the given language code, the response shows the default language value.

The sample request below filters all attribute values related to the attributes with ID 205.

Path:<code>i1/attribute_value/</code></strong>

Response

Response contains all attribute value data with search parameters. Response status is expected to be HTTP-200 Successful. Resource properties are in Python format.

Parameter

Data Type

Description

attribute

id

The ID of the attribute to which the attribute value is related

value

string

Attribute's value

order

int

Attribute value’s order

label

string

Attribute's label. It is used in the back-end front-end.

erp_code

string

Attribute value’s code in ERP

“count” shows how many attribute values exist in the system with used filter options.

“next” shows the next cursor url to retrieve the desired attribute values.

“previous” shows the previous cursor url to retrieve the desired attribute values.

“results” shows every attribute value detail.

Request GET ​

Below request is for retrieving Turkish values of the attribute values. Language is controlled by the ‘django_language’ cookie or ‘Accept-Language’ header. If the attribute value does not have translations for the given language code, it returns the default value.

Path: v1/attribute_value/

Response

Response contains all attribute value data with search parameters. Response status is expected to be HTTP-200 Successful. Resource properties are in Python format.

Parameter

Data Type

Description

attribute

id

The ID of the attribute to which the attribute value is related

value

string

Attribute's value

order

int

Attribute value’s order

order

string

Attribute's label. It is used on the back office front end.

erp_code

string

Attribute value’s code in ERP

“count” shows how many attribute values exist in the system with used filter options.

“next” shows the next cursor url to retrieve the desired attribute values.

“previous” shows the previous cursor url to retrieve the desired attribute values.

“results” shows every attribute value detail.

Create Attribute Value

Attribute value must be attached to an attribute. For this reason, attribute ID also must be sent when creating an attribute value. How to get attribute ID and other details are explained under Search Attribute section.

Parameter

Data Type

In

Required

Description

attribute_key

id

body

How attributes are saved in DB. (Ex: color, size).

attribute

id

body

YES

The ID of attribute to which the attribute value is related

value

string

body

YES

Attribute's value

label

string

body

Attribute's label. It is used in the backend and frontend

order

int

body

Order

erp_code

string

body

YES

Attribute's value code in ERP

Request POST

POST request is needed for creating a new attribute value.

‘content_type’ header represents the response type.

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

The ‘Translation’ key is used to add different language translations for the attribute value.

Path: v1/attribute_value/

Response​

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

The table below shows the field details of the created attribute value.

Parameter

Data Type

Description

api_token

id

The ID of the attribute to which the attribute value is related

value

string

Attribute's value

label

string

Attribute's label. It is used in the backend and frontend

order

int

Order

erp_code

string

Attribute's value code in ERP

Bad Request Responses

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

“Erp_code” and “value” are unique fields and don’t accept duplicate data.

Update Attribute Value

To update the value of the attribute, it is necessary to know the ID of the attribute value. How to get ID and other details are explained under Search Attribute Value section.

Parameter

Data Type

In

Description

value

string

query

It searches attributes that include the value

value__exact

string

query

It searches attributes that match the value exactly

attribute

string

query

The ID of the attribute to which the attribute value is related

Request PATCH

Request sample to update an attribute value. Attribute Value ID is required to perform this action. If the given ID is not found in the system, the response code is: 404 Not Found.

‘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/attribute_value/&lt;ATTRIBUTE_VALUE_ID>/

Response​

Returns the updated version of the attribute value fields. Resource Properties are in Python format.

Parameter

Data Type

Description

pk

id

The ID of the attribute value

attribute

id

The ID of the attribute to which the attribute value is related

value

string

Attribute's value

label

string

Attribute's label. It is used on the back office frontend

order

int

Order

erp_code

string

Attribute value’s code in ERP

Bad Request Responses

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

“erp_code” is a unique field and does not accept duplicate data.

“value” is a unique field.

If any product is using the “attribute_value”, the value of it cannot be updated.

Last updated

Was this helpful?