淘宝天猫店铺优惠券查询接口

531 阅读2分钟

有时,您需要获取店铺优惠券,为您的用户提供更好的优惠方案选择。

【接口功能】:查询商品对应的可用店铺券和商品优惠券。

【参数说明】:

名称类型必须描述

keyString是调用key(必须以GET方式拼接在URL中获取Key和secret

secretString是调用密钥 (接口代码wechat)

api_nameString是API接口名称(包括在请求地址中)[item_search,item_get,item_search_shop等]

cacheString否[yes,no]默认yes,将调用缓存的数据,速度比较快

result_typeString否[json,jsonu,xml,serialize,var_export]返回数据格式,默认为json,jsonu输出的内容中文可以直接阅读

langString否[cn,en,ru]翻译语言,默认cn简体中文

versionString否API版本

【代码请求示例】(备注:CURL、PHP 、PHPsdk 、Java 、C# 、Python…)

"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 请求示例 url 默认请求参数已经做URL编码
url = "https://wx19970108018/taobao/item_search_coupon/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=&num_iid=634250549720&pid=&cookie="
headers = {
    "Accept-Encoding": "gzip",
    "Connection": "close"
}
if __name__ == "__main__":
    r = requests.get(url, headers=headers)
    json_obj = r.json()
    print(json_obj)

【响应示例】

接口返回和手淘产品详情页的领券功能显示的优惠券一样,即为该商品可用的店铺优惠券(注意不是产品单品券)。

以下是商品626132884654查询的店铺券结果:

执行结果:

{

"error": "0",

"msg": "店铺优惠券查询成功!",

"coupons_total": 1,  //店铺优惠券数量

"has_coupon_prom": 1,   //是否有店铺满减活动,1表示有,0表示没有

"data": [

    {

        "subTitles": [

            "有效期至2021.03.31 23:59"

        ],

        "effectiveTime": 1614614400000,   //有效期

        "titles": [

            "满199使用"   //使用条件

        ],

        "type": 1,

        "uuid": "de5b3aaebe87400c83a0232217bc8a7d",   //券ID

        "logoImageUrl": "https://gw.alicdn.com/tfs/TB19Nsthbr1gK0jSZR0XXbP8XXa-498-90.png",

        "promotionUniqueId": "de5b3aaebe87400c83a0232217bc8a7d",

        "priceCurrency": "¥",

        "applyText": "立即领取",

        "uuid4Cal": "de5b3aaebe87400c83a0232217bc8a7d",

        "priceText": "5",   //优惠券面额:减5元(满199元)

        "unEffectiveTime": 1617206399000,   //有效期

        "bgUrl": "https://gw.alicdn.com/tfs/TB1UZgNf7T2gK0jSZFkXXcIQFXa-1428-288.png"

    },

     ........  //其它券略掉

    {

        "priceDes": "起",

        "priceCurrency": "¥",

        "subTitles": [

            "距到期仅剩2天"

        ],

        "applyUrl": "//h5.m.taobao.com/shopb/shopactivity.html?activityId=15626565363&sellerId=2271279753&source=2&spm=W-a211f8.10431435&scm=20140619.detail.dpb.0",

        "effectiveTime": 1615704560000,

        "titles": [],

        "type": 1007,

        "items": [   //店铺满减活动

            {

                "actionType": "4",

                "actionValue": "8",

                "title": "满35元,省8元",

                "gifts": [],

                "promotionUniqueId": "15626565363-1"

            },

            {

                "actionType": "4",

                "actionValue": "11",

                "title": "满41.9元,省11元",

                "gifts": [],

                "promotionUniqueId": "15626565363-2"

            },

            {

                "actionType": "4",

                "actionValue": "14",

                "title": "满47.9元,省14元",

                "gifts": [],

                "promotionUniqueId": "15626565363-3"

            },

            {

                "actionType": "4",

                "actionValue": "19",

                "title": "满53.9元,省19元",

                "gifts": [],

                "promotionUniqueId": "15626565363-4"

            }

        ],

        "priceText": "8",

        "unEffectiveTime": 1615856399000,

        "logoImageUrl": "https://gw.alicdn.com/tfs/TB1a.3vheH2gK0jSZJnXXaT1FXa-498-90.png",

        "bgUrl": "https://gw.alicdn.com/tfs/TB1rPY7gkT2gK0jSZFkXXcIQFXa-714-142.png"

    }

]