Skip to main content

How to Generate Report Downloads

Report downloads are CSV or XML files generated from the report.

Generating and getting Report Download files using API is done in 3 steps:

Step 1: Create Report Download

Use the createReportDownload mutation to create a download and start the generation process.

As an input to define which report you want to generate a download from you can pass either reportId or fields that describe the report: crawlId, reportTemplateCode, reportTypeCode, and optionally a segmentId. For a list of available report template codes please refer to the Report templates section of this documentation.

By default generated file will have all default report metrics. To select only a specific set of metrics pass an array of selected metric codes in the selectedMetrics property.

To get the filtered set of report rows use the filter property which can take any JSONObject and works for all datasources, but is only validated after mutation is submitted. There are also strongly typed filter properties for each of the datasources that you can use instead of a generic filter. Explore CreateReportDownloadInput to see all available fields. To know which datasource filter to use, you can get datasource code from a report or report template query. For help with building filter queries go to filtering overview page.

mutation CreateReportDownload($input: CreateReportDownloadInput!) {
createReportDownload(input: $input) {
reportDownload {
...ReportDownloadDetails
}
}
}

fragment ReportDownloadDetails on ReportDownload {
id
status
outputType
# ...other fields you want to retrieve
}

Try in explorer

Step 2: Wait for Report Download to generate

At first Report Download status will be Generating. When it's ready it'll change to Generated.

Depending on the size of the data in the report it may take from a few seconds to a few minutes to generate the file.

Step 3: Get the Report Download

Use the node query to get the created Report Download

query GetReportDownload {
node(id: "TjAxNFJlcG9ydERvd25sb2FkNzU4Njg3") {
... on ReportDownload {
status
fileURL
crawl{
id
}
}
}
}

Try in explorer

Use the getCrawl query to get all the Report Downloads for a crawl.

query GetReportDownloads {
getCrawl(id: 1234) {
reportDownloads(
first: 5
) {
id
status
fileURL
}
}
}

Try in explorer

The response contains authenticated links to download the requested files. The links are valid for 7 days from the time they are generated, so data should be downloaded promptly.