# analysis.getUserPortrait
Call this API at the server side. For more information, see Server API.
This API supports Cloud Calls. The WeChat DevTools version must be
1.02.1904090
or later (download the latest stable version here), and thewx-server-sdk
version must be0.4.0
or later.
Obtains the portrait of new or active users of a Mini Program. The data of the previous day, the recent 7 days, and the recent 30 days is supported. The number of new users refers to the number of deduplicate users who visit the Mini Program for the first time within the specified time. The number of active users refers to the number of deduplicate users who visit the Mini Program within the specified time.
Calling methods:
# HTTPS Call
# Request Address
POST https://api.weixin.qq.com/datacube/getweanalysisappiduserportrait?access_token=ACCESS_TOKEN
# Request Parameters
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
access_token | string | Yes | Credentials to call API | |
begin_date | string | Yes | Start date, in the format of yyyymmdd. | |
end_date | string | Yes | End date, in the format of yyyymmdd. The gap between the start date and end date can be 0 days, 6 days, or 29 days only, which respectively indicates that the data of the previous day, the recent 7 days, or the recent 30 days is queried. The maximum value is the previous day. |
# Return Value
# Object
JSON data package that is returned
Attribute | Type | Description |
---|---|---|
ref_date | string | Time range, for example, "20170611-20170617" |
visit_uv_new | Object | Portrait of new users |
visit_uv | Object | Portrait of active users |
visit_uv_new is composed as follows
Property | Type | Description |
---|---|---|
index | number | Distribution type |
province | Object | Province, for example, Beijing or Guangdong. |
city | Object | City, for example, Beijing or Guangzhou. |
genders | Object | Gender. Its values include "Male", "Female", and "Unknown". |
platforms | Object | Terminal platform, for example, an iPhone or Android device. |
devices | Object | Device model, for example, iPhone 6 or OPPO R9. |
ages | Object | Age, for example, below 17 years old, or between 18–24 years old. |
province is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
city is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
genders is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
platforms is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
devices is composed as follows:
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
ages is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
visit_uv is composed as follows
Property | Type | Description |
---|---|---|
index | number | Distribution type |
province | Object | Province, for example, Beijing or Guangdong. |
city | Object | City, for example, Beijing or Guangzhou. |
genders | Object | Gender. Its values include "Male", "Female", and "Unknown". |
platforms | Object | Terminal platform, for example, an iPhone or Android device. |
devices | Object | Device model, for example, iPhone 6 or OPPO R9. |
ages | Object | Age, for example, below 17 years old, or between 18–24 years old. |
province is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
city is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
genders is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
platforms is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
devices is composed as follows:
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
ages is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
access_source_visit_uv | number | The unique visitors (uv) of the scene. |
# Request Data Example
{
"begin_date" : "20170611",
"end_date" : "20170617"
}
# Return Data Example
{
"ref_date": "20170611",
"visit_uv_new": {
"province": [
{
"id": 31,
"name": "Guangdong Province",
"value": 215
}
],
"city": [
{
"id": 3102,
"name": "Guangzhou",
"value": 78
}
],
"genders": [
{
"id": 1,
"name": "Male",
"value": 2146
}
],
"platforms": [
{
"id": 1,
"name": "iPhone",
"value": 27642
}
],
"devices": [
{
"name": "OPPO R9",
"value": 61
}
],
"ages": [
{
"id": 1,
"name": "17 years old below",
"value": 151
}
]
},
"visit_uv": {
"province": [
{
"id": 31,
"name": "Guangdong Province",
"value": 1341
}
],
"city": [
{
"id": 3102,
"name": "Guangzhou",
"value": 234
}
],
"genders": [
{
"id": 1,
"name": "Male",
"value": 14534
}
],
"platforms": [
{
"id": 1,
"name": "iPhone",
"value": 21750
}
],
"devices": [
{
"name": "OPPO R9",
"value": 617
}
],
"ages": [
{
"id": 1,
"name": "17 years old below",
"value": 3156
}
]
}
}
# Cloud Call
Cloud call is a capability provided by Mini Program·Cloud Base that allows you to call WeChat APIs in a cloud function. It must be used via
wx-server-sdk
in the cloud function.
# API Calling Method
openapi.analysis.getUserPortrait
You need to configure the permissions for the
analysis.getUserPortrait
API viaconfig.json
. Details
# Request Parameters
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
beginDate | string | Yes | Start date, in the format of yyyymmdd. | |
endDate | string | Yes | End date, in the format of yyyymmdd. The gap between the start date and end date can be 0 days, 6 days, or 29 days only, which respectively indicates that the data of the previous day, the recent 7 days, or the recent 30 days is queried. The maximum value is the previous day. |
# Return Value
# Object
JSON data package that is returned
Property | Type | Description |
---|---|---|
refDate | string | Time range, for example, "20170611-20170617" |
visitUvNew | Object | Portrait of new users |
visitUv | Object | Portrait of active users |
visitUvNew is composed as follows
Property | Type | Description |
---|---|---|
index | number | Distribution type |
province | Object | Province, for example, Beijing or Guangdong. |
city | Object | City, for example, Beijing or Guangzhou. |
genders | Object | Gender. Its values include "Male", "Female", and "Unknown". |
platforms | Object | Terminal platform, for example, an iPhone or Android device. |
devices | Object | Device model, for example, iPhone 6 or OPPO R9. |
ages | Object | Age, for example, below 17 years old, or between 18–24 years old. |
province is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
city is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
genders is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
platforms is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
devices is composed as follows:
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
ages is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
visitUv is composed as follows
Property | Type | Description |
---|---|---|
index | number | Distribution type |
province | Object | Province, for example, Beijing or Guangdong. |
city | Object | City, for example, Beijing or Guangzhou. |
genders | Object | Gender. Its values include "Male", "Female", and "Unknown". |
platforms | Object | Terminal platform, for example, an iPhone or Android device. |
devices | Object | Device model, for example, iPhone 6 or OPPO R9. |
ages | Object | Age, for example, below 17 years old, or between 18–24 years old. |
province is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
city is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
genders is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
platforms is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
devices is composed as follows:
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
ages is composed as follows
Property | Type | Description |
---|---|---|
id | number | The ID of the property. |
name | string | The name of the property. It corresponds to the ID. For example, the name returned for the province includes "Guangdong". |
accessSourceVisitUv | number | The unique visitors (uv) of the scene. |
# Request Data Example
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.analysis.getUserPortrait({
beginDate: '20170611',
endDate: '20170617'
})
console.log(result)
return result
} catch (err) {
console.log(err)
return err
}
}
# Return Data Example
{
"refDate": "20170611",
"visitUvNew": {
"province": [
{
"id": 31,
"name": "Guangdong Province",
"value": 215
}
],
"city": [
{
"id": 3102,
"name": "Guangzhou",
"value": 78
}
],
"genders": [
{
"id": 1,
"name": "Male",
"value": 2146
}
],
"platforms": [
{
"id": 1,
"name": "iPhone",
"value": 27642
}
],
"devices": [
{
"name": "OPPO R9",
"value": 61
}
],
"ages": [
{
"id": 1,
"name": "17 years old below",
"value": 151
}
]
},
"visitUv": {
"province": [
{
"id": 31,
"name": "Guangdong Province",
"value": 1341
}
],
"city": [
{
"id": 3102,
"name": "Guangzhou",
"value": 234
}
],
"genders": [
{
"id": 1,
"name": "Male",
"value": 14534
}
],
"platforms": [
{
"id": 1,
"name": "iPhone",
"value": 21750
}
],
"devices": [
{
"name": "OPPO R9",
"value": 617
}
],
"ages": [
{
"id": 1,
"name": "17 years old below",
"value": 3156
}
]
},
"errMsg": "openapi.analysis.getUserPortrait:ok"
}