Codecov Comparison API

The Comparison API from Codecov — 6 operation(s) for comparison.

Operations 6

GET /{service}/{owner_username}/repos/{repo_name}/compare/ Comparison #
GET /{service}/{owner_username}/repos/{repo_name}/compare/components Component comparison #
GET /{service}/{owner_username}/repos/{repo_name}/compare/file/{file_path} File comparison #
GET /{service}/{owner_username}/repos/{repo_name}/compare/flags Flag comparison #
GET /{service}/{owner_username}/repos/{repo_name}/compare/impacted_files Impacted files comparison #
GET /{service}/{owner_username}/repos/{repo_name}/compare/segments/{file_path} Segmented file comparison #

Specifications

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/codecov:codecov-comparison-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

codecov-comparison-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Codecov Comparison API
  version: 2.0.0
  description: Public Codecov API
servers:
- url: https://api.codecov.io/api/v2/
tags:
- name: Comparison
paths:
  /{service}/{owner_username}/repos/{repo_name}/compare/:
    get:
      operationId: repos_compare_retrieve
      description: Returns a comparison for either a pair of commits or a pull
      summary: Comparison
      parameters:
      - in: query
        name: base
        schema:
          type: string
        description: base commit SHA (`head` also required)
      - in: query
        name: head
        schema:
          type: string
        description: head commit SHA (`base` also required)
      - in: path
        name: owner_username
        schema:
          type: string
        description: username from service provider
        required: true
      - in: query
        name: pullid
        schema:
          type: integer
        description: pull ID on which to perform the comparison (alternative to specifying `base` and `head`)
      - in: path
        name: repo_name
        schema:
          type: string
        description: repository name
        required: true
      - in: path
        name: service
        schema:
          type: string
          enum:
          - bitbucket
          - bitbucket_server
          - github
          - github_enterprise
          - gitlab
          - gitlab_enterprise
        description: Git hosting service provider
        required: true
      tags:
      - Comparison
      security:
      - tokenAuth: []
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Comparison'
          description: ''
  /{service}/{owner_username}/repos/{repo_name}/compare/components:
    get:
      operationId: repos_compare_components_retrieve
      summary: Component comparison
      parameters:
      - in: query
        name: base
        schema:
          type: string
        description: base commit SHA (`head` also required)
      - in: query
        name: head
        schema:
          type: string
        description: head commit SHA (`base` also required)
      - in: path
        name: owner_username
        schema:
          type: string
        description: username from service provider
        required: true
      - in: query
        name: pullid
        schema:
          type: integer
        description: pull ID on which to perform the comparison (alternative to specifying `base` and `head`)
      - in: path
        name: repo_name
        schema:
          type: string
        description: repository name
        required: true
      - in: path
        name: service
        schema:
          type: string
          enum:
          - bitbucket
          - bitbucket_server
          - github
          - github_enterprise
          - gitlab
          - gitlab_enterprise
        description: Git hosting service provider
        required: true
      tags:
      - Comparison
      security:
      - tokenAuth: []
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentComparison'
          description: ''
  /{service}/{owner_username}/repos/{repo_name}/compare/file/{file_path}:
    get:
      operationId: repos_compare_file_retrieve
      description: Returns a comparison for a specific file path
      summary: File comparison
      parameters:
      - in: query
        name: base
        schema:
          type: string
        description: base commit SHA (`head` also required)
      - in: path
        name: file_path
        schema:
          type: string
        description: file path
        required: true
      - in: query
        name: head
        schema:
          type: string
        description: head commit SHA (`base` also required)
      - in: path
        name: owner_username
        schema:
          type: string
        description: username from service provider
        required: true
      - in: query
        name: pullid
        schema:
          type: integer
        description: pull ID on which to perform the comparison (alternative to specifying `base` and `head`)
      - in: path
        name: repo_name
        schema:
          type: string
        description: repository name
        required: true
      - in: path
        name: service
        schema:
          type: string
          enum:
          - bitbucket
          - bitbucket_server
          - github
          - github_enterprise
          - gitlab
          - gitlab_enterprise
        description: Git hosting service provider
        required: true
      tags:
      - Comparison
      security:
      - tokenAuth: []
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileComparison'
          description: ''
  /{service}/{owner_username}/repos/{repo_name}/compare/flags:
    get:
      operationId: repos_compare_flags_retrieve
      description: Returns flag comparisons
      summary: Flag comparison
      parameters:
      - in: query
        name: base
        schema:
          type: string
        description: base commit SHA (`head` also required)
      - in: query
        name: head
        schema:
          type: string
        description: head commit SHA (`base` also required)
      - in: path
        name: owner_username
        schema:
          type: string
        description: username from service provider
        required: true
      - in: query
        name: pullid
        schema:
          type: integer
        description: pull ID on which to perform the comparison (alternative to specifying `base` and `head`)
      - in: path
        name: repo_name
        schema:
          type: string
        description: repository name
        required: true
      - in: path
        name: service
        schema:
          type: string
          enum:
          - bitbucket
          - bitbucket_server
          - github
          - github_enterprise
          - gitlab
          - gitlab_enterprise
        description: Git hosting service provider
        required: true
      tags:
      - Comparison
      security:
      - tokenAuth: []
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FlagComparison'
          description: ''
  /{service}/{owner_username}/repos/{repo_name}/compare/impacted_files:
    get:
      operationId: repos_compare_impacted_files_retrieve
      description: 'Returns a comparison for either a pair of commits or a pull

        Will only return pre-computed impacted files comparisons if available

        If unavailable `files` will be empty, however once the computation is ready

        the files will appear on subsequent calls

        `state: "processed"` means `files` are finished computing and returned

        `state: "pending"` means `files` are still computing, poll again later'
      summary: Impacted files comparison
      parameters:
      - in: query
        name: base
        schema:
          type: string
        description: base commit SHA (`head` also required)
      - in: query
        name: head
        schema:
          type: string
        description: head commit SHA (`base` also required)
      - in: path
        name: owner_username
        schema:
          type: string
        description: username from service provider
        required: true
      - in: query
        name: pullid
        schema:
          type: integer
        description: pull ID on which to perform the comparison (alternative to specifying `base` and `head`)
      - in: path
        name: repo_name
        schema:
          type: string
        description: repository name
        required: true
      - in: path
        name: service
        schema:
          type: string
          enum:
          - bitbucket
          - bitbucket_server
          - github
          - github_enterprise
          - gitlab
          - gitlab_enterprise
        description: Git hosting service provider
        required: true
      tags:
      - Comparison
      security:
      - tokenAuth: []
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImpactedFilesComparison'
          description: ''
  /{service}/{owner_username}/repos/{repo_name}/compare/segments/{file_path}:
    get:
      operationId: repos_compare_segments_retrieve
      description: 'Returns a comparison for a specific file path only showing the segments

        of the file that are impacted instead of all lines in file'
      summary: Segmented file comparison
      parameters:
      - in: query
        name: base
        schema:
          type: string
        description: base commit SHA (`head` also required)
      - in: path
        name: file_path
        schema:
          type: string
        description: file path
        required: true
      - in: query
        name: head
        schema:
          type: string
        description: head commit SHA (`base` also required)
      - in: path
        name: owner_username
        schema:
          type: string
        description: username from service provider
        required: true
      - in: query
        name: pullid
        schema:
          type: integer
        description: pull ID on which to perform the comparison (alternative to specifying `base` and `head`)
      - in: path
        name: repo_name
        schema:
          type: string
        description: repository name
        required: true
      - in: path
        name: service
        schema:
          type: string
          enum:
          - bitbucket
          - bitbucket_server
          - github
          - github_enterprise
          - gitlab
          - gitlab_enterprise
        description: Git hosting service provider
        required: true
      tags:
      - Comparison
      security:
      - tokenAuth: []
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImpactedFileSegments'
          description: ''
