Exporting CSV reports from the API

The Skytap API can export .CSV usage reports, auditing reports, and resource reports. For specific URIs and report parameters, see the detailed documentation associated with each resource.

You must be a Skytap administrator to request usage and auditing reports.

The general process for exporting a report is the same across resources:

  1. Make a POST request to the report resource URI. Some reports will have mandatory or optional report parameters (for example, results_format, start_date, and end_date). To request the report be emailed to you when it’s complete, include notify_by_email in the request body or URL.

    POST https://cloud.skytap.com/reports
       Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
       Accept: application/json
       Content-Type: application/json
       {
           "results_format": "csv",
           "start_date": "2015/01/01 16:00:00 -0700",
           "end_date": "2015/03/01 13:22:29 -0700",
           "notify_by_email": true
       }
    {
           "id": "123456",
           "ready": false,
           "results_format": "csv",
           "resource_type": "svms",
           "group_by": "user",
           "region": "all",
           "aggregate_by": "month",
           "start_date": "2015/01/01 16:00:00 -0700",
           "end_date": "2015/03/01 13:22:29 -0700",
           "created_at": "2015/03/20 13:22:29 -0700",
           "time_zone": "Pacific Time (US & Canada)",
           "notify_by_email": true,
           "email": "user@internet.net"
       }
  2. If you want to download the report through the API, follow this multi-step process:

    1. Parse the response body from the POST request to locate the report ID.
    2. Poll the report until the ready field equals true.

      GET https://cloud.skytap.com/reports/123456.json
      {
             "id": "123456",
             "ready": true,
             "results_format": "csv",
             "resource_type": "svms",
             "group_by": "user",
             "region": "all",
             "aggregate_by": "month",
             "start_date": "2015/01/01 16:00:00 -0700",
             "end_date": "2015/03/01 13:22:29 -0700",
             "created_at": "2015/03/20 13:22:29 -0700",
             "time_zone": "Pacific Time (US & Canada)",
             "url": "https://cloud.skytap.com/reports/123456.csv",
             "notify_by_email": true,
             "email": "user@internet.net"
         }
    3. When "ready": true,, you can access the report at the report URL listed in the response body. In some cases, you may need to append .csv to the report URL.

      Sample request:

       GET https://cloud.skytap.com/reports/123456.csv