google_drive_export
POST /API/v2/google_drive_export
Exports report data to Google Drive
. Data is restricted by query parameters passed in POST arguments. See example.
Request body¶
slicer_name
: the name of the report.project_name
: the name of the project.token
: the authorization token (see Authentication).split_by
: an array of the key fields to split data by in the form of ["key_field1",...].include_mappings
(optional): defines whether key field value mappings are returned by the API request. The default value is 1 (mappings are returned) if only 1 key field is used in thesplit_by
POST argument. The default value is 0 (mappings are not returned) if 2 or more key fields are used in thesplit_by
POST argument.include_total
(optional): defines whether to display Total values in the exported file. Possible values: (0 - don't display Total values in the exported file, 1 - display Total values in the exported file). The default value is 0.add_keys
: the array of key fields to add. Format: ["key_field1", ... ].email
: an array of 1 - 20 email addresses in the form of ["email_address1",...].-
start_date
,end_date
: the start/end of the date range to gather data for. Supported formats:- Absolute dates: YYYY-MM-DD.
-
Relative dates:
- today, yesterday
- - N d and - N days for the number of days since the current date, where N - any positive integer or zero.
- - N m and - N months for the number of months since the current date, where N - any positive integer or zero.
- - N m_first, - N months_first, - N m_last, and - N months_last for the first and the last day of the specified month correspondingly, where N - any positive integer or zero.
- -N d_m_first, where N - any positive integer. The first day of the month matches the following date:
current date
+ N days. Examples for the current date of 2021-10-12:
Template Resulting start_date -15d_m_first
2021-09-01 0d_m_first
2021-10-01 15d_m_first
2021-10-01 -100d_m_first
2021-07-01 30d_m_first
2021-11-01
-
timezone
(optional):time zone UTC offset in hours. Format: N,where N- any integer in the range of -12 <= N <= +12. -
filters
(optional): an array with the following structure:- "
name
": "key_field
", - "
case_insensitive
": (optional), defines whether search should becase-insensitive
. Possible values: (1 -case-insensitive
, 0 -case-sensitive
). The default value is 0. - "
search_mappings
": (optional), defines whether the search should be performed inmappings
. Possible values: (1 - search should be performed in bothkey field values
and theirmappings
, 0 - search should be performed inkey field values
only). The default value is 0. - "
value
": ["value1
", ... ], - "
match
": "equals|not equals|contains|not contains|beginswith|endswith|not beginswith|not endswith"
where the value of the "
value
" field should be an array.If "
search_mappings
" is set to 1, the search will be performed for both specified key field values and their mappings (descriptions). For example, if you have thecreative_id
key field with some value of "1
" and its mapping of "First Creative
", you can search for it as follows:{"name": "creative_id", "value": ["First Creative"],"match":"equals", "search_mappings": 1}
OR
{"name": "creative_id", "value": [1],"match": "equals"}
Search results will be fully identical.
You can even use a partial matching, like {"name":"creative_id","value": ["Creative"],"match":" contains", "search_mappings": 1}, but please note that if you use a too short search string (1 - 2 characters long), it may take significant time to look up all matching records.
- "
-
data_filters
(optional): an array with the following structure: -
filter_template
(optional): a string template defining priorities for filters specified in thefilters
POST argument. Can contain the following elements:- opening/closing parentheses
- OR/AND operators
- "x" character as a placeholder for filters
Example: "x OR (x AND x)".
Filters from the
filters
POST argument in the specified order are substituted instead of x. -
data_filter_template
(optional): a string template defining priorities for filters specified in the data_filters POST argument. Can contain the following elements:- opening/closing parentheses
- OR/AND operators
- "x" character as a placeholder for filters
Example: "x OR (x AND x)".
Filters from the
data_filters
POST argument in the specified order are substituted instead of x. -
order_by (optional): defines sorting rules. A single record or an array of records with the following structure:
- "
name
": "field", the name of the key or data field to sort the results by. Note that this field can be any key field, specified in thesplit_by
POST argument, or one of the data fields specified by thedata_fields
POST argument (or any of the data fields if thedata_fields
POST argument is not specified). The default value is the first column with enabled percent. - "
mapping
": defines whether to sort bykey field ID
or bykey field mapping
. Possible values: (0 - sort bykey field ID
, 1 - sort bykey field mapping
). The default value is 0. - "
direction
": sort in the ascending or descending order, eitherASC
orDESC
. The default value isDESC
.
- "
-
data_fields
(optional): the array of data fields to be returned in the form of [ "data_field1", .... ]. If it is not defined (by default), data fields will not be returned. To receive the details of all data fields available for your particular report use the info method. drive_folder
(optional): Any folder in your Google Drive. Could be a shared folder as well. You can also use subfolders, e.g: Folder/SubFolder/SubSubFolder. Might be left empty.drive_file_name
: Any filename supported by Google Drive. It is expected that filename ends with .xlsx.can_write
: Gives edit rights for users that you share the file with. Possible values: true and false. The default value is true.
Response¶
status
: the status of the request.success
, if the request was processed successfully, or error code, if any error occurred. If the status is notsuccess**
, then the response contains thestatus
andreason
fields only. Possible values:success
: the request was processed successfully.bad_request
: invalid request parameters, please see thereason
field for more details.timeout
: the request took too long to complete.access_error
: the user doesn't have access to the specified project/slicer, or a wrong token was used.internal_error
: the request failed due to an unknown problem.
reason
: user-friendly description of the occurred error. This field is displayed for failed requests only.Google Sheets file
: a file with exported report data (column headers and data rows). Maximum 300000 data rows.
Example¶
Export to Google Sheets a Report on all Campaigns, containing the "100" string, displayed in California and Texas to users of the Opera internet browser for the period from March 01, 2012 to March 03, 2012.
Path:
https://uslicer.iponweb.com/API/v2/google_drive_export
Request
{
"slicer_name": "Traffic Demo",
"project_name": "demo",
"token": "<token>",
"split_by": "campaign_id",
"start_date": "2011-02-16",
"end_date": "2011-02-18",
"email": [
"jsmith@gmail.com"
],
"filters" : [
{
"name": "geo_region",
"value": [
"California", "Texas"
],
"match": "equals"
},
{
"name": "campaign_id",
"value": [
"100"
],
"match": "contains"
},
{
"name" : "browser",
"value": [
"Opera"
],
"match" : "equals"
}
]
}
curl --data '{
"slicer_name": "Traffic Demo",
"project_name": "demo",
"token": "<token>",
"split_by": "campaign_id",
"start_date": "2012-03-01",
"end_date": "2012-03-03",
"email": [
"jsmith@gmail.com"
],
"filters": [
{
"name": "geo_region",
"value":["California", "Texas"],
"match": "equals"
},
{
"name": "campaign_id",
"value" :[
"100"
],
"match": "contains"
},
{
"name": "browser",
"value":[
"Opera"
],
"match": "equals"
}
]
}'\
-H "Content-Type: application/json" \
"https://uslicer.iponweb.com/API/v2/google_drive_export"
Response
{
"status" : "success"
}