components:
  schemas:
    Owner:
      type: object
      properties:
        service:
          allOf:
          - $ref: '#/components/schemas/ServiceEnum'
          readOnly: true
        username:
          type:
          - string
          - 'null'
          readOnly: true
        name:
          type:
          - string
          - 'null'
          readOnly: true
      required:
      - name
      - service
      - username
    FileComparison:
      type: object
      properties:
        name: {}
        totals:
          $ref: '#/components/schemas/TotalsComparison'
        has_diff:
          type: boolean
        stats: {}
        change_summary: {}
        lines:
          type: array
          items:
            $ref: '#/components/schemas/LineComparison'
      required:
      - change_summary
      - has_diff
      - lines
      - name
      - stats
      - totals
    TotalsComparison:
      type: object
      properties:
        base:
          $ref: '#/components/schemas/ReportTotals'
        head:
          $ref: '#/components/schemas/ReportTotals'
        patch:
          $ref: '#/components/schemas/ReportTotals'
      required:
      - base
      - head
      - patch
    StateB73Enum:
      enum:
      - complete
      - pending
      - error
      - skipped
      type: string
      description: '* `complete` - Complete

        * `pending` - Pending

        * `error` - Error

        * `skipped` - Skipped'
    ServiceEnum:
      enum:
      - github
      - gitlab
      - bitbucket
      - github_enterprise
      - gitlab_enterprise
      - bitbucket_server
      type: string
      description: '* `github` - Github

        * `gitlab` - Gitlab

        * `bitbucket` - Bitbucket

        * `github_enterprise` - Github Enterprise

        * `gitlab_enterprise` - Gitlab Enterprise

        * `bitbucket_server` - Bitbucket Server'
    ReportTotals:
      type: object
      properties:
        files:
          type: integer
        lines:
          type: integer
        hits:
          type: integer
        misses:
          type: integer
        partials:
          type: integer
        coverage:
          type: number
          format: double
          readOnly: true
        branches:
          type: integer
        methods:
          type: integer
        messages:
          type: integer
        sessions:
          type: integer
        complexity:
          type: number
          format: double
        complexity_total:
          type: number
          format: double
        complexity_ratio:
          type: number
          format: double
          readOnly: true
        diff: {}
      required:
      - branches
      - complexity
      - complexity_ratio
      - complexity_total
      - coverage
      - diff
      - files
      - hits
      - lines
      - messages
      - methods
      - misses
      - partials
      - sessions
    LineComparison:
      type: object
      properties:
        value:
          type: string
        number: {}
        coverage: {}
        is_diff:
          type: boolean
        added:
          type: boolean
        removed:
          type: boolean
        sessions:
          type: integer
      required:
      - added
      - coverage
      - is_diff
      - number
      - removed
      - sessions
      - value
    ComponentComparison:
      type: object
      properties:
        component_id:
          type: string
        name:
          type: string
        base_report_totals:
          $ref: '#/components/schemas/ReportTotals'
        head_report_totals:
          $ref: '#/components/schemas/ReportTotals'
        diff_totals:
          $ref: '#/components/schemas/ReportTotals'
      required:
      - base_report_totals
      - component_id
      - diff_totals
      - head_report_totals
      - name
    Commit:
      type: object
      properties:
        commitid:
          type: string
          title: commit SHA
        message:
          type: string
          title: commit message
        timestamp:
          type: string
          format: date-time
          title: timestamp when commit was made
        ci_passed:
          type: boolean
          title: indicates whether the CI process passed for this commit
        author:
          allOf:
          - $ref: '#/components/schemas/Owner'
          title: author of the commit
        branch:
          type: string
          title: branch name on which this commit currently lives
        totals:
          allOf:
          - $ref: '#/components/schemas/CommitTotals'
          title: coverage totals
        state:
          allOf:
          - $ref: '#/components/schemas/StateB73Enum'
          title: Codecov processing state for this commit
        parent:
          type: string
          title: commit SHA of first ancestor commit with coverage
      required:
      - author
      - branch
      - ci_passed
      - commitid
      - message
      - parent
      - state
      - timestamp
      - totals
    FlagComparison:
      type: object
      properties:
        name:
          type: string
        base_report_totals:
          type:
          - object
          - 'null'
          additionalProperties: {}
          readOnly: true
        head_report_totals:
          $ref: '#/components/schemas/ReportTotals'
        diff_totals:
          $ref: '#/components/schemas/ReportTotals'
      required:
      - base_report_totals
      - diff_totals
      - head_report_totals
      - name
    CommitTotals:
      type: object
      properties:
        files:
          type: integer
        lines:
          type: integer
        hits:
          type: integer
        misses:
          type: integer
        partials:
          type: integer
        coverage:
          type: number
          format: double
          readOnly: true
        branches:
          type: integer
        methods:
          type: integer
        sessions:
          type: integer
        complexity:
          type: number
          format: double
        complexity_total:
          type: number
          format: double
        complexity_ratio:
          type: number
          format: double
          readOnly: true
        diff:
          type: integer
          readOnly: true
          title: 'Deprecated: this will always return 0.  Please use comparison endpoint for diff totals instead.'
      required:
      - branches
      - complexity
      - complexity_ratio
      - complexity_total
      - coverage
      - diff
      - files
      - hits
      - lines
      - methods
      - misses
      - partials
      - sessions
    ImpactedFilesComparison:
      type: object
      properties:
        base_commit:
          type: string
        head_commit:
          type: string
        totals:
          $ref: '#/components/schemas/TotalsComparison'
        commit_uploads:
          type: array
          items:
            $ref: '#/components/schemas/Commit'
        diff:
          type: object
          additionalProperties: {}
          readOnly: true
        files:
          type: array
          items:
            type: object
            additionalProperties: {}
          readOnly: true
        untracked:
          type: array
          items:
            type: string
          readOnly: true
        state:
          type: string
          readOnly: true
      required:
      - base_commit
      - commit_uploads
      - diff
      - files
      - head_commit
      - state
      - totals
      - untracked
    ImpactedFileSegments:
      type: object
      properties:
        segments:
          type: string
          readOnly: true
      required:
      - segments
    Comparison:
      type: object
      properties:
        base_commit:
          type: string
        head_commit:
          type: string
        totals:
          $ref: '#/components/schemas/TotalsComparison'
        commit_uploads:
          type: array
          items:
            $ref: '#/components/schemas/Commit'
        diff:
          type: object
          additionalProperties: {}
          readOnly: true
        files:
          type: array
          items:
            type: object
            additionalProperties: {}
          readOnly: true
        untracked:
          type: array
          items:
            type: string
          readOnly: true
      required:
      - base_commit
      - commit_uploads
      - diff
      - files
      - head_commit
      - totals
      - untracked
  securitySchemes:
    tokenAuth:
      type: http
      scheme: bearer
