Leveraging Sonarqube API's to extract project related information


I am currently using SonarQube v6.7, I am looking to get the following information using API’s -

  1. List of sonarqube projects
  2. Lines of code per project
  3. Application / Portfolio that the project is associated with?

I tried exploring api/components and api/measures but that wasn’t of much help.
Any suggestions will be much appreciated.


Hi Naveen,

You’ll find below the answer of your questions.

  1. List of sonarqube projects


  1. Lines of code per project


  1. Application / Portfolio that the project is associated with?

This information is not available in this way, you can only get the list of projects from a Portfolio or Application :



Thanks Julien, with the mentioned queries from you, I was able to get the information but in silos, I probably need to write a script in order to get one consolidated report for the above 3 points. Is there a database query that can simply give the above information in a single report?



Running queries against a production database actively serving an application is not a good idea — and the SonarQube database should be treated as a black box: it is not publicly documented and it can change at anytime from version to version without warning.

Our Web APIs however have clear documentation available as well as consistent deprecation strategies when they are altered (a deprecated parameter will, for example, still be available for 2 major versions post-deprecation before being removed). Assuming you want to run your report more than once across multiple versions of SonarQube, this is very important!

I strongly encourage using the Web APIs.


Okay, point taken Colin.
Thanks for the prompt reply and recommendations.


On my side I need to get by API’s these differents values in one of my SonaQube project :

  • Duplications
  • Number of bugs
  • Rate value for the bugs
  • Number of vulnerabilities
  • Rate value for the vulnerabilities
  • Debt value
  • Debt rate

Could you tell me which API I have to use, and with which parameters please ?