SonarQube API

Development / OAuth Advanced HTTPS
Varies by plan (check documentation)

Overview

SonarQube provides a REST API for its code quality and security analysis platform, letting you programmatically retrieve metrics, issues, and quality gate statuses for your projects. It supports OAuth authentication and integrates with CI/CD pipelines to automate code review workflows. Developers use it to build dashboards, enforce quality gates, and track technical debt over time.

Beginner Tip

You can explore the SonarCloud Web API interactively at sonarcloud.io/web_api without writing any code — a great way to understand available endpoints before integrating them into your pipeline.

Available Data

SonarQube data via REST API

Example Response

JSON Response
{
  "url": "https://example.com",
  "safe": true,
  "threat_level": "none",
  "categories": [
    "clean"
  ],
  "scan_date": "2025-01-15T10:00:00Z"
}

Field Reference

component.key The unique project key identifying the analyzed component
component.measures Array of metric measurement objects for the requested metricKeys
component.measures[].metric The metric key name (e.g., coverage, bugs, code_smells)
component.measures[].value The current numeric value for the metric
component.qualifier Type of component analyzed, such as TRK (project) or FIL (file)

Implementation Example

Request
const url = "https://sonarcloud.io/web_api";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "Authorization": "Bearer YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

401 Unauthorized Token not included or formatted incorrectly in the Authorization header
Pass your SonarCloud token as the username with a blank password using -u YOUR_TOKEN: in curl (note the trailing colon)
404 Not Found on component The project key does not exist or you do not have access to it
Verify the project key in your SonarCloud dashboard under Administration > Update Key
400 Bad Request on metricKeys One or more metric key names are invalid
Use the /api/metrics/search endpoint to get a full list of valid metric keys for your SonarCloud instance

Metadata Score Breakdown

Estimated from metadata — endpoint not independently tested

This score is estimated from observable metadata — HTTPS support, authentication model, declared CORS, and documentation reachability — because the API requires authentication or exposes no publicly testable endpoint. The five-signal breakdown is only shown for live-tested APIs.

Metadata estimate · endpoint not independently tested

Technical Specifications

Auth OAuth
HTTPS REQUIRED
CORS UNKNOWN
Category Development
Difficulty Advanced
Verified: 2026-04-04

Similar APIs

View All →