Commodity interface of e-commerce system design

Time:2020-2-26

Commodity interface of e-commerce system design

Preface

I should be one of the few people to show interface documentation directly in the article. In this article, I have thought about whether to analyze the attention points of commodity interface development for a long time.

Client development and server development are both natural enemies and brothers. I hope this article can help you reduce disputes and give love to each other.

interface design

Sketch

In the design of e-commerce system, the more complex interface is about the interface of commodity details, and the response parameters are particularly many, especially miscellaneous. The following principles should be followed in the development of the interface for obtaining product details

  • Less JSON nesting returned
  • Convenient to find the designated SKU
  • Other interface related specifications

Commodity interface of e-commerce system design

Query SKU

About querying SKUs, I asked my little partner to do this. First, I took out the specifications and properties

Select color:[
   {
          "Name": "silver",
          "id": 75
   }
],
Select version:[
   {
          "Name": "Public Edition",
          "id": 77
   },
   {
          "Name": "[original extended warranty version]",
          "id": 78
   }  
],
"Memory":
   {
          "name": "64G",
          "id": 82
   },
   {
          "name": "256G",
          "id": 83
   }
],

Yes, you are right. In fact, you use specification as key and attribute as value. Take out the value [ID] and splice to find the corresponding SKU.

Response parameter [specification name] [attribute code] = necessary for splicing SKU string

The specification is equivalent to a group, and the attribute is actually an important part of the splicing SKU. For example, the above data

75? 77? 82 = silver, public, 64g

Interface document

Request address

/v1/product/{productId}

Request type

GET

Request parameters

parameter type Default value Explain
productId int 0 Commodity encoding

Response example

{
  "code": 200,
  "Message": "success",
  "data": {
    "id": 131,
    "Name": "Apple iPhone x (a1865) 64GB dark space gray Mobile China Unicom 4G mobile phone",
    "price": "8388.00",
    "market_price": "8388.00",
    "Sketch": "iPhone's great method is good, 10% off, 10% off, chop your hands quickly",
    "Intro": "this is the product description",
    "Keywords": ['Apple', 'iPhone'],
    "attribute": {
      Select color:[
        {
          "Name": "silver",
          "id": 75
        },
        {
          "Name": "dark gray",
          "id": 76
        }
      ],
      Select version:[
        {
          "Name": "Public Edition",
          "id": 77
        },
        {
          "Name": "[original extended warranty version]",
          "id": 78
        },
        {
          "Name": "dual network edition",
          "id": 79
        },
        {
          "Name": "wireless charging package",
          "id": 80
        },
        {
          "Name": "airports package",
          "id": 81
        }
      ],
      "Memory":
        {
          "name": "64G",
          "id": 82
        },
        {
          "name": "256G",
          "id": 83
        }
      ],
      "Purchase method":[
        {
          "Name": "official standard configuration",
          "id": 84
        },
        {
          "Name": "mobile deals",
          "id": 85
        },
        {
          "Name": "Telecom special purchase",
          "id": 86
        },
        {
          "Name": "Unicom special purchase",
          "id": 87
        }
      ]
    },
    "album": [
      {
        "id": 2,
        "Name": "this is the first picture",
        "url": "http://xxx.com/59ec33eaN6ddb0c54.jpg"
      },
      {
        "id": 3,
        "Name": "this is the second picture",
        "url": "http://xxx.com/59ec3400Nce4cc116.jpg"
      }
    ],
    "radio": {
      "id": 1,
      "Name": "this is a video",
      "url": "http://xxx.com/1.mp4"
    },
    "sku": {
      "75_77_82_84": {
        "id": 1018,
        "Name": "select color: silver; select version: public; memory: 64g; purchase method: official standard;",
        "price": "8388.00",
        "stock": 83888388
      },
      "75_77_82_85": {
        "id": 1019,
        "Name": "select color: silver; select version: public; memory: 64g; purchase method: Mobile preferential purchase;",
        "price": "8388.00",
        "stock": 83888388
      },
      "75_77_82_86": {
        "id": 1020,
        "Name": "select color: silver; select version: public; memory: 64g; purchase method: Telecom preferential purchase;",
        "price": "8388.00",
        "stock": 83888388
      },
      "75_77_82_87": {
        "id": 1021,
        "Name": "select color: silver; select version: public; memory: 64g; purchase method: Unicom preferential purchase;",
        "price": "8388.00",
        "stock": 83888388
      },
      "75_77_83_84": {
        "id": 1022,
        "Name": "select color: silver; select version: public; memory: 256g; purchase method: official standard;",
        "price": "8388.00",
        "stock": 83888388
      },
      "75_77_83_85": {
        "id": 1023,
        "Name": "select color: silver; select version: public; memory: 256g; purchase method: Mobile preferential purchase;",
        "price": "8388.00",
        "stock": 83888388
      }
    }
  }
}

Response parameter description

Core parameters

parameter type Default value Explain
id int 0 Commodity encoding
name string Product title
price double 00.00 commodity price
keywords string Product keywords
market_price double 00.00 market price
virtual int 0 Virtual sales volume
sketch string Commodity Brief
intro string Commodity details

Commodity map parameters

parameter type Default value Explain
album[] array [] Commodity carousel
id int 0 Resource encoding
name string Picture name
url string Resource path

Product video parameters

Return [] if no video

parameter type Default value Explain
radio[] array [] Merchandise video
id int 0 Resource encoding
name string Video name
url string Resource path

Product specification / property parameters

parameter type Default value Explain
attribute array[] [] Commodity attribute
[(attr_name)] [] array[] [] Attribute name
name string Property item name
id int 0 Attribute item code

Product SKU parameters

parameter type Default value Explain
sku[] array[] [] Commodity SKU
[(option_id)] [] array[] The product SKU query method is attribute (attr? Name) splicing
id int 0 SKU encoding
name string SKU name
price double 00.00 commodity price
stock int 0 Commodity inventory

Thank

If you don’t have many words, just make it clear. Thank you for seeing here. I hope this article can help you. If you have any questions, you can discuss them in the comment area. Thank you.