apiusage-by-time report

The following shows how to generate the apiusage-by-time report using either the Reporting API’s Generate a report POST operation or the Get a cacheable report GET operation. Details about each report’s supported products, metrics, filters, and available data intervals are also available dynamically by running the API’s Get a report type operation, also shown below. See also other available reports.

Report definition

The API usage report allows you to audit which users are using APIs and which APIs are most frequently or heavily used.

This report allows you to configure the aggregation interval for each data record. Available interval values are: MONTH, WEEK, DAY, HOUR.

Business object: account_id

Data available for: 92 days

Required products: EDGECONTROL

Available metrics

Metric Description
Data metrics
bytes The bandwidth used during the request for the associated URL.
requests Requests.
Summary metrics
bytesTotal The total bandwidth used for requests.
requestsTotal Total requests for a given time frame.

Available filters

Filter Type Description
Optional filters
contract_type String The list of accounts and contract type IDs a given user has access to.
endpoint String An API configuration registered with Akamai.
response_class Enumeration A class of HTTP response status codes, from 0xx through 6xx.
0xx: An aborted action on the client side.
1xx: An informational response, like Continue.
2xx: A successful response.
3xx: Success, but a redirect where the thing you want is somewhere else.
4xx: Error, where there’s some problem with the client request.
5xx: Error, where there’s some problem with how the API server responded to the client request.
6xx: Invalid headers, defined by Akamai.
response_code String An HTTP response status code, for example, 201.
response_status Enumeration An indicator of whether the HTTP response resulted in success or an error.
success: Successful HTTP response status.
error: Error HTTP response status.
username String Name of client generating API request.

Sample report

POST /reporting-api/v1/reports/apiusage-by-time/versions/1/report-data{?start,end,interval}

Sample: /reporting-api/v1/reports/apiusage-by-time/versions/1/report-data?start=2020-11-17T10%3A00%3A00Z&end=2020-11-17T14%3A00%3A00Z&interval=HOUR

For other granularity, you need to adjust start and end dates:

Sample with longer interval: /reporting-api/v1/reports/apiusage-by-time/versions/1/report-data?start=2020-07-01&end=2020-11-01&interval=MONTH

Object type: Query

Download schema: report-request-schema.json

Query parameters

Parameter Type Sample Description
Required
start String 2020-11-17T10:00:00Z Specifies the start of the reported period as an ISO–8601 timestamp with optional time zone. The report includes data that matches the start value’s timestamp.
end String 2020-11-17T14:00:00Z Specifies the end of the reported period as an ISO–8601 timestamp with optional time zone. The report excludes any data that matches the end value’s timestamp.
interval Enumeration HOUR The duration of each data record. Available values: MONTH, WEEK, DAY, HOUR.

JSON request members

Member Type Description
objectIds Array Specifies the set of account_id values you want to report on.
objectIds Enumeration As an alternative to an array of ID values, specify all as a string for unfiltered data. Either way, objectIds is required.
metrics Array The set of desired metrics. If omitted, the report includes all available metrics.
filters Map of Arrays Specifies a set of custom filters, with each filter’s name keying an array with each filter’s set of values.

Request body:

{
    "objectIds": [
        "account1",
        "account2",
        "account3"
    ],
    "metrics": [
        "bytes",
        "bytesTotal",
        "requests",
        "requestsTotal"
    ],
    "filters": {
        "contract_type": [
            "1-3CV382",
            "1-6T5ZND"
        ],
        "endpoint": [
            "endpoint/1",
            "endpoint/2"
        ],
        "response_class": [
            "1xx",
            "0xx"
        ],
        "response_code": [
            "201",
            "500"
        ],
        "response_status": [
            "success",
            "error"
        ],
        "username": [
            "username1",
            "username2"
        ]
    }
}

GET /reporting-api/v1/reports/apiusage-by-time/versions/1/report-data{?start,end,interval,objectIds,allObjectIds,metrics,filters}

Sample: /reporting-api/v1/reports/apiusage-by-time/versions/1/report-data?start=2020-11-17T10%3A00%3A00Z&end=2020-11-17T14%3A00%3A00Z&interval=HOUR&objectIds=account1,account2,account3&metrics=bytes%2CbytesTotal&filters=contract_type%3D1-3CV382%2Ccontract_type%3D1-6T5ZND%2Cendpoint%3Dendpoint%2F1%2Cendpoint%3Dendpoint%2F2

