Contact Free trial Login

Reviewing Analytics Event API

API Manager gathers analytics data for each API you manage. You can create charts that query and display event data. Using the Analytics Event API you can create reports that query raw event data and expose it through an API endpoint. Reports and charts you create present data by environment.

You can create reports that span multiple APIs, or create different reports for the same API. The Analytics Event API provides a one month retention policy for events and, with a data availability delay of up to 10 minutes.

The Analytics Event API enforces a usage limit of 10 requests/minute, with a maximum of 20,000 events per request. Request rates higher than 10 request/minutes will be throttled.


  • Event API is designed to create ad hoc reports, and it is not intended as a data export tool. If you need to export data, keep in mind the following recommendations:

    • Do not allow calls to overlap time intervals.

    • Retrieve all the data that you need in a single request. Do not repeat the same request for every API that you have.

    • Do not call Event API more than once per minute.

    • For organizations whose API usage exceed 20 000 calls per 10 minutes, consider a different way for data export. API gateway can be configured to send usage events directly to monitoring systems.

  • Event API is not meant for data synchronization.
    If you are interested in data sync for events with an external system, refer to Analytics Event Forwarding for more information.

Creating a Report

The following procedure describes how to create a report to find the API events that, for example, resulted in a policy violation. Suppose you want to find any events that were rejected because of policy violations, such as rate limiting or IP blacklisting. In step 5, you select Violated Policy Name in Fields to filter the data in this manner.

  1. In API Manager > Analytics > Manage Reports, click New to create a new report.

  2. In Create Report, select a data source, range, and format.

  3. In Fields, select Violated Policy Name.

    A URL appears that you can use to see the report after you save it. The date that data becomes available for the data source you specified appears.

  4. Save the report.

    When the report becomes available, go to the URL to view it.

Running a Report in the Browser

The following steps show you how to run a report. API Analytics lists the starting point for when data is available for the API, including a warning message if no data is available for the API.

On the Manage Reports page, click Run for the specified report.


After the report runs, the CSV or JSON file contains all of the raw analytics data for the parameters you specified in the report.

Using curl to View Report Information

You get the value of $TOKEN by running the curl command in this procedure. The command gets the access_token JSON property of this response.

The authorization header has the form: Authorization: Bearer {$TOKEN.access_token}

The use of the jq command-line JSON processor is one possible solution for obtaining the access token value. Download and install this application or one with the same functionality for this procedure.

To view report information programatically:

  1. Open a new terminal window and execute the following command:

    TOKEN=$(curl -s -d "username=<YOUR-USERNAME>&password=<YOUR-PASSWORD>" | jq -r .access_token)
  2. This command sends a request to the authentication servers of the Anypoint Platform and, if the request is successful, returns an access token that’s stored in the $TOKEN variable. The value of this variable is displayed below:

     "access_token": "54545454-5454-5454-5454-545454545454",
     "token_type": "Bearer",
     "redirectUrl": "/accounts/#/cs/profile/home"
  3. After the access token has been received, it must be appended to the Authorization header in the request to the Analytics Reporting API endpoint for your report. To make a request to this endpoint, copy it from the Manage Reports page in the Analytics dashboard. Using the $TOKEN variable from the previous step, include it in the next request as shown below:

    curl -H "Authorization: Bearer $TOKEN" "<ORGANIZATION_ID>/events?format=csv&startDate=2016-01-01&endDate=2016-12-31&fields=Application%20Name.Client%20IP.Resource%20Path > output.csv"
  4. If the request is successful, the response includes a CSV file (as requested) that downloads as a file with the specified name (output.csv) in the directory where the curl request was made.

An example shell script combining the two curl commands and which displays values in the command prompt window is:

TOKEN=$(curl -s -d "username=myusername&password=mypassword" | jq -r .access_token)
curl -H "Authorization: Bearer $TOKEN" ""

Example output for this command is:

"Application Name","Client IP","Resource Path",Timestamp,"API ID","API Version ID","API Name","API Version Name"
"Las Vegas T-Shirt serviceLas Vegas T-Shirt serviceLas Vegas",,/,2016-10-03T04:27:02.072Z,61460,63811,"test api contracts",1
"Las Vegas T-Shirt serviceLas Vegas T-Shirt serviceLas Vegas",,/,2016-10-03T05:03:38.774Z,61460,63811,"test api contracts",1

