Data APIs are open to all verified Official Accounts. With data APIs, developers can get data that is similar to but more flexible than that of the statistics module in the Official Accounts Platform and can also perform advanced processing operations as needed.
In the Official Account login authorization mechanism, "Message Summary" APIs belong to the account service authorizations set.
Notes:
1. The API's Official Account database only stores data after December 1, 2014. Data before this time may not be found or is untrusted dirty data.
2. Developers should save the data obtained by calling the API in their own databases. This will speed up the subsequent visit speed while reducing unnecessary loss in Weixin API call.
3. To ensure that the Official Account data is calculated and processed, query the previous-day data each day before 08:00.
"Message Summary" APIs refer to the APIs that get the message summary data in the data statistics module of the Official Accounts Platform. For the specific APIs, see the following list (excluding APIs related to message keywords data):
API Name | Maximum Time Span | API Calling Address (starting with https) |
---|---|---|
getupstreammsg | 7 | https://api.weixin.qq.com/datacube/getupstreammsg?access_token=ACCESS_TOKEN |
getupstreammsghour | 1 | https://api.weixin.qq.com/datacube/getupstreammsghour?access_token=ACCESS_TOKEN |
getupstreammsgweek | 30 | https://api.weixin.qq.com/datacube/getupstreammsgweek?access_token=ACCESS_TOKEN |
getupstreammsgmonth | 30 | https://api.weixin.qq.com/datacube/getupstreammsgmonth?access_token=ACCESS_TOKEN |
getupstreammsgdist | 15 | https://api.weixin.qq.com/datacube/getupstreammsgdist?access_token=ACCESS_TOKEN |
getupstreammsgdistweek | 30 | https://api.weixin.qq.com/datacube/getupstreammsgdistweek?access_token=ACCESS_TOKEN |
getupstreammsgdistmonth | 30 | https://api.weixin.qq.com/datacube/getupstreammsgdistmonth?access_token=ACCESS_TOKEN |
The maximum time span is the maximum time range in which data can be acquired when an API is called. For example, a maximum time span of 7 means that data of the past 7 days can be acquired at a time. The actual value of access_token is obtained via the "Get access_token" API.
Note: Weekly data and monthly data are calculated from Monday and the first day of the current month, respectively. You can get the weekly/month data only after this week/month passes. For example, if you call the API on December 1 and set begin_date and end_date to November 1 and November 5, respectively, you can get the monthly data of November.
API Request Format
"Message Summary" APIs (including the above APIs) post the following sample packet to API calling address:
{
"begin_date": "2014-12-07",
"end_date": "2014-12-08"
}
Call Parameters
Parameter | Required | Description |
---|---|---|
access_token | Yes | The credential for API call |
begin_date | Yes | Gets the start date of the data. The difference between begin_date and end_date must be less than the "maximum time span" (for example, when the maximum time span is 1, the difference between begin_date and end_date can only be 0). Otherwise, an error will occur. |
end_date | Yes | Gets the end date of the data. The maximum value of end_date is yesterday. |
Response Description
The API getupstreammsghour posts the following packet to the API calling address:
{
"list": [
{
"ref_date": "2014-12-07",
"msg_type": 1,
"msg_user": 282,
"msg_count": 817
}//Followed by data of different msg_type on the same ref_date as well as data on different ref_date (within the selected time range)
]
}
The API getupstreammsg posts the following packet to the API calling address:
{
"list": [
{
"ref_date": "2014-12-07",
"ref_hour": 0,
"msg_type": 1,
"msg_user": 9,
"msg_count": 10
}//Followed by data of different msg_type in the same ref_hour as well as data in different ref_hour. Since the maximum time span is 1, ref_date is a fixed value.
]
}
The response JSON packet of the API getupstreammsgweek is as follows:
{
"list": [
{
"ref_date": "2014-12-08",
"msg_type": 1,
"msg_user": 16,
"msg_count": 27
} //Followed by data of different msg_type on the same ref_date as well as data on different ref_date
]
}
The response JSON packet of the API getupstreammsgmonth is as follows:
{
"list": [
{
"ref_date": "2014-11-01",
"msg_type": 1,
"msg_user": 7989,
"msg_count": 42206
}//Followed by data of different msg_type on the same ref_date as well as data on different ref_date
]
}
The response JSON packet of the API getupstreammsgdist is as follows:
{
"list": [
{
"ref_date": "2014-12-07",
"count_interval": 1,
"msg_user": 246
}//Followed by data of different count_interval on the same ref_date as well as data on different ref_date
]
}
The response JSON packet of the API getupstreammsgdistweek is as follows:
{
"list": [
{
"ref_date": "2014-12-07",
"count_interval": 1,
"msg_user": 246
}//Followed by data of different count_interval on the same ref_date as well as data on different ref_date
]
}
The response JSON packet of the API getupstreammsgdistmonth is as follows:
{
"list": [
{
"ref_date": "2014-12-07",
"count_interval": 1,
"msg_user": 246
}//Followed by data of different count_interval on the same ref_date as well as data on different ref_date
]
}
Response Parameters
Parameter | Description |
---|---|
ref_date | The date of the data, between begin_date and end_date |
ref_hour | The hour of the data, from 000 to 2300, representing [000,100) to [2300, 2400), respectively, that is, the first hour and the last hour of each day |
msg_type | The message type. 1: Text; 2: Image; 3: Voice; 4: Video; 6: Message with links from third-party apps |
msg_user | The number of users who send messages to Official Accounts |
msg_count | The number of messages sent to Official Accounts |
count_interval | The distribution interval of the number of messages sent on the current day. 0: 0; 1: 1-5; 2: 6-10; 3: >10 |
int_page_read_count | The number of reads of the article page |
ori_page_read_user | The number of readers of the original page that users are redirected to after tapping Read More. 0 indicates no original page. |
When an error occurs, Weixin will return the error code and other information. For the specific error code, see Common Error Codes.