SearchSPUs

Definition

Use this call to search SPU information by category and some keywords. The maximum number of SPUs is 100 in the response body.

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

Parameters

FieldTypeDescription
ActionstringSearchSPUs
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.
CategoryIdstringThe ID of the primary category. To get the ID for each of the system's categories, call GetCategoryTree. Optional.
SearchstringReturns those SPUs where the search string is contained in the SPU's name or brand or model. It will return all SPUs when search word is empty. Optional.
OffsetintegerNumber of SPUs to skip (i.e., an offset into the result set; together with the Limit parameter, simple result set paging is possible; if you do page through results, note that the list of products might change during paging).
LimitintegerThe maximum number of products that can be returned. If you omit this parameter, the default of 100 is used. The largest number of SPUs you can request with a single call is 500 (this is the default hard limit, which can be changed per instance). If you need to retrieve more products than that, you have to page through the result set using the Offset parameter.

Code sample

# SearchSPUs cURL example
# to run, update Timestamp and recompute Signature
#
url = "https://api.sg.ali-lazada.com/"
post
data-urlencode Action=SearchSPUs
data-urlencode Timestamp=2016-07-18T11:11+0000
data-urlencode [email protected]
data-urlencode Version=1.0
data-urlencode Signature=9ade00fb4b9ab9ed1b8a4d189f1a13e1029edc25dd963235480ec69226fd9f39
data-urlencode CategoryId=1628
data-urlencode Search=Apple iphone
data-urlencode Offset=1
//1.search by keyword
//SearchSPUs searchSPUs = new SearchSPUs("Apple");
//2.search by category Id
//SearchSPUs searchSPUs = new SearchSPUs(3L);
//3.search by category Id and keyword
//SearchSPUs searchSPUs = new SearchSPUs(3L, "Apple");
//4.search with paging
SearchSPUs searchSPUs = new SearchSPUs(3L, "Apple", 0, 100);
try {
  SearchSPUsResponse response = searchSPUs.execute();
  for(SPU spu: response.getBody().getSpus()) {
    System.out.println(spu);
  }
} catch (LazadaException e) {
  System.out.println(e.getResponseStr());
}

Response

NameTypeDescription
SPUssubsectionSPU structure list. Mandatory
SPUsubsectionSPU structure. Mandatory
SPUIdstringThe ID of SPU. Mandatory
PrimaryCategoryintegerThe ID of the primary category for his product.
SPUNamestringThe name of SPU.
AttributessubsectionAll the attributes belong to current SPU.

Some example fields in 'Attributes':

NameTypeDescription
brandstringThe brand name of the product. Optional
modelstringThe model name of the product. Optional
...Other attributes defined in the SPU.

Result sample

<?xml version="1.0" encoding="UTF-8"?>
<SuccessResponse>
  <Head>
    <RequestId>
    </RequestId>
    <RequestAction>SearchSPUs</RequestAction>
    <ResponseType>SPU</ResponseType>
    <Timestamp>2016-08-25T10:12:41+0000</Timestamp>
  </Head>
  <Body>
    <SPUs>
      <SPU>
        <SPUId>13408</SPUId>
        <PrimaryCategory>3</PrimaryCategory>
        <SPUName>Mobiles Apple 5S</SPUName>
        <Attributes>
          <Brand>Apple</Brand>
          <Model>5S</Model>
        </Attributes>
      </SPU>
      <SPU>
        <SPUId>13334</SPUId>
        <PrimaryCategory>3</PrimaryCategory>
        <SPUName>Mobiles Apple 6S</SPUName>
        <Attributes>
          <Brand>Apple</Brand>
          <Model>6S</Model>
        </Attributes>
      </SPU>
      <SPU>
        <SPUId>13333</SPUId>
        <PrimaryCategory>6620</PrimaryCategory>
        <SPUName>T-Shirts &amp; Shirts Daiichi Apple steve job inspiring t-shirt</SPUName>
        <Attributes>
          <Brand>Daiichi</Brand>
          <Model>Apple steve job inspiring t-shirt</Model>
        </Attributes>
      </SPU>
    </SPUs>
  </Body>
</SuccessResponse>
{
    "SuccessResponse": {
        "Head": {
            "RequestId": "",
            "RequestAction": "SearchSPUs",
            "ResponseType": "SPU",
            "Timestamp": "2016-08-25T11:27:32+0000"
        },
        "Body": {
            "SPUs": [
                {
                    "SPUId": 13410,
                    "PrimaryCategory": 3,
                    "SPUName": "Mobiles Apple 5S",
                    "Attributes": {
                        "Brand": "Apple",
                        "Model": "5S"
                    }
                },
                {
                    "SPUId": 13334,
                    "PrimaryCategory": 3,
                    "SPUName": "Mobiles Apple 6S",
                    "Attributes": {
                        "Brand": "Apple",
                        "Model": "6S"
                    }
                },
                {
                    "SPUId": 281,
                    "PrimaryCategory": 3,
                    "SPUName": "Mobiles Isotonix apple 7s",
                    "Attributes": {
                        "Brand": "Isotonix",
                        "Model": "apple 7s"
                    }
                }
            ]
        }
    }
}

Error messages

Error codeMessage
5E005: Invalid Request Format
14E014: %s Invalid Offset
19E019: %s Invalid Limit
30E030: Empty Request
201E201: %s Invalid CategoryId
502E502: Search SPU failed
1000Format Error Detected