GetCategoryAttributes

Definition

Use this call to get a list of attributes with options for a given category. It will also display attributes for TaxClass, with their possible values listed as options.

Request URI: https://api.sellercenter.lazada.sg?Action=GetCategoryAttributes

Parameters

FieldTypeDescription
ActionstringGetCategoryAttributes
Name of the API that is to be called. Mandatory.
FormatstringThe response format, with XML as the default. Can be XML or JSON. Optional.
TimestampdatetimeThe current time in ISO8601 format (e.g., Timestamp=2016-04-01T10:00:00+02:00 for Berlin). Mandatory.
UserIDstringThe ID of the user making the call. Mandatory.
VersionstringThe API version against which this call is to be executed. The current version is "1.0". Mandatory.
SignaturestringThe cryptographic signature, authenticating the request. You must create this value by computing the SHA256 hash of the request, using the API key of the user specified in the UserID parameter. Mandatory.
PrimaryCategoryintegerIdentifier of the category for which the caller wants the list of attributes.

Code sample

🚧

One exception for category attribute

For all category attributes of type singleSelect or multiSelect, you can find valid values by calling GetCategoryAttributes, but this is not true for the 'brand' attribute.
In order to get valid brand list, you need to use the GetBrands API.

//This API is intend for providing the information listed below:
//1. Attributes for both Product and Sku
//2. Whether or not an attribute is mandatory
//3. Valid values for attribute of type singleSelect or mutiSelect

//you may find this info useful for creating product

GetCategoryAttributes getCategoryAttributes = new GetCategoryAttributes(2L);
try {
    GetCategoryAttributesResponse response = getCategoryAttributes.execute();
    System.out.println("Product mandatory attributes:");
    for(Attribute attribute: response.getProductMandatoryAttributes()) {
        System.out.println(String.format("name:[%s], type:[%s],options:%s",
          attribute.getName(), attribute.getInputType(), attribute.getOptionValues().toString()));
    }
    System.out.println("Sku mandatory attributes:");
    for(Attribute attribute: response.getSkuMandatoryAttributes()) {
        System.out.println(String.format("name:[%s], type:[%s],options:%s",
          attribute.getName(), attribute.getInputType(), attribute.getOptionValues().toString()));
    }
} catch (LazadaException e) {
    System.out.println(e.getResponseStr());
}

Response

The tags of the result XML have the following types and meaning.

NameTypeDescription
namestringIdentifier of the attribute
labelstringHuman-readable display name of the attribute
isMandatorybooleanWhether the attribute is mandatory. 1 for mandatory, and 0 for optional.
isSalePropbooleanWhether the attribute is sale property. 1 for sale property, and 0 for non sale property. Sale property is always mandatory attribute.
DescriptionstringAttribute description
attributeTypestringAttribute type
inputTypestringAttribute input type (for example, text, rich text, enumInput, multiEnumInput, and option)
optionsnodeList of all option nodes
name (option)stringOption name

πŸ“˜

What are mandatory attributes?

A method to identify mandatory attributes:

Mandatory attribute fields

Eg:
"attributeType": "normal",
"inputType": "singleSelect",
"label": "warranty_type",
"isMandatory": 1

If this is indicated, it would be required.

There will be instances where SKU specific attributes are mandatory.

Result sample

A success result sample is as follows.

<?xml version="1.0" encoding="UTF-8"?>
<SuccessResponse>
  <Head>
    <RequestId/>
    <RequestAction>GetCategoryAttributes</RequestAction>
    <ResponseType>Attributes</ResponseType>
    <Timestamp>2015-07-01T11:11:11+0000</Timestamp>
  </Head>
  <Body>
  [{
    "attributeType":"sku",
    "inputType":"text",
    "isMandatory":1,
    "isSaleProp":0,
    "label":"title",
    "name":"title",
    "options":[]
  },
  {
    "attributeType":"sku",
    "inputType":"richText",
    "isMandatory":1,
    "isSaleProp":0,
    "label":"description",
    "name":"description",
    "options":[]
  },
  {
    "attributeType":"normal",
    "inputType":"text",
    "isMandatory":1,
    "isSaleProp":0,
    "label":"price",
    "name":"price",   
    "options":[]
  },
  {
    "attributeType":"normal",
    "inputType":"option",
    "isMandatory":1,
    "isSaleProp":1,
    "label":"CPU Core",
    "name":"CPU Core",
    "options":[{
        "name":"4 cores"
      },
      {
        "name":"2 cores"
      }]
  }]
  </Body>  
</SuccessResponse>

Error messages

Error codeMessage
57E057: No attribute sets linked to that category.