Kakaclo Api Docs
  • Welcome!
  • Quick Start
  • Release Notes
    • 2023-08 Add API token refresh function, logistics channel to add Express
    • 2023-07 product api increase supplierLevel info
    • 2023-06 Order Automatic Split interface changes
    • 2023-04 Product CountryAndWarehouse interface changes
    • 2023-04 Order V1 Version And Order V2 Version
    • 2022-12 Order V2 Version
  • API Usage
    • API Endpoint
    • Rate Limits
  • Admin API
    • Product
      • Category
      • Products
      • CountryAndWarehouse
      • Stock
      • Product API pull suggestion
    • Order V1(Outdated)
      • Logistics Channel
      • Order
      • Query Order
        • Orders Status Json Response
      • Refund Order
      • Query ReFund
    • Order V2
      • Logistics Channel
      • Order
      • Query Order
        • Orders Status Json Response
      • Refund Order
      • Query ReFund
      • Automatic Split Logistics Channel
    • Custom Product
      • Get Design Category Name List
      • Get Design Model List
      • Get Design Model Detail
      • Get Custom Designed List
      • Get Custom Designed Detail
      • Create designed product orders and get order list
      • Get KakaClo pod-designer address
      • Save POD Designed Product
    • Payment
      • Query Balance
Powered by GitBook
On this page
  • Product Stock relationship
  • Pull process suggestion
  • Advice on dateStartTime and dateEndTime
  1. Admin API
  2. Product

Product API pull suggestion

PreviousStockNextOrder V1(Outdated)

Last updated 2 years ago

Product Stock relationship

The return value of the Product API includes stock (the sum of all sku stocks under spu), skuList, and skuList includes sku, stock (the sum of the stocks of all sku warehouses). The Stock API returns the specific inventory data of the warehouse corresponding to the sku. Therefore, by obtaining the return data of Stock Api, the total inventory of sku can be obtained, and then the inventory of spu can be obtaine

Pull process suggestion

It is recommended that you refer to the following process for programming

Step 1. Obtained by "dateStartTime", "dateEndTime" call "product API" to pull product information.

Step 2. After processing the product response data, store it in the database "product" table and "sku" table respectively, and the "product" table and "sku" table are related by the spu or kkProductId field.

Step 1 to Step 2 until the "dateEndTime" in Step 1 reaches the end of the current time.

Step 3. Obtained by "dateStartTime", "dateEndTime" call "Stock API" to pull stock information.

Step 4. Store the stock data in the database stock table.

Step 5. Sum the warehouse inventory of sku to obtain the current total inventory of sku, and update it to the sku data table

Step 6. Obtain the spu through the sku, sum the sku inventory of the spu, get the current total inventory of the spu, and then update it to the product data table

Step 3 to Step 6 until the "dateEndTime" in Step 3 reaches the end of the current time.

Through the above steps, you can basically think that the data in the product, sku, and stock tables in your database are real-time. You can get spuStatus, skuStatus, stock information from product table and sku table.

You can select an appropriate step size when obtaining through "dateStartTime" and "dateEndTime", and "dateEndTime" cannot be greater than the current time. "dateStartTime" is suggested to be the "dateEndTime" of the last pull.

The pull cycle is recommended to be every 1-5 minutes.

Generally, the data is pulled like this. Your step size is set to 8 hours. You start from "2021-06-01T00:00:00Z" and pull it every 1 minute. The time point of your first pull is "2021-06-01T00:00:00Z" - "2021-06-01T08:00:00Z", when the last page is pulled in this time period, you can start downloading A time period "2021-06-01T08:00:00Z" - "2021-06-01T16:00:00Z". Until the end time is equal to the current time (for example, the current time is "2022-10-05T11:00:00Z"), the pulled time period is "2022-10-05T08:00:00Z" - "2022-10-05T11:00:00Z". Since your pull task runs every 1 minute. The subsequent interval is basically 1 minute. Such as "2022-10-05T11:00:00Z" - "2022-10-05T11:01:00Z", the next time is "2022-10-05T11:01:00Z" - "2022-10-05T11:02:00Z" " . In this way, the difference between your data and kakaclo's data is basically only 1 minute, and since there is not much data changed in one minute, it can be considered that the data you obtain is real-time.

Advice on dateStartTime and dateEndTime

Since we use Elasticsearch for our query, this can improve the query efficiency of our api. However, there is a time difference between data synchronization from mysql to Elasticsearch, which is within 5 minutes.

So it is recommended that when you query, the maximum time of "dateEndTime" is set to the current time minus 10 minutes. For example, if the current time is "2023-01-05T08:00:00Z", then the maximum time of "dateEndTime" should not exceed "2023-01-05T07:50:00Z".

Another suggestion is that the "dateStartTime" value of the next query is set to the largest "updateTime" in the product data returned last time. In this way, your query time can always cover the latest data.

For example, the largest "updateTime" in the returned data of the current request is "2023-01-03T09:44:54Z", then the next round of request "dateStartTime" can be set to "2023-01-03T09:44:54Z".