Query parameters

Parameter Type Sample Description
Required
start String 2020-11-17T10:00:00Z Specifies the end of the reported period as an ISO–8601 timestamp with optional time zone. The report excludes any data that matches the end value’s timestamp.
end String 2020-11-17T14:00:00Z Specifies if unavailable reports should be shown.
interval Enumeration HOUR The duration of each data record. Available values: MONTH, WEEK, DAY, HOUR.
Optional
allObjectIds Boolean true As an alternative to objectIds, enabling this generates a report that includes all IDs available for the account_id objectType. This parameter is ignored if the request also specifies a set of objectIds.
objectIds String account1,account2,account3 As an alternative to allObjectIds, specifies the set of unique IDs for the account_id objectType you want to report on, formatted as a comma-delimited list.
metrics String bytes,bytesTotal Specifies a comma-separated list of metrics to include in the report, otherwise all metrics if omitted. The set of available metrics depends on the type of report. URL-encode the entire value in the GET request.
filters String contract_type=1–3CV382,contract_type=1–6T5ZND,endpoint=endpoint/1,endpoint=endpoint/2 Specifies criteria to filter the report’s data. The set of available filters depends on the type of report. Separate each filter name and value with an equals (=) character, and separate various name/value pairs with commas (,). To specify more than one filter value, repeat the filter name. See the accompanying example for guidance. URL-encode the entire value in the GET request.

Status 200 application/json

Object type: Report

Download schema: report-response-schema.json

Response body:

{
    "metadata": {
        "name": "apiusage-by-time",
        "version": "1",
        "outputType": "FLAT",
        "groupBy": [
            "startdatetime"
        ],
        "interval": "HOUR",
        "start": "2020-11-17T10:00:00Z",
        "end": "2020-11-17T14:00:00Z",
        "availableDataEnds": null,
        "suggestedRetryTime": null,
        "rowCount": 4,
        "filters": [
            {
                "name": "contract_type",
                "values": [
                    "1-3CV382",
                    "1-6T5ZND"
                ]
            },
            {
                "name": "endpoint",
                "values": [
                    "endpoint/1",
                    "endpoint/2"
                ]
            },
            {
                "name": "response_class",
                "values": [
                    "4xx",
                    "5xx"
                ]
            },
            {
                "name": "response_code",
                "values": [
                    "201",
                    "200"
                ]
            },
            {
                "name": "response_status",
                "values": [
                    "success",
                    "error"
                ]
            },
            {
                "name": "username",
                "values": [
                    "username1",
                    "username2"
                ]
            }
        ],
        "columns": [
            {
                "name": "groupBy",
                "label": "startdatetime"
            },
            {
                "name": "bytes",
                "label": "Bytes"
            },
            {
                "name": "requests",
                "label": "Requests"
            }
        ],
        "objectType": "account_id",
        "objectIds": [
            "account1",
            "account2",
            "account3"
        ]
    },
    "data": [
        {
            "startdatetime": "2020-11-17T10:00:00Z",
            "bytes": "3100",
            "requests": "331"
        },
        {
            "startdatetime": "2020-11-17T11:00:00Z",
            "bytes": "155",
            "requests": "4219"
        },
        {
            "startdatetime": "2020-11-17T12:00:00Z",
            "bytes": "4605",
            "requests": "1819"
        },
        {
            "startdatetime": "2020-11-17T13:00:00Z",
            "bytes": "3734",
            "requests": "451"
        }
    ],
    "summaryStatistics": {
        "bytesTotal": {
            "value": "1051",
            "details": {}
        },
        "requestsTotal": {
            "value": "2756",
            "details": {}
        }
    }
}

Status 200 text/csv

Response Body:

#METADATA_START
name,apiusage-by-time
version,1
source,apiusage-by-time/versions/1
groupBy,startdatetime
start,2020-11-17T10:00:00Z
end,2020-11-17T14:00:00Z
interval,`HOUR`
availableDataEnds,
suggestedRetryTime,
rowCount,4
objectType,account_id
objectIds,account1,account2,account3
contract_type,1-3CV382,1-6T5ZND
endpoint,endpoint/1,endpoint/2
response_class,4xx,5xx
response_code,201,200
response_status,success,error
username,username1,username2
#METADATA_END

#SUMMARYSTATISTICS_START
bytesTotal,1051
requestsTotal,2756
#SUMMARYSTATISTICS_END

