Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Lazada Product Detail API: Request Implementation & Response Field Breakdown (Attributes, Pricing, Main Images)

Tech Jun 13 1

The Lazada Item Detail API anables retrieval of comprehensive information for a specified product, including core attributes, pricing details, main product images, and seller-related data. Note that response fields may vary based on the API version and platform updates, so always refer to Lazada's official developer documentation for the most accurate and up-to-date specifications.

To use the API, you must obtain valid credentials (API key and secret) from an authorized gateway provider or Lazada's official developer platform. Below is a Python implementation example:

# coding: utf-8
"""
Compatible with Python 2.x and 3.x
Dependency: Install via pip install requests
"""
import requests
from typing import Dict, Any

def get_lazada_product(api_key: str, api_secret: str, product_id: str, country_code: str) -> Dict[str, Any]:
    # Replace with your authorized API endpoint
    base_endpoint = "https://api-gw.example.com/lazada/product_detail/"
    request_params = {
        "api_key": api_key,
        "api_secret": api_secret,
        "product_id": product_id,
        "country": country_code
    }
    request_headers = {
        "Accept-Encoding": "gzip",
        "Connection": "keep-alive"
    }
    
    try:
        response = requests.get(base_endpoint, params=request_params, headers=request_headers)
        response.raise_for_status()
        return response.json()
    except requests.exceptions.RequestException as err:
        raise Exception(f"API request failed: {str(err)}")

if __name__ == "__main__":
    # Replace with your actual credentials and target product data
    USER_API_KEY = "<your_valid_api_key>"
    USER_API_SECRET = "<your_valid_api_secret>"
    TARGET_PRODUCT_ID = "267690734"
    TARGET_MARKETPLACE = "co.th"
    
    product_info = get_lazada_product(USER_API_KEY, USER_API_SECRET, TARGET_PRODUCT_ID, TARGET_MARKETPLACE)
    print(product_info)

In the example above, product_id refers to the unique identifier of the product you wish to query, and country_code specifies the Lazada marketplace (e.g., co.th for Thailand).

A sample JSON response (simplified) is shown below:

{
  "product": {
    "product_id": "267690734",
    "title": "Premium Men's Formal Oxford Shoes - Leather Wedding & Business Footwear",
    "current_price": 232,
    "seller_name": "URBAN SAFARI",
    "main_image_url": "//my-test-11.slatic.net/original/208de91b5132477f8a723c82c56c3a58.jpg",
    "product_page_url": "https://www.lazada.co.th/products/oxfords-i267690734-s418579763.html",
    "brand_name": "No Brand",
    "original_retail_price": 417,
    "variant_list": {
      "variant": [
        {
          "total_price": 0,
          "current_price": 232,
          "original_retail_price": 417,
          "stock_quantity": 1950,
          "variant_attributes": "30097:95204;30585:133117",
          "attribute_labels": "30097:95204:Color:White;30585:133117:Size:38",
          "variant_id": "418579756"
        },
        {
          "total_price": 0,
          "current_price": 232,
          "original_retail_price": 417,
          "stock_quantity": 1949,
          "variant_attributes": "30097:95204;30585:133137",
          "attribute_labels": "30097:95204:Color:White;30585:133137:Size:39",
          "variant_id": "418579757"
        }
      ]
    }
  }
}

Key response field explanations:
- `product_id`: Unique identifier for the target product
- `current_price`: Discounted selling price for the product
- `seller_name`: Name of the Lazada store listing the product
- `main_image_url`: URL of the primary product image
- `product_page_url`: Direct link to the product's Lazada marketplace page
- `variant_list`: Collection of all available product variatns, including size, color, stock levels, and variant-specific pricing

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

SBUS Signal Analysis and Communication Implementation Using STM32 with Fus Remote Controller

Overview In a recent project, I utilized the SBUS protocol with the Fus remote controller to control a vehicle's basic operations, including movement, lights, and mode switching. This article is aimed...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.