Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
DescriptionGet a list of lines of source code

URL

/api/sources

HTTP MethodGET
Response Formatsxml | json | txt

Security

Requires Code Viewer role on the project

Examples

Use CaseExample Request
Get source code of 'org.codehaus.sonar:sonar-plugin-api:org.sonar.api.measures.CoreMetrics' from line 10 to 20

GET http://nemo.sonarsource.org/api/sources?resource=org.codehaus.sonar:sonar-plugin-api:org.sonar.api.measures.CoreMetrics&from=10&to=20

Response Format

Code Block
titleJSON
languagejavascript
[
  {
    "10":" *",
    "11":" * Sonar is distributed in the hope that it will be useful,",
    "12":" * but WITHOUT ANY WARRANTY; without even the implied warranty of",
    ...
  }
]

Parameters

Parameter

Description

Required

Default ValueExample Value

resource

id or key of the file

Yes

Noneorg.codehaus.sonar:sonar-plugin-api:org.sonar.api.measures.CoreMetrics

from

First line to display

No

None10

to

Last line to display (inclusive)

No

None20

color

Highlights code syntax if true.
Possible values: true | false 

No

falsetrue
format

Response format can be set through:

  • Parameter format: xml | json | txt
  • Or the 'Accept' property in the HTTP header:
    • Accept:text/xml
    • Accept:application/json
If nothing is set, json is used.
NoNonejson