商品新增接口

单个商品发布,需要配合pdd.goods.image.upload上传主图及商品详情图片。

1.请求参数:

请求URL:

POST https://kf.fw199.com/gateway/pdd/goods/add

参数名 类型 必须 说明
appid String 必填 合作伙伴AppId
timestamp String 必填 当前时间戳
tb_seller_nick String 必填 拼多多账号, 非店铺名称
sign String 必填 如何计算生成见示例代码

相关的商品部分入参见拼多多文档

2. 请求示例代码(Java)

    @Test
     public void PddGoodsAddRequest() throws Exception {

        String seller_nick = Config.PddSellerNick; // 拼多多卖家账号
        //业务参数
        Map<String, String> data = new HashMap<String, String>();
        data.put("appid", Config.AppId);
        data.put("seller_nick", seller_nick);
        Long timestamp = System.currentTimeMillis() / 1000;
        data.put("timestamp", timestamp.toString());
        String cg = "[\"https://img.pddpic.com/open-gw/2021-10-11/ffc9a1e35840c3cf7f7af66f56c004c1.jpeg\"]";
        data.put("carousel_gallery", cg);
        data.put("cat_id", "17438");
        data.put("cost_template_id", "163280639235619");
        // 地区/国家ID,country_id可以通过pdd.goods.country.get获取,仅在goods_type为2、3时(海淘商品)入参生效,其余goods_type传0
        data.put("country_id", "0");
        data.put("goods_desc", "新包装,保证产品的口感和新鲜度。单颗独立小包装,双重营养,1斤家庭分享装,更实惠新疆一级骏枣夹核桃仁");
        data.put("goods_name", "这是通过API发布的商品不要拍!");

        String dg = "[\"https://img.pddpic.com/open-gw/2021-10-11/ffc9a1e35840c3cf7f7af66f56c004c1.jpeg\"]";

        data.put("detail_gallery", dg);
        data.put("goods_type", "1");
        data.put("is_folt", "true");
        data.put("is_pre_sale", "false");
        data.put("is_refundable", "true");
        data.put("market_price", "2000");
        data.put("second_hand", "false");
        data.put("shipment_limit_second", "86400");

        String skuList = "[{\n" +
                "        \"id\": 0,\n" +
                "        \"limit_quantity\": 0,\n" +
                "        \"out_sku_sn\": \"\",\n" +
                "        \"spec_id_list\":  \"[765]\" ,\n" +
                "        \"is_onsale\": 1,\n" +
                "        \"price_in_yuan\": \"10\",\n" +
                "        \"multi_price\": 1100,\n" +
                "        \"price\": 1200,\n" +
                "        \"quantity\": 20,\n" +
                "        \"thumb_url\": \"https://t16img.yangkeduo.com/garner-api/385531de9957fb1f3de0ce48956ee432.jpeg\",\n" +
                "        \"thumb_url_file_id\": 898996070,\n" +
                "        \"weight\": 0,\n" +
                "        \"spec\": [{\n" +
                "            \"parent_id\": 1216,\n" +
                "            \"parent_name\": \"尺寸\",\n" +
                "            \"spec_id\": 765,\n" +
                "            \"spec_name\": \"小号\"\n" +
                "        }],\n" +

                "        \"sku_srv_templates\": \"\"\n" +
                "    }, {\n" +
                "        \"id\": 0,\n" +
                "        \"limit_quantity\": 0,\n" +
                "        \"out_sku_sn\": \"\",\n" +
                "        \"spec_id_list\":  \"[767]\" ,\n" +
                "        \"is_onsale\": 1,\n" +
                "        \"price_in_yuan\": \"11\",\n" +
                "        \"multi_price\": 1200,\n" +
                "        \"price\": 1300,\n" +
                "        \"quantity\": 20,\n" +
                "        \"thumb_url\": \"https://t16img.yangkeduo.com/garner-api/70ec7360c13688309252f88a9ce49965.jpeg\",\n" +
                "        \"thumb_url_file_id\": 898953569,\n" +
                "        \"weight\": 0,\n" +
                "        \"spec\": [{\n" +
                "            \"parent_id\": 1216,\n" +
                "            \"parent_name\": \"尺寸\",\n" +
                "            \"spec_id\": 767,\n" +
                "            \"spec_name\": \"大号\"\n" +
                "        }],\n" +

                "        \"sku_srv_templates\": \"\"\n" +
                "    }]";

        data.put("sku_list", skuList);
        data.put("is_onsale", "1");
        data.put("limit_quantity", "999");
        data.put("multi_price", "1000");
        data.put("price", "900");
        data.put("quantity", "100");
        data.put("thumb_url", "https://img.pddpic.com/open-gw/2021-10-11/ffc9a1e35840c3cf7f7af66f56c004c1.jpeg");
        data.put("weight", "100");

        String skuProperties = "[{\n" +
                "        \"template_pid\": 96688,\n" +
                "        \"template_module_id\": 22326,\n" +
                "        \"ref_pid\": 310,\n" +
                "        \"pid\": 5,\n" +
                "        \"value\": \"\",\n" +
                "        \"value_unit\": \"\"\n" +
                "    }]";

        data.put("sku_properties",skuProperties);  
        // 参数签名
        data.put("sign", Utils.Sign(data, Config.AppSecret));
        doHttpRequest(Config.PddGoodsAddRequestUrl, data);

    }

2.2 请求示例的部分json片段

sku_list的json格式

[{
    "id": 0,
    "limit_quantity": 0,
    "out_sku_sn": "",
    "spec_id_list":  "[765]" ,
    "is_onsale": 1,
    "price_in_yuan": "10",
    "multi_price": 1100,
    "price": 1200,
    "quantity": 20,
    "thumb_url": "https://t16img.yangkeduo.com/garner-api/385531de9957fb1f3de0ce48956ee432.jpeg",
    "thumb_url_file_id": 898996070,
    "weight": 0,
    "spec": [{
        "parent_id": 1216,
        "parent_name": "尺寸",
        "spec_id": 765,
        "spec_name": "小号"
    }],
    "sku_srv_templates": ""
}, {
    "id": 0,
    "limit_quantity": 0,
    "out_sku_sn": "",
    "spec_id_list":  "[767]" ,
    "is_onsale": 1,
    "price_in_yuan": "11",
    "multi_price": 1200,
    "price": 1300,
    "quantity": 20,
    "thumb_url": "https://t16img.yangkeduo.com/garner-api/70ec7360c13688309252f88a9ce49965.jpeg",
    "thumb_url_file_id": 898953569,
    "weight": 0,
    "spec": [{
        "parent_id": 1216,
        "parent_name": "尺寸",
        "spec_id": 767,
        "spec_name": "大号"
    }],
    "sku_srv_templates": ""
}]

sku_properties的json格式

[{
    "template_pid": 96688,
    "template_module_id": 22326,
    "ref_pid": 310,
    "pid": 5,
    "value": "",
    "value_unit": ""
}]

3. 返回结果

返回结果如下。

{
    "code": 0,
    "message": "ok",
    "data": {
        "goods_commit_id": 72948403362,  // 上传商品的上传序列ID
        "goods_id": 286996055566, // 商品ID
        "request_id": "16339461578465562"
    },
    "trace_id": ""
}

说明: code为0表示成功,非0为失败,message会包含失败原因。

文档更新时间: 2023-03-14 17:03   作者:admin