Fetch SonarQube Report from java project using SonarQube rest API

Hi, I want to fetch SonarQube report from java project. is there any SonarQube api available so that I can use it and fetch data like bugs, code smells, duplications using api? Please help me

Hey there.

The Web API (documentation linked in the footer of your instance) will help you out – specifically the api/measures domain, (GET api/measures/component specifically)

//https://next.sonarqube.com/sonarqube/api/measures/component?component=org.sonarsource.java%3Ajava&metricKeys=bugs,code_smells,duplicated_lines_density
{
   "component":{
      "key":"org.sonarsource.java:java",
      "name":"SonarJava",
      "description":"Code Analyzer for Java",
      "qualifier":"TRK",
      "measures":[
         {
            "metric":"duplicated_lines_density",
            "value":"0.3",
            "bestValue":false
         },
         {
            "metric":"code_smells",
            "value":"125",
            "bestValue":false
         },
         {
            "metric":"bugs",
            "value":"5",
            "bestValue":false
         }
      ]
   }
}
1 Like

Thanks for the reply. Where is the Web api documentation link?

As mentioned, it’s always linked in the footer of your instance.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.