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

# Get Score Trend

> Returns score trend over a time range, bucketed by the requested granularity.



## OpenAPI

````yaml /openapi/em-data-readiness-v2.yaml get /api/data-readiness/metrics/trend
openapi: 3.1.0
info:
  title: EM Data Readiness Service
  description: Data Readiness Service API for managing workflows, metrics, and data quality
  version: 4.3.0-dev1
servers: []
security:
  - BearerAuth: []
tags:
  - name: Health
    description: Service health monitoring. Check service status and version information.
  - name: Root
    description: Root endpoint providing service information and navigation links.
  - name: Configuration
    description: Service configuration endpoints. View current configuration values.
  - name: Workflows
    description: >-
      Workflow configuration and execution management. Create, configure, and
      run data quality workflows including definitions, configurations, runs,
      and tasks.
  - name: Data Assets
    description: >-
      Data catalog entity management. Manage databases, schemas, and tables
      metadata.
  - name: Metrics
    description: >-
      Data quality metrics and scorecards. Calculate scores, view trends, and
      analyze dimensions.
  - name: Violations
    description: >-
      Data quality violation management. View, acknowledge, and remediate
      detected violations.
  - name: Glossary
    description: >-
      Business glossary management. Create, verify, and organize business terms
      and definitions.
paths:
  /api/data-readiness/metrics/trend:
    get:
      tags:
        - Metrics
      summary: Get Score Trend
      description: >-
        Returns score trend over a time range, bucketed by the requested
        granularity.
      operationId: get_metrics_trend
      parameters:
        - name: start_date
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: Start of the time range (ISO 8601)
            title: Start Date
          description: Start of the time range (ISO 8601)
        - name: end_date
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: End of the time range (ISO 8601)
            title: End Date
          description: End of the time range (ISO 8601)
        - name: granularity
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/Granularity'
            description: Time bucket granularity
            default: day
          description: Time bucket granularity
        - name: asset_fqn
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Fully qualified name to scope the trend (e.g.
              service.database.schema.table)
            title: Asset Fqn
          description: >-
            Fully qualified name to scope the trend (e.g.
            service.database.schema.table)
        - name: assessment_type
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by assessment type
            title: Assessment Type
          description: Filter by assessment type
        - name: weight_overrides
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              JSON object mapping dimension UUIDs to weights, e.g. {"<uuid>":
              0.5}
            title: Weight Overrides
          description: 'JSON object mapping dimension UUIDs to weights, e.g. {"<uuid>": 0.5}'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrendResponse'
        '400':
          description: Bad Request - Invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    Granularity:
      type: string
      enum:
        - day
        - week
        - month
      title: Granularity
      description: Time granularity for trend queries.
    TrendResponse:
      properties:
        scope:
          type: string
          title: Scope
          description: Scope level of the trend
          examples:
            - service
        entity:
          $ref: '#/components/schemas/EntityIdentifier'
          description: Entity identifier for the scope
        start_date:
          type: string
          format: date-time
          title: Start Date
          description: Start of the time range (ISO 8601)
          examples:
            - '2024-01-01T00:00:00Z'
        end_date:
          type: string
          format: date-time
          title: End Date
          description: End of the time range (ISO 8601)
          examples:
            - '2024-01-31T23:59:59Z'
        granularity:
          type: string
          title: Granularity
          description: Time bucket granularity
          examples:
            - day
            - week
            - month
        data_points:
          items:
            $ref: '#/components/schemas/TrendDataPoint'
          type: array
          title: Data Points
          description: Trend data points
      type: object
      required:
        - scope
        - entity
        - start_date
        - end_date
        - granularity
        - data_points
      title: TrendResponse
      description: Score trend over a time range.
    ErrorResponse:
      properties:
        error:
          $ref: '#/components/schemas/ErrorInfo'
          description: >-
            Error information object containing code, message, and optional
            details
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Request Id
          description: Request ID for debugging and support
          examples:
            - req_abc123xyz
      type: object
      required:
        - error
      title: ErrorResponse
      description: >-
        Standard error response model for API errors.


        Matches the structure returned by _handle_service_error in
        workflows/routes.py.

        The actual API response format is:

        {
            "error": {
                "code": "ERROR_CODE",
                "message": "Error message",
                "details": {...}
            },
            "request_id": "optional-request-id"
        }
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    EntityIdentifier:
      properties:
        service:
          anyOf:
            - type: string
            - type: 'null'
          title: Service
          description: Service name
          examples:
            - production_db
        database_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Database Name
          description: Database name filter
          examples:
            - analytics
        schema_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Schema Name
          description: Schema name filter
          examples:
            - public
        table_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Table Name
          description: Table name filter
          examples:
            - customers
      type: object
      title: EntityIdentifier
      description: Identifies the scope entity for a scorecard or trend.
    TrendDataPoint:
      properties:
        timestamp:
          type: string
          format: date-time
          title: Timestamp
          description: Timestamp of the data point (ISO 8601)
          examples:
            - '2024-01-15T00:00:00Z'
        overall_score:
          anyOf:
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
            - type: 'null'
          title: Overall Score
          description: Overall score at this time point
          examples:
            - '0.82'
        dimensions:
          items:
            $ref: '#/components/schemas/TrendDimensionPoint'
          type: array
          title: Dimensions
          description: Dimension scores at this time point
      type: object
      required:
        - timestamp
        - overall_score
        - dimensions
      title: TrendDataPoint
      description: Scores at a single time bucket.
    ErrorInfo:
      properties:
        code:
          type: string
          title: Code
          description: >-
            Error code identifier (e.g., 'WORKFLOW_NOT_FOUND',
            'VALIDATION_ERROR')
          examples:
            - WORKFLOW_NOT_FOUND
        message:
          type: string
          title: Message
          description: Human-readable error message
          examples:
            - >-
              Workflow configuration with id
              '123e4567-e89b-12d3-a456-426614174000' not found
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: >-
            Additional error details as a dictionary (flexible structure for
            business logic errors)
          examples:
            - workflow_id: 123e4567-e89b-12d3-a456-426614174000
      type: object
      required:
        - code
        - message
      title: ErrorInfo
      description: >-
        Nested error information object.


        Note: This model uses an untyped dict for `details` to match the
        flexible error

        structure used throughout the service layer (see WorkflowServiceError
        and similar).

        This is distinct from ErrorDetail, which is used for structured
        validation errors.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    TrendDimensionPoint:
      properties:
        dimension_id:
          type: string
          format: uuid
          title: Dimension Id
          description: Unique identifier of the dimension
          examples:
            - 550e8400-e29b-41d4-a716-446655440021
        name:
          type: string
          title: Name
          description: Dimension name
          examples:
            - completeness
        score:
          anyOf:
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
            - type: 'null'
          title: Score
          description: Score at this time point
          examples:
            - '0.85'
        weight:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Weight
          description: Dimension weight
          examples:
            - '0.25'
      type: object
      required:
        - dimension_id
        - name
        - score
        - weight
      title: TrendDimensionPoint
      description: Dimension score at a single time bucket.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Bearer token authentication. Include the token in the Authorization
        header as: `Authorization: Bearer <token>`. The JWT must contain valid
        client_id, and project_id claims for tenant isolation and SDK routing.

````