Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program advertising and advertising analysis data interface


May 18, 2021 WeChat Mini Program Development Document


Table of contents


Description of the ad analysis data interface

Open the data interface to all public numbers, small programs, and game developers who become traffic owners. Through the data interface, developers can access data similar to the public platform's official website statistics module but more flexible, and can also perform advanced processing as needed.

Please note:

  1. Only data from January 1, 2016 is stored in the interface side database, and the previous data will not be queried, even if found, it is not trustworthy dirty data;
  2. It is suggested that developers save the data in their own database after calling the interface to obtain the data, so as to maximize the efficiency of access and reduce the unnecessary loss of WeChat side interface calls.
  3. Due to the large amount of data, all interfaces are pedded, with a maximum acquisition of 90 per page. (eg:total_num is 100, then the first 10 are returned when page s 1,page_size s 10; page s 1,page_size s 20, then the first 20 are returned; page s 2,page_size s 10, then article 11 to article 20 is returned)
  4. Ad bit enumeration value changes indicate that because multiple interfaces use ad bit parameters, in order to ensure the consistency of the experience and the readability of parameters, we have made some changes, all interfaces support the transfer of parameters with the ad bit type name (ad_slot), the new name on the package to represent the relevant meaning. P revious parameters slot_id can continue to be used and passed back. Specifically:
Advertising Type Name (ad_slot) Advertising type
SLOT_ID_BIZ_BOTTOM Public number of advertising
SLOT_ID_BIZ_MID_CONTEXT Public number
SLOT_ID_BIZ_VIDEO_END Public video post
SLOT_ID_BIZ_SPONSOR Public number interleeverance
SLOT_ID_BIZ_CPS Public number
SLOT_ID_WEAPP_BANNER Small program Banner
SLOT_ID_WEAPP_REWARD_VIDEO Small program excitation video
SLOT_ID_WEAPP_INTERSTITIAL Small program tablet ad
SLOT_ID_WEAPP_VIDEO_FEEDS Small program video advertisement
SLOT_ID_WEAPP_VIDEO_BEGIN Approval video
SLOT_ID_WEAPP_BOX Small program plaid advertisement
SLOT_ID_WEAPP_TEMPLATE Small program native template advertising

Interface overview

Advertising Interface is currently available to some of the advertising data displayed by the Public Platform → Flower → Data Statistics page show some income data displayed by the Public Platform → Flower → Financial Management page, and the list of interfaces related to the applet is as follows:

Interface name use Maximum time span Interface call address (HTTPS must be used)
publisher_adpos_general Get small program advertising summary data 90 days https://api.weixin.qq.com/publisher/stat?action=publisher_adpos_general&access_token=ACCESS_TOKEN
publisher_adunit_general Get small program advertising subdivision data 90 days https://api.weixin.qq.com/publisher/stat?action=publisher_adunit_general&access_token=ACCESS_TOKEN
get_adunit_list Get small program advertising list without https://api.weixin.qq.com/publisher/stat?action=get_adunit_list&access_token=ACCESS_TOKEN
publisher_settlement Get small program settlement income data and settlement subject information without https://api.weixin.qq.com/publisher/stat?action=publisher_settlement&access_token=ACCESS_TOKEN

Interface call request

First, get the small program advertising summary data (Publisher_adpos_general)

You need to adjust the address to the corresponding interface to add the following GET request parameters:

Parameters Whether it is necessary Description
page Is Return to the first few pages of data
page_size Is When the page returns the number of data bars
start_date Is Get data start time yyyy-mm-dd
end_date Is Get the end time of the data yyyyy-mm-dd
ad_slot Whether The name of the ad bit type

Note: If you don't pass the ad bit type name, data for all types of ad bits is returned by default.


Return parameter description (publisher_adpos_general)

Parameters Description
err_msg Returns an error message
Ret Error code
list: slot_id Ad bit type id
list: ad_slot The name of the ad bit type
list: date Date
list: req_succ_count The amount of pull
list: exposure_count Exposure
list: exposure_rate Exposure
list: click_count Clicks
list: click_rate Hits
list: income Revenue (points)
list: ecpm Ad thousands of exposure gains (points)
summary: req_succ_count Total pull
summary: exposure_count Total exposure
summary: exposure_rate Total exposure
summary: click_count Total clicks
summary: click_rate Total click-through rate
summary: income Total revenue (points)
summary: ecpm Ad thousands of exposure gains (points)
total_num List returns the total number of bars

Return packet example (publisher_adpos_general)

{
    "base_resp":{
        "err_msg":"ok",
        "ret":0
    },
    "list":[
        {
            "slot_id":3030046789020061,
            "ad_slot":"SLOT_ID_WEAPP_INTERSTITIAL",
            "date":"2020-04-13",
            "req_succ_count":443610,
            "exposure_count":181814,
            "exposure_rate":0.409850995,
            "click_count":10095,
            "click_rate":0.055523777,
            "income":52175,
            "ecpm":286.969100289
        }
    ],
    "summary":{
        "req_succ_count":4406394,
        "exposure_count":1797225,
        "exposure_rate":0.407867522,
        "click_count":100167,
        "click_rate":0.055734257,
        "income":578003,
        "ecpm":321.608591022
    },
    "total_num":1
}

Second, access to small program ad segmentation data (publisher_adunit_general)

The following GET request parameters need to be added to the corresponding interface call address:

Parameters Whether it is necessary Description
page Is Return to the first few pages of data
page_size Is When the page returns the number of data bars
start_date Is Get the start date of the data yyyyy-mm-dd
end_date Is Get the end time of the data yyyyy-mm-dd
ad_slot Whether The name of the ad bit type
ad_unit_id Whether Ad bit id

