Analytics

The tool analyzes API analytics data using natural language queries and displays insights as AI-generated charts and graphs.

The Analytics tool helps you to explore API performance and user trends. You can query dashboards with natural language to view metrics such as usage, latency, status codes, and user data. The tool retrieves data from analytics endpoints and can display results as charts or graphs for easier interpretation.

Tool details and limitations

If your query covers a large time range, the data size might exceed the AI model’s content limit. This condition is called content overflow. When content overflow occurs, the API Agent response indicates the issue. To resolve it, narrow your query or use a smaller time range.

The following operations are supported in the Analytics tool:

Common parameters

The following table shows the parameters that are common to all analytics operations. Specific parameters for individual operations are described in their respective sections.

Table 1. Parameters
Parameter Required Description
userPrompt Yes Natural language query input.
query No HTTP query string filters. Only supports valid IBM® API Connect analytics query filters.
dateCategory No Time unit for relative queries. For example, day and hour.
dateNum No Number of units for relative queries.
startDay No Start date in YYYY-MM-DD format.
startTime No Start time in HH:mm:ss format.
endDay No End date in YYYY-MM-DD format.
endTime No End time in HH:mm:SS format.
timeZone No Override the default time zone.
catalog No Catalog name or ID.
space No Space name or ID.
analyticsService No Analytics service name or ID. The default value is not applicable. If not provided, API Agent detects automatically and defaults to the first configured service for the default sandbox catalog or the target catalog if specified. Provide this parameter only to override the default behavior.
chart Yes Chart type or auto-selection. Accepts only supported values such as bar, line, pie, or auto. The default value is no. Specify yes to allow automatic selection of the chart type.

Get analytics usage

Query usage data for published APIs and their paths. Use this operation to complete the following actions:

  • Count API calls and error rates
  • Measure API popularity
  • Track usage spikes
Table 2. Parameters
Parameter Required Description
operation Yes Property key from the Analytics API dashboard response to use to find the relevant data for the query. Operation must be one of the predefined keys:
  • top_apis_by_calls
  • top_apis_by_errors
  • top_apis_over_time
  • top_api_paths_by_calls
  • top_api_paths_by_errors
  • api_type_calls_over_time
  • top_apis_for_errors_over_time
Note: top_apis_by_calls is the default value.
Example prompts

  • What are our most popular APIs with successful calls this week? Show a chart of the data
  • What are our most popular APIs with error calls?
  • What API had the most 200 family response calls in the last 5 days?
  • What apis have been called between october 10th to october 15th?
  • What are our most popular REST type APIs with successful calls? Show the results in a bar chart
  • What APIs had the highest usage in the last 12 hours?
  • How many error calls were made to the shop API in the last 2 weeks?
  • In the prod space of the acme catalog, which api had the highest usage in this quarter?
  • Tell me about that spike in errors this week
  • '
    What is the distribution of API calls? Show this as a pie chart
  • What is the API errors distribution over the past 7 days? Display as a line chart'
  • What were the most used API paths between 3am and 4pm this morning?
  • What 3 APIs had the highest error rate this month?
  • How many DELETE operations resulted in errors?
  • What are our least popular REST APIs in the prod catalog?
  • What apis are failing today?

Get analytics latency

Query response and latency times for published APIs. Use this operation to complete the following actions:

  • Track response times across time frames
  • Identify minimum, maximum, and average values
  • Find the fastest and slowest APIs
Parameters
No operation-specific parameters. Common parameters apply.
Example prompts

  • What is the average response time of our successful calls this week?
  • What is the average response time of our error calls? Provide a chart of the data
  • What are the response times for the store api?
  • What is the minimum response time of our REST APIs?
  • What is the maximum response time of our successful REST APIs?

Get analytics status

Query HTTP status codes from API calls. Use this operation to complete the following actions:

  • Fetch status data for all or specific APIs
  • Filter results by status codes or families
Parameters
No operation-specific parameters. Common parameters apply.
Example prompts

  • What HTTP statuses did my APIs respond with in the last week?
  • What were the top status codes for the shop API in the last 5 days? Show a pie chart of the data
  • What are the least frequent status codes for the sales API in the commerce catalog in the last 15 days? Show a pie chart of the data

Get analytics users

Query data about users and clients that call APIs. Use this operation to complete the following actions:

  • Track usage patterns by country or time zone
  • Analyze device types
  • Identify clients with high error rates
Table 3. Parameters
Parameter Required Description
operation Yes Property key from the Analytics Users dashboard response to use to find the relevant data for the query. Operation must be one of the predefined types:
  • top_countries
  • top_timezones
  • top_useragents
  • top_client_ips_over_time
  • top_client_ips_errors_over_time
Note: top_client_ips_over_time is the default value.
Example prompts

  • What country had the most successful calls this week?
  • What timezone had the most 200 family response calls?
  • What timezone calls the shop API most?
  • What devices call the most REST APIs?
  • What devices use the most GET operations? Show the result as a pie chart
  • What clients made the most API calls in the last 5 days?
  • What clients had the most API call errors in this week? Show a chart
  • Which countries accessed our APIs during 9am to 5pm yesterday?
  • What were the top timezones accessing our APIs between March 1st and March 15th this year?
  • Show me user agent distribution for API calls made during October 12th this year
  • What client IPs had the most errors between 2pm and 4pm today?
  • Show me user agents that accessed our REST APIs during September last year
  • What timezones accessed our APIs from 15th to 31st last December?
  • Which timezone had the most 400 family response calls in the television catalog?
  • Which clients in the prod space of the acme catalog had the most API call errors in the past week? Show a chart