> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apigene.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get App Insights

> Get comprehensive insights and analytics for a specific application (agent).

This endpoint analyzes all interactions for the given app_name and provides:
- Performance metrics (avg, median, P95, P99 durations)
- Cache effectiveness metrics
- Success/error rate analysis
- Usage patterns and trends
- User engagement metrics
- Response size analysis
- Time-based insights (peak hours, growth trends)
- Health score and recommendations

Parameters:
- app_name: Name of the application/agent to analyze
- current_user: Current user for authentication
- tenant: Tenant database instance

Returns:
- AppInsightsResponse with comprehensive analytics

Raises:
- HTTPException(404): If no interactions found for the app_name
- HTTPException(401): If the user is not authorized



## OpenAPI

````yaml get /api/interaction/insights/{app_name}
openapi: 3.1.0
info:
  title: Apigene
  description: Apigene API
  version: 1.0.0
  contact:
    name: Apigene Support
    url: https://app.apigene.ai
    email: support@apigene.ai
servers:
  - url: https://app.apigene.ai
security:
  - BearerAuth: []
paths:
  /api/interaction/insights/{app_name}:
    get:
      tags:
        - Interaction
      summary: Get App Insights
      description: >-
        Get comprehensive insights and analytics for a specific application
        (agent).


        This endpoint analyzes all interactions for the given app_name and
        provides:

        - Performance metrics (avg, median, P95, P99 durations)

        - Cache effectiveness metrics

        - Success/error rate analysis

        - Usage patterns and trends

        - User engagement metrics

        - Response size analysis

        - Time-based insights (peak hours, growth trends)

        - Health score and recommendations


        Parameters:

        - app_name: Name of the application/agent to analyze

        - current_user: Current user for authentication

        - tenant: Tenant database instance


        Returns:

        - AppInsightsResponse with comprehensive analytics


        Raises:

        - HTTPException(404): If no interactions found for the app_name

        - HTTPException(401): If the user is not authorized
      operationId: get_app_insights
      parameters:
        - name: app_name
          in: path
          required: true
          schema:
            type: string
            title: App Name
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppInsightsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    AppInsightsResponse:
      properties:
        app_name:
          type: string
          title: App Name
        total_interactions:
          type: integer
          title: Total Interactions
        date_range:
          additionalProperties:
            anyOf:
              - type: string
              - type: 'null'
          type: object
          title: Date Range
        performance:
          $ref: '#/components/schemas/PerformanceMetrics'
        cache:
          $ref: '#/components/schemas/CacheMetrics'
        success_metrics:
          $ref: '#/components/schemas/SuccessMetrics'
        usage:
          $ref: '#/components/schemas/UsageMetrics'
        users:
          $ref: '#/components/schemas/UserMetrics'
        response_sizes:
          $ref: '#/components/schemas/ResponseSizeMetrics'
        time_insights:
          $ref: '#/components/schemas/TimeInsights'
        health_score:
          type: number
          title: Health Score
        top_insights:
          items:
            type: string
          type: array
          title: Top Insights
        recommendations:
          items:
            type: string
          type: array
          title: Recommendations
      type: object
      required:
        - app_name
        - total_interactions
        - date_range
        - performance
        - cache
        - success_metrics
        - usage
        - users
        - response_sizes
        - time_insights
        - health_score
        - top_insights
        - recommendations
      title: AppInsightsResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PerformanceMetrics:
      properties:
        avg_duration:
          type: number
          title: Avg Duration
        median_duration:
          type: number
          title: Median Duration
        p95_duration:
          type: number
          title: P95 Duration
        p99_duration:
          type: number
          title: P99 Duration
        slowest_operations:
          items:
            $ref: '#/components/schemas/OperationMetric'
          type: array
          title: Slowest Operations
        fastest_operations:
          items:
            $ref: '#/components/schemas/OperationMetric'
          type: array
          title: Fastest Operations
        duration_distribution:
          additionalProperties:
            type: integer
          type: object
          title: Duration Distribution
      type: object
      required:
        - avg_duration
        - median_duration
        - p95_duration
        - p99_duration
        - slowest_operations
        - fastest_operations
        - duration_distribution
      title: PerformanceMetrics
    CacheMetrics:
      properties:
        hit_rate:
          type: number
          title: Hit Rate
        total_hits:
          type: integer
          title: Total Hits
        total_misses:
          type: integer
          title: Total Misses
        avg_duration_cached:
          type: number
          title: Avg Duration Cached
        avg_duration_uncached:
          type: number
          title: Avg Duration Uncached
        performance_improvement:
          type: number
          title: Performance Improvement
      type: object
      required:
        - hit_rate
        - total_hits
        - total_misses
        - avg_duration_cached
        - avg_duration_uncached
        - performance_improvement
      title: CacheMetrics
    SuccessMetrics:
      properties:
        success_rate:
          type: number
          title: Success Rate
        error_rate:
          type: number
          title: Error Rate
        status_code_breakdown:
          additionalProperties:
            type: integer
          type: object
          title: Status Code Breakdown
        failed_operations:
          items:
            $ref: '#/components/schemas/OperationMetric'
          type: array
          title: Failed Operations
      type: object
      required:
        - success_rate
        - error_rate
        - status_code_breakdown
        - failed_operations
      title: SuccessMetrics
    UsageMetrics:
      properties:
        top_operations:
          items:
            $ref: '#/components/schemas/OperationMetric'
          type: array
          title: Top Operations
        api_distribution:
          additionalProperties:
            type: integer
          type: object
          title: Api Distribution
        usage_trends:
          additionalProperties:
            type: integer
          type: object
          title: Usage Trends
        client_source_distribution:
          additionalProperties:
            type: integer
          type: object
          title: Client Source Distribution
          description: >-
            Distribution of interactions by client source (e.g., Cursor, Claude,
            VS Code)
      type: object
      required:
        - top_operations
        - api_distribution
        - usage_trends
      title: UsageMetrics
    UserMetrics:
      properties:
        total_unique_users:
          type: integer
          title: Total Unique Users
        most_active_users:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Most Active Users
        avg_interactions_per_user:
          type: number
          title: Avg Interactions Per User
      type: object
      required:
        - total_unique_users
        - most_active_users
        - avg_interactions_per_user
      title: UserMetrics
    ResponseSizeMetrics:
      properties:
        avg_raw_size:
          type: number
          title: Avg Raw Size
        avg_processed_size:
          type: number
          title: Avg Processed Size
        total_raw_size:
          type: number
          title: Total Raw Size
        total_processed_size:
          type: number
          title: Total Processed Size
        per_api_breakdown:
          additionalProperties:
            additionalProperties:
              type: number
            type: object
          type: object
          title: Per Api Breakdown
        largest_responses:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Largest Responses
        efficiency_ratio:
          type: number
          title: Efficiency Ratio
      type: object
      required:
        - avg_raw_size
        - avg_processed_size
        - total_raw_size
        - total_processed_size
        - per_api_breakdown
        - largest_responses
        - efficiency_ratio
      title: ResponseSizeMetrics
    TimeInsights:
      properties:
        peak_hours:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Peak Hours
        peak_days:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Peak Days
        growth_trend:
          additionalProperties: true
          type: object
          title: Growth Trend
        recent_activity:
          additionalProperties:
            type: integer
          type: object
          title: Recent Activity
      type: object
      required:
        - peak_hours
        - peak_days
        - growth_trend
        - recent_activity
      title: TimeInsights
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    OperationMetric:
      properties:
        action_name:
          type: string
          title: Action Name
        count:
          type: integer
          title: Count
        avg_duration:
          type: number
          title: Avg Duration
        success_rate:
          type: number
          title: Success Rate
        error_count:
          type: integer
          title: Error Count
      type: object
      required:
        - action_name
        - count
        - avg_duration
        - success_rate
        - error_count
      title: OperationMetric
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Authorization header using the Bearer scheme. Example:
        'Authorization: Bearer {token}'

````