The app server calls this API to create a data export task that exports all the data collected and reported by the app.
If you need to import the data collected by Analytics Kit to your own analytics platform or a third-party analytics platform for analysis, you can use this API to export data that has been collected by Analytics Kit.
Protocol | HTTP POST |
|---|---|
Direction | Your callback API server -> Analytics Kit server |
URL | {rootUrl}/analytics/export/raw_data_requests/v2 NOTE: For details about {rootUrl}, please refer to API Access Address. |
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Request header
Parameter | Mandatory | Type | Description |
|---|---|---|---|
x-product-id | Yes | String | Product ID registered in AppGallery Connect. |
x-app-id | Yes | String | App ID registered in AppGallery Connect. |
Authorization | Yes | String | Authentication information. For details, please refer to OAuth 2.0-based Authentication. NOTE: A space character must be added between Bearer and the value of access_token. |
Request body
Parameter | Mandatory | Type | Description |
|---|---|---|---|
date_range | Yes | DateRange | Time range for query. |
file_format | Yes | String | File format. Only the .csv format is supported. |
filters | No | List<Filter> | Attribute or event filter conditions. |
task_name | No | String | Task name. The value can contain a maximum of 255 characters and cannot contain the following special characters: < > " ' [ ] $ % + \ / * ; = ^ , |
DateRange parameters
Parameter | Mandatory | Type | Description |
|---|---|---|---|
start_date | Yes | String | Start date, in the format of yyyy-MM-dd. |
end_date | Yes | String | End date, in the format of yyyy-MM-dd. |
Filter parameters
Parameter | Mandatory | Type | Description |
|---|---|---|---|
name | Yes | String | User attribute name, or ID of a predefined or custom event.
|
values | Yes | String | User attribute values, or name of a predefined or custom event. For details about the values, see the request example. |
POST /analytics/export/raw_data_requests/v2 HTTP/1.1
Content-Type: application/json; charset=UTF-8
Accept: application/json
Authorization: Bearer ***
x-product-id: sample-productid
x-app-id: sample-appid
{
"date_range": {
"start_date": "2021-07-10",
"end_date": "2021-07-17"
},
"file_format": "csv",
"filters": [
{
"name": "location_cd",
"values": [
"CN"
]
},
{
"name": "device_maker",
"values": [
"HUAWEI"
]
},
{
"name": "event_id",
"values": [
"$InstallApp",
"$UninstallApp"
]
},
{
"name": "os_language",
"values": [
"ZH_CN"
]
},
{
"name": "os_ver",
"values": [
"ANDROID:9"
]
},
{
"name": "device_name",
"values": [
"YAL-AL00"
]
}
],
"task_name": "abc123"
} Assume that the status code is 200.
Response header
Parameter | Mandatory | Type | Description |
|---|---|---|---|
Content-Type | Yes | application/json | Response data format. |
Response body
Parameter | Mandatory | Type | Description |
|---|---|---|---|
result_code | Yes | String | Result code. For details, please refer to Result Codes. |
result_msg | Yes | String | Response description. |
request_id | Yes | String | Request ID, which is returned by the API for creating a data export task. |
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Connection: Close
Content-Length: xxxx
{
"result_code":"0",
"result_msg":"success",
"request_id": "c0b41debe8064c54ab200d30907f40c5"
} Status Code | Result Code | Description | Solution |
|---|---|---|---|
200 | 0 | Request successful. | - |
400 | 10020 | Invalid parameter. | Check and correct the parameter value. |
400 | 10008 | Requests are too frequent. | Reduce the frequency of creating data export tasks. |
400 | 10009 | The number of ongoing export tasks of an app reaches 3, which is the upper limit. | Try again after some or all of the ongoing tasks are complete. |
400 | 19910 |
| Try again later. |
400 | 21021 | The query start time is out of the retention period. | The maximum time range for a query is one year from the present time. Enter another query start time. |
400 | 21025 | The data export function is not supported. | Currently, the data export function is only available to invited partners. You can apply for this function by submitting a ticket online. |