SonarQube Measures API

Component metrics and measurement data

Documentation

Specifications

Schemas & Data

Other Resources

OpenAPI Specification

sonarqube-measures-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: SonarQube Web Measures API
  description: The SonarQube Web API provides HTTP endpoints for programmatic interaction with SonarQube Server. It enables management of projects, quality gates, issues, rules, users, groups, permissions, and CI/CD integrations. The API uses token-based authentication and follows REST conventions. It powers the SonarQube web UI and is used for CI/CD integration, custom tooling, and third-party plugin development.
  version: 10.0.0
  contact:
    name: SonarSource
    url: https://community.sonarsource.com/
  license:
    name: GNU Lesser General Public License v3.0
    url: https://www.gnu.org/licenses/lgpl-3.0.html
servers:
- url: https://{sonarqubeHost}/api
  description: SonarQube Server
  variables:
    sonarqubeHost:
      default: sonarqube.example.com
      description: Hostname of your SonarQube instance
tags:
- name: Measures
  description: Component metrics and measurement data
paths:
  /measures/component:
    get:
      operationId: getComponentMeasures
      summary: Get Component Measures
      description: Get measures (metrics) for a specific component. Returns values for requested metric keys such as coverage, bugs, vulnerabilities, code smells, duplications, and lines of code.
      tags:
      - Measures
      parameters:
      - name: component
        in: query
        required: true
        description: Component key
        schema:
          type: string
      - name: metricKeys
        in: query
        required: true
        description: Comma-separated metric keys to retrieve
        schema:
          type: string
      - name: branch
        in: query
        description: Branch name
        schema:
          type: string
      - name: pullRequest
        in: query
        description: Pull request identifier
        schema:
          type: string
      security:
      - basicAuth: []
      - bearerAuth: []
      responses:
        '200':
          description: Successfully retrieved component measures
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ComponentMeasuresResponse'
        '401':
          description: Unauthorized
        '404':
          description: Component not found
components:
  schemas:
    Measure:
      type: object
      properties:
        metric:
          type: string
          description: Metric key (e.g., coverage, bugs, vulnerabilities)
        value:
          type: string
          description: Metric value
        bestValue:
          type: boolean
          description: Whether this value is the best possible for the metric
        period:
          type: object
          properties:
            index:
              type: integer
            value:
              type: string
            bestValue:
              type: boolean
    ComponentMeasuresResponse:
      type: object
      properties:
        component:
          type: object
          properties:
            key:
              type: string
            name:
              type: string
            description:
              type: string
            qualifier:
              type: string
            measures:
              type: array
              items:
                $ref: '#/components/schemas/Measure'
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Basic authentication using a user token as the username and an empty password. Generate tokens in User > My Account > Security.
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication using a SonarQube user token.