Note: You don't need to pass ad bit type name and ad bit id when you need to get segment data for all ad bits, you only need to pass ad bit type name when you need to get segment data for a certain type of ad bit, and you only need to pass ad bit id when you need to get segment data for an ad bit id.


Return parameter description (publisher_adunit_general)

Parameters Description
err_msg Returns an error message
Ret Error code
list: ad_unit_id Ad bit id
list: ad_unit_name The name of the ad bit
list: stat_item: ad_slot The name of the ad bit type
list: stat_item :date The date of the data
list: stat_item :req_succ_count The amount of pull
list: stat_item :exposure_count Exposure
list: stat_item: exposure_rate Exposure
list: stat_item :click_count Clicks
list: stat_item :click_rate Hits
list: stat_item :income Income
list: stat_item :ecpm Ad thousands of exposure gains (points)
total_num The total number of requests returned

Return packet example (publisher_adunit_general)

{
    "base_resp":{
        "err_msg":"ok",
        "ret":0
    },
    "list":[
        {
            "ad_unit_id":"adunit-9cedd8514XXXX",
            "ad_unit_name":"激励视频长广告",
            "stat_item":{
                "ad_slot":"SLOT_ID_WEAPP_REWARD_VIDEO",
                "date":"2020-04-10",
                "req_succ_count":138250,
                "exposure_count":74771,
                "exposure_rate":0.54083906,
                "click_count":2242,
                "click_rate":0.029984887,
                "income":93883,
                "ecpm":6.790813743
            }
        }
    ],
    "total_num":1
}

3. Get a list of ad spaces for small programs (get_adunit_list)

The following GET request parameters need to be added to the corresponding interface call address:

Parameters Whether it is necessary Description
page Is Return to the first few pages of data
page_size Is When the page returns the number of data bars
ad_slot Whether The name of the ad bit type
ad_unit_id Whether Ad bit id

Note: When you need to get a list of all ad bits, you don't need to pass the ad bit type name and ad bit id;


Return parameter description (get_adunit_list)

Parameters Description
err_msg Returns an error message
Ret Error code
ad_slot The name of the ad bit type
ad_unit_id Ad bit ID
ad_unit_name The name of the ad bit
ad_unit_size Ad bit size
ad_unit_status Ad bit status

Return packet example (get_adunit_list)

{
    "base_resp":{
        "err_msg":"ok",
        "ret":0
    },
    "ad_unit":[
        {
            "ad_slot":"SLOT_ID_WEAPP_REWARD_VIDEO",
            "ad_unit_id":"adunit-e9418ee19XXXXX",
            "ad_unit_name":"rewaXXXX",
            "ad_unit_size":[
                {
                    "height":166,
                    "width":582
                }
            ],
            "ad_unit_status":"AD_UNIT_STATUS_ON",
            "ad_unit_type":"AD_UNIT_TYPE_REWARED_VIDEO",
            "appid":"wx0afc78670fXXXX",
            "video_duration_max":30,
            "video_duration_min":6
        }
    ],
    "total_num":1
}

4. Obtaining small program settlement income data and settlement entity information (publisher_settlement)

The following GET request parameters need to be added to the corresponding interface call address:

Parameters Whether it is necessary Description
page Is The number of pages the data returns
page_size Is The number of data bars returned per page
start_date Is Get data start time yyyy-mm-dd
end_date Is Get the end time of the data yyyyy-mm-dd

Note: As long as there is a time to get the data, the data corresponding to the settlement interval will be returned. For example, requesting data for the period from 11 February to 26 March will return data for the first half of February, the second half of February, the first half of March, and the second half of March.


Return parameter description (publisher_settlement)

Parameters Description
err_msg Returns an error message
Ret Error code
body The principal name
revenue_all Accumulated income
penalty_all Deduction amount
settled_revenue_all The settled amount
settlement_list: date The time the data was updated
settlement_list: zone The date interval
settlement_list: month Revenue month
settlement_list: order 1 - First half month, 2 - second half month
settlement_list: sett_status 1 - Settled; 2, 3 - Settled; 4 - Paid; 5 - Paid
settlement_list: settled_revenue Settlement income within the interval
settlement_list: sett_no Settlement document number
settlement_list: mail_send_cnt The number of times to request a replacement settlement document
settlement_list: slot_revenue: slot_id An advertising space that generates revenue
settlement_list: slot_revenue: slot_settled_revenue The amount settled for the ad space
total_num The total number of bars requested

Return packet example (publisher_settlement)

{
    "base_resp":{
        "err_msg":"ok",
        "ret":0
    },
    "body":"深圳市腾讯计算机系统有限公司",
    "penalty_all":0,
    "revenue_all":5178368698,
    "settled_revenue_all":2613696765,
    "settlement_list":[
        {
            "date":"2020-03-25",
            "zone":"2020年3月1日至15日"
            "month":"202003",
            "order":1,
            "sett_status":1,
            "settled_revenue":718926045,
            "sett_no":"XXX",
            "mail_send_cnt":"0",
            "slot_revenue":[
                {
                    "slot_id":"SLOT_ID_WEAPP_BANNER",
                    "slot_settled_revenue":34139443
                },
                {
                    "slot_id":"SLOT_ID_WEAPP_REWARD_VIDEO",
                    "slot_settled_revenue":684786602
                }
            ]
        }
    ],
    "total_num":1
}

Error code description

The error code returns a value Meaning
45009 Requests are too frequent, please try later
45010 The interface name is not valid
1701 The argument is wrong
2009 The traffic master is not valid