#COLUMNS_START
startdatetime,bytes,requests
#COLUMNS_END

#DATA_START
2020-11-17T10:00:00Z,3100,331
2020-11-17T11:00:00Z,155,4219
2020-11-17T12:00:00Z,4605,1819
2020-11-17T13:00:00Z,3734,451
#DATA_END

Get report details

This sample Get a report type operation gets the same information you need to run the apiusage-by-time report as provided in this reference documentation, but available dynamically to your API client application.

GET /reporting-api/v1/reports/apiusage-by-time/versions/1

Status 200 application/json

Object type: ReportType

Download schema: data-row-schema.json

Response body:

{
    "name": "apiusage-by-time",
    "description": "The API usage report allows users to audit which users are using APIs and which APIs are most frequently/heavily used",
    "businessObjectName": "account_id",
    "version": 1,
    "status": "PUBLISHED",
    "deprecated": false,
    "timeBased": true,
    "supportsPagination": false,
    "outputType": "FLAT",
    "requiredProducts": [
        "EDGECONTROL"
    ],
    "requiredRoles": [
        "IDM: API Clients - Admin Access"
    ],
    "available": true,
    "metrics": [
        {
            "name": "bytes",
            "description": "The bandwidth used during the request for the associated URL.",
            "label": "Bytes",
            "unit": "BYTE",
            "summaryStatistic": false
        },
        {
            "name": "bytesTotal",
            "description": "The total bandwidth used for requests.",
            "label": "Total Bytes",
            "unit": "BYTE",
            "summaryStatistic": true
        },
        {
            "name": "requests",
            "description": "Requests.",
            "label": "Requests",
            "unit": "COUNT",
            "summaryStatistic": false
        },
        {
            "name": "requestsTotal",
            "description": "Total requests for a given time frame.",
            "label": "Total Requests",
            "unit": "COUNT",
            "summaryStatistic": true
        }
    ],
    "groupOutlyingValues": {
        "enabled": false
    },
    "groupBy": [
        "startdatetime"
    ],
    "filters": [
        {
            "name": "endpoint",
            "type": "string",
            "description": "An API configuration registered with Akamai.",
            "required": false
        },
        {
            "name": "response_class",
            "type": "enum",
            "description": "A class of HTTP response status codes, from 0xx through 6xx.",
            "values": [
                {
                    "value": "0xx",
                    "description": "An aborted action on the client side."
                },
                {
                    "value": "1xx",
                    "description": "An informational response, like Continue."
                },
                {
                    "value": "2xx",
                    "description": "A successful response. "
                },
                {
                    "value": "3xx",
                    "description": "Success, but a redirect where the thing you want is somewhere else."
                },
                {
                    "value": "4xx",
                    "description": "Error, where there's some problem with the client request."
                },
                {
                    "value": "5xx",
                    "description": "Error, where there's some problem with how the API server responded to the client request."
                },
                {
                    "value": "6xx",
                    "description": "Invalid headers (defined by Akamai)."
                }
            ],
            "required": false
        },
        {
            "name": "username",
            "type": "string",
            "description": "Name of client generating API request.",
            "required": false
        },
        {
            "name": "contract_type",
            "type": "string",
            "description": "The list of accounts and contract type IDs a given user has access to.",
            "required": false
        },
        {
            "name": "response_code",
            "type": "string",
            "description": "An HTTP response status code, for example, 201.",
            "required": false
        },
        {
            "name": "response_status",
            "type": "enum",
            "description": "An indicator of whether the HTTP response resulted in success or an error.",
            "values": [
                {
                    "value": "success",
                    "description": "Successful HTTP response status."
                },
                {
                    "value": "error",
                    "description": "Error HTTP response status."
                }
            ],
            "required": false
        }
    ],
    "intervals": [
        "MONTH",
        "WEEK",
        "DAY",
        "HOUR"
    ],
    "dataRetentionDays": 92,
    "links": [
        {
            "rel": "self",
            "href": "/reporting-reports-executor-api/v1/reports/apiusage-by-time/versions/1"
        },
        {
            "rel": "versions",
            "href": "/reporting-reports-executor-api/v1/reports/apiusage-by-time/versions"
        },
        {
            "rel": "all-reports",
            "href": "/reporting-reports-executor-api/v1/reports"
        },
        {
            "rel": "execute-report",
            "href": "/reporting-reports-executor-api/v1/reports/apiusage-by-time/versions/1/report-data"
        }
    ]
}