Supporting Environments

For organizations that have enabled environments, API events queried using the approach described above will belong exclusively to the Unclassified" environment. To request events for APIs in a specific environment, select the environment in the environment selector and create the report that you want to run. Reports are stored per-environment, so different reports will exist in different environments. Copy the report URL from the UI, and note that in addition to the Organization ID, the URL also includes /environment/{Environment ID}. Anypoint Platform assigns the unique and immutable Organization ID and Environment IDs at organization and environment creation times.

The addition of the Environment ID to the report URL is all you need to access events in the specified environment. API IDs are different in different environments: An API’s ID in QA will be different from its ID in Production, for example.

Reviewing Command Options

The following options can be added to the curl command:

Option Description


Comma-delimited list of API IDs to include in a query. Omit or specify all or * to include all APIs.

Type: string
Required: no
Example: appIds=42,54


Comma-delimited list of API version IDs to include in query. Omit or specify all or * to include all API versions. Ignored if no value was specified for API IDs.

Type: string
Required: no
Example: apiVersionIds=42,54


The duration over which the report should return data. Consists of an integer number denoting quantity and a single-letter suffix denoting units.

Suffix is one of:

  • d: Days

  • h: Hours

  • m: Minutes

  • s: Seconds

To cover a duration of one week, specify 7d as the duration. To cover half a minute, specify 30s.

Type: string
Required: no
Example: duration=45m


Fields to include in the report. Required for CSV output and optional for JSON output. The list of fields can be comma- or period-delimited. Use %20 for spaces. You can use any value in [Data Fields for Reports]. Timestamp, API Name, API ID, API Version, API Version ID are always included.

Type: string
Required: no
Example: fields=Hardware%20Platform.Client%20IP.Resource%20Path


Determines the serialization format of the returned data. Either csv or json.

Type: string
Required: yes
Example: format=csv


Maximum number of events to return. Default value is 20000.+

Type: integer
Required: no
Example: maxResults=3


Starting date and time, as described by[ISO Date Time Parser].

Type: date
Required: no
Example: startDate=2016-01-01T08:15:30-05:00


Ending date and time, as described by

Type: date
Required: no
Example: endDate=2016-11-10


Filter results by event resource path, used when reporting against a particular REST resource root.

Type: string
Required: no
Example: pathPrefix=/products/electronics

Reviewing Data Fields for Reports

Your report can query data for one, many, or all of the available data fields. These fields are explained in the table below.

Data Field Name Description


Client ID associated with the incoming API request.

Application Name

Name of the application making the API request (only available when a client ID is passed with the request).


Browser type associated with the incoming API request.


The city from which the API request originated (inferred by the IP address of the client).

Client IP

IP address of the client making the API request.


The continent from which the API request originated (inferred by the IP address of the client).


The country from which the API request originated (inferred by the IP address of the client).

Hardware Platform

The hardware type of the client making the request (such as Mobile, Tablet, Desktop, etc.).

Message ID

Message ID value.

OS Family

The client OS type: Mac OS X, iOS, Windows, Linux.

OS Major Version

Operating system major version.

OS Minor Version

Operating system minor version.

OS Version

Operating system version.

Postal Code

The postal code from which the API request originated (inferred by the IP address of the client).

Request Outcome

Indicates whether a request was successful or resulted in a policy violation.

Request Size

The size (in bytes) of the incoming client request.

Resource Path

The path of the client request.

Response Size

The size in bytes of the API response. See note below.

Response Time

The processing time of the API request.

Status Code

The HTTP status code of the response.


The time zone from which the API request originated (inferred by the IP address of the client).

User Agent Name

The complete user agent string for the incoming client request.

User Agent Version

The version of the user agent string for the incoming client request.


The REST verb associated with the API client request (GET, POST, PATCH, etc.).

Violated Policy Name

The name of the policy violated by the API request (if any).

If the Content-Length header is present, the Response Size is set to that value. If the Content-Length header is not present and the payload is a String, Analytics calculates the length of the String and reports that value. If the Content-Length header is not present and the payload is not a String, Analytics reports the response size as -1. For example, if the output returned is a DataWeave stream and the Content-Length header is not present, Analytics doesn’t report a response size because the value is not a String. However if your application performs a String conversion, the response size is listed.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.