x-provenance:
  method: searched
  source: https://docs.codecov.com/reference
  harvested: '2026-10-26'
  tool: harvest-readme-openapi.py
  note: Assembled verbatim from the OpenAPI definition ReadMe embeds in each operation page of the provider's developer portal; paths and components merged by API title, nothing authored.
  assembled_from:
  - https://docs.codecov.com/reference/repos_branches_list.md
  - https://docs.codecov.com/reference/repos_branches_retrieve.md
  - https://docs.codecov.com/reference/repos_commits_list.md
  - https://docs.codecov.com/reference/repos_commits_retrieve.md
  - https://docs.codecov.com/reference/repos_commits_uploads_list.md
  - https://docs.codecov.com/reference/repos_compare_components_retrieve.md
  - https://docs.codecov.com/reference/repos_compare_file_retrieve.md
  - https://docs.codecov.com/reference/repos_compare_flags_retrieve.md
  - https://docs.codecov.com/reference/repos_compare_impacted_files_retrieve.md
  - https://docs.codecov.com/reference/repos_compare_retrieve.md
  - https://docs.codecov.com/reference/repos_compare_segments_retrieve.md
  - https://docs.codecov.com/reference/repos_components_list.md
  - https://docs.codecov.com/reference/repos_config_retrieve.md
  - https://docs.codecov.com/reference/repos_coverage_list.md
  - https://docs.codecov.com/reference/repos_evals_compare_retrieve-1.md
  - https://docs.codecov.com/reference/repos_evals_summary_retrieve-1.md
  - https://docs.codecov.com/reference/repos_file_report_retrieve.md
  - https://docs.codecov.com/reference/repos_flags_coverage_list.md
  - https://docs.codecov.com/reference/repos_flags_list.md
  - https://docs.codecov.com/reference/repos_list.md
  - https://docs.codecov.com/reference/repos_pulls_list.md
  - https://docs.codecov.com/reference/repos_pulls_retrieve.md
  - https://docs.codecov.com/reference/repos_report_retrieve.md
  - https://docs.codecov.com/reference/repos_report_tree_retrieve.md
  - https://docs.codecov.com/reference/repos_retrieve.md
  - https://docs.codecov.com/reference/repos_test_analytics_list-1.md
  - https://docs.codecov.com/reference/repos_test_results_list.md
  - https://docs.codecov.com/reference/repos_test_results_retrieve.md
  - https://docs.codecov.com/reference/repos_totals_retrieve.md
  - https://docs.codecov.com/reference/root_list.md
  - https://docs.codecov.com/reference/root_retrieve.md
  - https://docs.codecov.com/reference/user_sessions_list.md
  - https://docs.codecov.com/reference/users_list.md
  - https://docs.codecov.com/reference/users_partial_update.md
  - https://docs.codecov.com/reference/users_retrieve.md
  merge:
    pages: 35
    deduped: 98
    conflicts_kept_first: 0