(API) Get Score using API

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • how is SonarQube deployed: zip, Docker, Helm
  • what are you trying to achieve
  • what have you tried so far to achieve this

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

I’m using sonarqube Enterprise.

I want to get scores (Reliability - A, Maintainability - A, Security - A, … ) in dashboard using API.

ex - “https://my-sonar-qube/dashboard?id=my-project&pullRequest=1437”,

Could you help me ?

Hi @hyunju.sung

You can use the api/measures/component endpoint to fetch metrics for your project. The general format of the URL will look like this:

https://my-sonar-qube/api/measures/component?component=my-project&metricKeys=sqale_rating,reliability_rating,security_rating

Here, metricKeys includes the metrics you’re interested in. The names of the metrics you might want to use are:
* Reliability : reliability_rating
* Maintainability : sqale_rating (note: if you want to get maintainability specifically you might want to check additional metrics)
* Security : security_rating

1 Like

Thank you.
Many things are working well, but I have question about code smells score.

“measures”:[{“metric”:“code_smells”,“value”:“518”,“bestValue”:false},

I can get exact value, but I can’t get score.

How can I get “A”, “B”, “C” in code smells ?

Hi @hyunju.sung ,

I am sorry, i don’t understand what is code smells score. Can you send me a screenshot ?

For the metric definitions see

It’s also seen here https://<yoursonarhost>/projects

has

SonarQube executes rules on source code to generate issues. There are four types of rules:

  • Code smell (maintainability domain)
  • Bug (reliability domain)
  • Vulnerability (security domain)
  • Security hotspot (security domain)
1 Like

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