> ## 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 coverage

> Retrieve line-by-line test coverage data for a file at a specific Git reference or commit SHA



## OpenAPI

````yaml https://api.qlty.sh/openapi.json get /gh/{ownerKeyOrId}/projects/{projectKeyOrId}/coverage/file
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:
  - Bearer: []
tags:
  - name: Service
    description: Service status and API discovery operations
  - 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
  - name: Components
    description: Operations for retrieving components
  - name: Coverage
    description: Operations for retrieving code coverage data
paths:
  /gh/{ownerKeyOrId}/projects/{projectKeyOrId}/coverage/file:
    get:
      tags:
        - Coverage
      summary: Get file coverage
      description: >-
        Retrieve line-by-line test coverage data for a file at a specific Git
        reference or commit SHA
      operationId: getFileCoverage
      parameters:
        - schema:
            type: string
            minLength: 3
            example: acme-corp
            description: Repository owner name (login) or workspace ID
          required: true
          description: Repository owner name (login) or workspace ID
          name: ownerKeyOrId
          in: path
        - schema:
            type: string
            minLength: 3
            example: my-repo
            description: Repository name or project ID
          required: true
          description: Repository name or project ID
          name: projectKeyOrId
          in: path
        - schema:
            type: string
            minLength: 1
            example: refs/heads/main
            description: Git reference (refs/heads/branch, refs/tags/tag) or commit SHA
          required: true
          description: Git reference (refs/heads/branch, refs/tags/tag) or commit SHA
          name: reference
          in: query
        - schema:
            type: string
            minLength: 1
            example: src/index.ts
            description: File path to get coverage for
          required: true
          description: File path to get coverage for
          name: path
          in: query
      responses:
        '200':
          description: Retrieve file coverage for the specified path
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetFileCoverageResponse'
              example:
                tags:
                  - unit
                  - integration
                files:
                  - path: src/index.ts
                    hits:
                      - 1
                      - 0
                      - 1
                      - 1
                      - 0
                    tag: unit
                    coveredLines: 42
                    missedLines: 8
                    omitLines: 10
                    totalLines: 60
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate Limit Exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    GetFileCoverageResponse:
      type: object
      properties:
        tags:
          type: array
          items:
            type: string
          example:
            - unit
            - integration
          description: Available coverage tags
        files:
          type: array
          items:
            $ref: '#/components/schemas/FileCoverage'
      required:
        - tags
        - files
    Error:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              status:
                type: string
                example: '400'
              title:
                type: string
                example: Bad Request
              detail:
                type: string
                example: The request was invalid.
            required:
              - status
              - title
              - detail
      required:
        - errors
    FileCoverage:
      type: object
      properties:
        path:
          type: string
          example: src/index.ts
        hits:
          type: array
          items:
            type: integer
          example:
            - 1
            - 0
            - 1
            - 1
            - 0
          description: Line-by-line hit counts
        tag:
          type: string
          example: unit
          description: Coverage tag (e.g., unit, integration)
        coveredLines:
          type: integer
          example: 42
        missedLines:
          type: integer
          example: 8
        omitLines:
          type: integer
          example: 10
        totalLines:
          type: integer
          example: 60
      required:
        - path
        - hits
        - coveredLines
        - missedLines
        - omitLines
        - totalLines
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      description: Generate an API token at https://qlty.sh/user/settings/tokens

````