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

# Get file metrics

> Retrieve the latest values of all metrics for a file in a Project's default branch



## OpenAPI

````yaml /openapi/qlty-api.json get /gh/{ownerKeyOrId}/projects/{projectKeyOrId}/files
openapi: 3.1.0
info:
  title: Qlty API
  version: 1.0.0
  description: >-
    The Qlty API is organized around REST. It provides predictable,
    resource-oriented URLs, accepts JSON-encoded request bodies, and returns
    JSON-encoded responses.
servers:
  - url: https://api.qlty.sh
security:
  - BearerAuth: []
  - BasicAuth: []
tags:
  - name: User
    description: Operations for the authenticated user
  - name: Workspaces
    description: Operations for managing workspaces
  - name: Projects
    description: Operations for managing projects
  - name: Issues
    description: Operations for managing issues
  - name: Metrics
    description: Operations for retrieving metrics
paths:
  /gh/{ownerKeyOrId}/projects/{projectKeyOrId}/files:
    get:
      tags:
        - Metrics
      summary: Get file metrics
      description: >-
        Retrieve the latest values of all metrics for a file in a Project's
        default branch
      operationId: getFileMetrics
      parameters:
        - name: ownerKeyOrId
          in: path
          required: true
          description: The key or ID of the Workspace that owns the Project
          schema:
            type: string
        - name: projectKeyOrId
          in: path
          required: true
          description: The key or ID of the Project to retrieve metrics for
          schema:
            type: string
        - name: path
          in: query
          required: true
          description: The path to the file for which to retrieve metrics
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetricsResponse'
              example:
                data:
                  - key: complexity
                    name: Cognitive Complexity
                    description: >-
                      Measures the cognitive load required to understand the
                      code
                    category: maintainability
                    value: 8.3
                    inverted: true
                  - key: loc
                    name: Lines of Code
                    description: Total number of lines in this file
                    category: size
                    value: 47
                    inverted: true
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '429':
          $ref: '#/components/responses/TooManyRequestsError'
components:
  schemas:
    MetricsResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Metric'
          description: List of Metric items returned in the response
      required:
        - data
    Metric:
      type: object
      properties:
        key:
          type: string
          description: Unique identifier for the metric
        name:
          type: string
          description: Human-readable name of the metric
        description:
          type: string
          description: Detailed explanation of what the metric measures
        category:
          type: string
          description: >-
            The category of the metric (e.g., maintainability, reliability,
            security)
        value:
          description: The latest value of the metric
          oneOf:
            - type: number
            - type: string
              enum:
                - XS
                - S
                - M
                - L
                - XL
            - type: string
              enum:
                - A
                - B
                - C
                - D
                - F
        inverted:
          type: boolean
          description: >-
            Whether a higher value indicates worse quality (true) or better
            quality (false)
      required:
        - key
        - name
        - category
        - value
        - inverted
    ErrorBody:
      type: object
      properties:
        status:
          type: string
          description: The HTTP status code of the error
        title:
          type: string
          description: A short, human-readable summary of the error
        detail:
          type: string
          description: A detailed explanation of the error
      required:
        - status
  responses:
    BadRequestError:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
    ForbiddenError:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
    NotFoundError:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
    TooManyRequestsError:
      description: Too Many Requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Generate an API token at https://qlty.sh/user/settings/tokens
    BasicAuth:
      type: http
      scheme: basic
      description: Use your API token as the username with an empty password

````