Full documentation for SonarQube has moved to a new location: http://docs.sonarqube.org/display/SONAR

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
iconfalse
titleTable of Contents

Table of Contents
maxLevel1

Get a List of Resources

DescriptionGet a list of resources

URL

/api/resources

HTTP MethodGET
Response Formatsjson | xml

Security

Requires User role on resource

...

Parameter

Description

RequiredDefault ValueExample Values

resource

id or key of the resource

NoNoneorg.codehaus.sonar:sonar

metrics

Comma-separated list of metric keys/ids.
Load measures on selected metrics. If only one metric is set, then measures are ordered by value.

NoNonelines,blocker_violations

depth

Used only when resource is set. 

  • 0: only selected resource 
  • -1: all children, including selected resource 
  • >0: depth toward the selected resource
No0-1

scopes

Comma-separated list of scopes:

  • PRJ: project/module 
  • DIR: directory (like Java package) 
  • FIL: file
NoNonePRJ,DIR

qualifiers

Comma-separated list of qualifiers

  • VW: view
  • SVW: sub-view
  • TRK: project 
  • BRC: module 
  • CLA: class 
  • UTS: unit test 
  • DIR: directory 
  • FIL: file
  • DEV: developer
NoNoneTRK,BRC

verbose

Add some data to response.
Possible values: true | false 

Nofalsetrue

limit

Limit the number of results. Only used if one metric, and only one, is set.

NoNone10

includetrends

Include trends and period variations in response: add <trend> (1 if better, else worse), <var> (1 if measure value increases) and nodes <p*> for period variations.
Possible values: true | false 

Nofalsetrue

includealerts

Include alerts data: add nodes <alert> (ERROR, WARN, OK) and <alert_text>
Possible values: true | false  

Nofalsetrue

rules

Filter on rules: setting it to true will return rules id and rule name for measure having such info (such as 'blocker_violations', 'critical_violations', ..., 'new_blocker_violations', ...)
Possible values: true | false | list of rule ids 

Nofalsetrue

rule_priorities

Filter on rule priority: setting it to true or to a list of priorities (BLOCKER, CRITICAL, MAJOR, MINOR, INFO) will return measures having such info (such as 'blocker_violations', 'critical_violations', ..., 'new_blocker_violations', ...).
Possible values: true | false | list of priorities

NofalseBLOCKER,CRITICAL
formatResponse formats.
Possible values: json | xml
NoNonejson

Search Resources by Name

DescriptionSearch resources by name

URL

/api/resources/search

HTTP MethodGET
Response Formatsjson

Security

Requires User role on resources

Examples

Use CaseExample Request
Get all the projects and sub-projects with name containing 'com'

GET http://nemo.sonarsource.org/api/resources/search?s=com&q=TRK,BRC 

Response Format

Code Block
titleJSON
languagejavascript
{
  "total":325,
  "page":1,
  "page_size":10,
  "data":[
    {
      "id":48209,
      "nm":"Commons IO",
      "q":"TRK"
    },
    {
      "id":74793,
      "nm":"Commons BCEL",
      "q":"TRK"
    },
    ...
  ]
}

Parameters

Parameter

Description

RequiredDefault ValueExample Values

s

String to look for.

NoNonecom

q

Comma-separated list of qualifiers: 

  • VW: view
  • SVW: sub-view
  • TRK: project 
  • BRC: module 
  • CLA: class 
  • UTS: unit test 
  • DIR: directory 
  • FIL: file
  • DEV: developer
NoNoneTRK,BRC
psPage size: number of results returned by page.No105
pPage to return.No12
formatResponse formats.
Possible values: json
NoNonejson