目录

Creating a Data Export Task

Overview

The app server calls this API to create a data export task that exports all the data collected and reported by the app.

Scenario

If you need to import the data collected by HUAWEI Analytics Kit to your own analytics platform or a third-party analytics platform for analysis, you can use this API to export data collected by HUAWEI Analytics Kit.

Restrictions

Interface Prototype

Protocol

HTTP POST

Direction

HUAWEI Analytics Kit server -> Developer callback API server

URL

POST https://<URI>/analytics/export/raw_data_requests/v2

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

Request

Table1 Request body
ParameterMandatory/OptionalTypeDescription

date_range

Mandatory

DateRange

Time range for query.

file_format

Mandatory

String

File format. Only the csv format is supported.

filters

Optional

List<Filter>

Attribute filters.

Table2 DateRange
ParameterMandatory/OptionalTypeDescription

start_date

Mandatory

string

Start date, in format of yyyy-MM-dd.

end_date

Mandatory

string

End date, in format of yyyy-MM-dd.

Table3 Filter
ParameterMandatory/OptionalTypeDescription

name

Mandatory

string

Filter key, which is the user attribute name.

values

Mandatory

string

Filter value, which is the user attribute value.

Response

Table4 Response body
ParameterTypeDescription

result_code

String

Result code. For details, please refer to Result Codes.

result_msg

String

Response description.

Response Example

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Connection:  Close
  4. Content-Length: xxxx                      
  5. {
  6.  "result_code":"0",
  7.  "result_msg":"success",
  8. }

Result Codes

Status CodeResult CodeResponse CodeDescriptionSuggestion

200

0

Success

Request succeeded.

-

400

10020

invalidParameter

Invalid parameter.

Check and correct the parameter value.

400

10008

tooFrequentRequest

API requests are too frequent.

Display a message indicating that data export creation requests are excessively frequent and asking the user to try again later.

400

10009

tooManyTask

The number of ongoing data export tasks of an app exceeds the upper limit (3).

Display a message prompting the user to wait until other tasks are complete and try again later.

Call Example

  1. POST /analytics/export/raw_data_requests/v2 HTTP/1.1
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: xxxx
  4. Accept: application/json
  5. Authorization: Bearer 78C2395236BBF4262CAE4F1172E327C2929AD63EAA0395961A49DEBC3B6F8339
  6. x-product-id: sample-productid
  7. x-app-id: sample-appid
  8. {
  9.    "data_range": {
  10.        "start_date": "2020-03-10",
  11.        "end_date": "2020-03-17"
  12.    },
  13.    "file_format": "csv",
  14.    "filters": [
  15.        {
  16.            "name": "model",
  17.            "values": [
  18.                "TL-00",
  19.                "MTA-00"
  20.            ]
  21.        }
  22.    ],
  23.    "fields": [
  24.        "eventId"
  25.    ],
  26.    "field_map": [
  27.        {
  28.            "origin": "eventId",
  29.            "target": "eventName"
  30.        }
  31.    ]
  32. }