# Get list of all issues for a specific project

**URL:** <https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143>\
**Category:** SonarQube Server / Community Build\
**Created:** [November 29, 2020, 6:10pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143 "2020-11-29T18:10:55Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Just\_some\_guy](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@Just\_some\_guy](https://community.sonarsource.com/u/Just_some_guy)\
**Post date:** [November 29, 2020, 6:10pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/1 "2020-11-29T18:10:55Z")

</div>

Hello everyone,  
I’m using SonarQube v.7.9.1 and I wanted to ask how can I get all issues for a specific project with SonarQube web API.

I’ve tried with a GET request at the address `https://my-sonarqube-server/api/issues/search` and it seems to work, but I get a (partial?) list of different projects.

How can I filter by project name?

Thank you so much.

---

<div class="post-metadata">

**Author:** ![Just\_some\_guy](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@Just\_some\_guy](https://community.sonarsource.com/u/Just_some_guy)\
**Post date:** [November 29, 2020, 6:23pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/2 "2020-11-29T18:23:36Z")

</div>

I tried specifying the parameter `componentKeys` as my project ID and it seems to work. My only doubt is if the list of issues is complete or not. Is there a limit?

Thanks again.

---

<div class="post-metadata">

**Author:** ![Alexandre\_Frigout](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/alexandre_frigout/32/151_2.png) [@Alexandre\_Frigout](https://community.sonarsource.com/u/Alexandre_Frigout)\
**Post date:** [November 30, 2020, 9:57am UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/3 "2020-11-30T09:57:21Z")

</div>

Hello @Just_some_guy,  
The list is limited to 10M as it is a limitation form the Elastic Search stack we use.  
You can use the createdAfter and createdBefore parameter to extract the complete list in several calls.  
Alex.

---

<div class="post-metadata">

**Author:** ![Just\_some\_guy](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@Just\_some\_guy](https://community.sonarsource.com/u/Just_some_guy)\
**Post date:** [November 30, 2020, 11:49am UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/4 "2020-11-30T11:49:52Z")

</div>

Thank you very much for the info and for the tip Alexandre! Cheers!

---

<div class="post-metadata">

**Author:** ![Shane\_Kramer](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shane_kramer/32/25820_2.png) [@Shane\_Kramer](https://community.sonarsource.com/u/Shane_Kramer)\
**Post date:** [September 20, 2021, 9:40pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/5 "2021-09-20T21:40:00Z")

</div>

I am able to use the API to pull issues, by project, to build my own reports, but I have not found a reasonable way to get over the per-project cap of 500 issues. I suppose I could try to determine total number of issues per project and use p=1,2,3, etc? If I do not specify ps param, it defaults to 100. I am capped at 500, which a couple of my projects exceed. This seems super clunky. Thoughts/advice?

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [September 21, 2021, 7:09am UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/6 "2021-09-21T07:09:36Z")

</div>

Welcome 🙂

you didn’t reveal your Sonarqube version.  
Sonarqube 9.1 comes with a new `api/projects/export_findings` endpoint that allows to fetch all issues and hotspots for a given project and a given branch, see  
[https://jira.sonarsource.com/browse/SONAR-15334](https://jira.sonarsource.com/browse/SONAR-15334)

> **[Download | SonarQube](https://www.sonarqube.org/downloads/)**
>
> Get the latest LTS and version of SonarQube the leading product for Code Quality and Security from the official download page.

Otherwise with older versions you may use something like that  
get total issues via  
`api/issues/search?componentKeys=com.foo:bar&severities=CRITICAL&ps=1`

and then use `total = (issues.total.toFloat()/100).round()` in a loop

```auto
counter = 1
while(counter <= total)
{
api/issues/search?componentKeys=com.foo:bar&severities=CRITICAL&ps=100&p=$counter
counter++
}

```

Gilbert

---

<div class="post-metadata">

**Author:** ![prasad-clouduser](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/prasad-clouduser/32/27501_2.png) [@prasad-clouduser](https://community.sonarsource.com/u/prasad-clouduser)\
**Post date:** [August 5, 2022, 8:03am UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/7 "2022-08-05T08:03:14Z")

</div>

Hi Gilbert,

Suppose if we have less than 100 issues and also if we have ex 120 issues we gonna miss out the issues. which is an issue. we need to make sure that all issues are returned with the above logic.

Thanks,  
Prasad.

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [August 5, 2022, 10:14am UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/8 "2022-08-05T10:14:36Z")

</div>

Hi,

which Sonarqube version do you use ?  
If \< Sonarqube 9.1 did you try with the proposal for older versions ?

Gilbert

---

<div class="post-metadata">

**Author:** ![prasad-clouduser](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/prasad-clouduser/32/27501_2.png) [@prasad-clouduser](https://community.sonarsource.com/u/prasad-clouduser)\
**Post date:** [August 5, 2022, 1:44pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/9 "2022-08-05T13:44:01Z")

</div>

I am using sonarqube version 9.2.3 community edition. Currently it is pulling only 100 issues by default. I have 2000 issues in the project and all needs to be pulled. I tried your method and it is rounding off to 0 (when 14 issues ) and to 1 (when 120 issues) and as resulting losing issues.

---

<div class="post-metadata">

**Author:** ![prasad-clouduser](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/prasad-clouduser/32/27501_2.png) [@prasad-clouduser](https://community.sonarsource.com/u/prasad-clouduser)\
**Post date:** [August 5, 2022, 6:14pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/10 "2022-08-05T18:14:31Z")

</div>

Hi Gilbert,

I am using community edition 9.2.3 version to retrieve. In this version is there any new way to get all the list of issues?

Thanks,  
Prasad.

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [August 10, 2022, 11:55am UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/11 "2022-08-10T11:55:14Z")

</div>

Hi Prasad,

somehow i missed that the new `api/projects/export_findings` endpoint was only implemented  
for Sonarqube Enterprise.  
When using Sonarqube Community you have to use `api/issues/search` instead.  
You’re right about the rounding problem, my proposal was only briefly outlined without test.

At a second glance i would use something like that, a small example in Groovy

```auto
import groovy.json.*

def sqRest(url,method) {
  jsonSlurper = new JsonSlurper()
  raw ='yoursonartoken:'
  bauth = 'Basic ' + raw.bytes.encodeBase64().toString()
  conn = url.toURL().openConnection()
  conn.setRequestMethod(method)
  conn.setRequestProperty("Authorization", bauth)
  httpstatus = conn.responseCode
 // println "sqRest ResponseCode = $httpstatus"
  if(method == 'GET') {
    object = jsonSlurper.parseText(conn.content.text)
  }
}

issues = sqRest('https://yoursonarhost/api/issues/search?componentKeys=com.foo:bar&severities=CRITICAL&ps=1', 'GET')
println 'Total issues => ' + issues.total

if(issues.total > 100) {
  total = issues.total.toFloat()/50.round()
  counter = 1
  while(counter < total + 1) {
    response = sqRest("https://yoursonarhost/api/issues/search?componentKeys=com.foo:bar&severities=CRITICAL&ps=$counter", 'GET')
    println response.issues
    println response.issues.key.join(',')
    println response.issues.rule.join(',')
    counter++  
  }
}
else {
  response = sqRest('https://yoursonarhost/api/issues/search?componentKeys=com.foo:bar&severities=CRITICAL&ps=100', 'GET')
  println response.issues
  println response.issues.key.join(',')
  println response.issues.rule.join(',')
}

```

Alternatively if you use Python you should have a look into [sonar-tools · PyPI](https://pypi.org/project/sonar-tools/)  
by Olivier Korach which has also sonar-findings-export feature.

Gilbert

---

<div class="post-metadata">

**Author:** ![prasad-clouduser](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/prasad-clouduser/32/27501_2.png) [@prasad-clouduser](https://community.sonarsource.com/u/prasad-clouduser)\
**Post date:** [August 22, 2022, 1:04pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/12 "2022-08-22T13:04:39Z")

</div>

Hi Gilbert,

Thanks for your reply. In the If loop you are intended to say p=counter instead of ps=counter in the below URL: Correct if I am wrong.

response = sqRest(“[https://yoursonarhost/api/issues/search?componentKeys=com.foo:bar&severities=CRITICAL&ps=$counter](https://yoursonarhost/api/issues/search?componentKeys=com.foo:bar&severities=CRITICAL&ps=%24counter)”, ‘GET’)

Suppose if there are 720 issues, it is rounded to 14, In the first 8 (ps default value 100) iterations only all the issues are returned and next 6 iterations are wasted and if there are thousands of issues there will be more unnecessary iterations.

sonar-tools is very helpful tool. Thank you.

---

<div class="post-metadata">

**Author:** ![prasad-clouduser](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/prasad-clouduser/32/27501_2.png) [@prasad-clouduser](https://community.sonarsource.com/u/prasad-clouduser)\
**Post date:** [October 27, 2022, 2:00pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/13 "2022-10-27T14:00:50Z")

</div>

Hi Gilbert,

sonar-tools is not working with **SonarQube 9.7**. it is stuck at the below stage, I gave admin token during this run. 9.7 community edition officially released?

- pip install sonar-tools  
Collecting sonar-tools  
Downloading sonar\_tools-2.4.1-py3-none-any.whl (184 kB)  
Collecting datetime  
Downloading DateTime-4.7-py2.py3-none-any.whl (52 kB)  
Collecting argparse  
Downloading argparse-1.4.0-py2.py3-none-any.whl (23 kB)  
Collecting pytz  
Downloading pytz-2022.5-py2.py3-none-any.whl (500 kB)  
Collecting python-dateutil  
Downloading python\_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)  
Collecting jprops  
Downloading jprops-2.0.2-py2.py3-none-any.whl (9.1 kB)  
Collecting requests  
Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)  
Collecting zope.interface  
Downloading zope.interface-5.5.0-cp36-cp36m-manylinux\_2\_5\_x86\_64.manylinux1\_x86\_64.manylinux\_2\_12\_x86\_64.manylinux2010\_x86\_64.whl (253 kB)  
Collecting six\>=1.5  
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)  
Collecting charset-normalizer~=2.0.0  
Downloading charset\_normalizer-2.0.12-py3-none-any.whl (39 kB)  
Collecting certifi\>=2017.4.17  
Downloading certifi-2022.9.24-py3-none-any.whl (161 kB)  
Collecting urllib3\<1.27,\>=1.21.1  
Downloading urllib3-1.26.12-py2.py3-none-any.whl (140 kB)  
Collecting idna\<4,\>=2.5  
Downloading idna-3.4-py3-none-any.whl (61 kB)  
Requirement already satisfied: setuptools in /usr/local/lib/python3.6/site-packages (from zope.interface-\>datetime-\>sonar-tools) (57.5.0)  
Installing collected packages: zope.interface, urllib3, six, pytz, idna, charset-normalizer, certifi, requests, python-dateutil, jprops, datetime, argparse, sonar-tools  
Successfully installed argparse-1.4.0 certifi-2022.9.24 charset-normalizer-2.0.12 datetime-4.7 idna-3.4 jprops-2.0.2 python-dateutil-2.8.2 pytz-2022.5 requests-2.27.1 six-1.16.0 sonar-tools-2.4.1 urllib3-1.26.12 zope.interface-5.5.0  
WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: [12. Virtual Environments and Packages — Python 3.11.0 documentation](https://pip.pypa.io/warnings/venv)  
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.  
You should consider upgrading via the ‘/usr/local/bin/python -m pip install --upgrade pip’ command.  
[Pipeline] sh  
Warning: A secret was passed to “sh” using Groovy String interpolation, which is insecure.  
Affected argument(s) used the following variable(s): [TOKEN]  
See [https://jenkins.io/redirect/groovy-string-interpolation](https://jenkins.io/redirect/groovy-string-interpolation) for details.
- export SONAR\_HOST\_URL=https://\<\>\>.biz
- export SONAR\_TOKEN=\*\*\*\*
- sonar-findings-export -t \*\*\*\* -k services --format json  
2022-10-27 13:49:44,814 | sonar-tools | INFO | MainThread | Set debug level to INFO  
2022-10-27 13:49:44,814 | sonar-tools | INFO | MainThread | sonar-tools version 2.4.1  
2022-10-27 13:49:44,815 | sonar-tools | INFO | MainThread | Listing projects  
2022-10-27 13:49:45,008 | sonar-tools | INFO | MainThread | Exporting findings for 1 projects with params {‘url’: ‘https://\<\>\>.biz’, ‘projectKeys’: ‘services’, ‘format’: ‘json’, ‘csvSeparator’: ‘,’, ‘threads’: 8, ‘useFindings’: False, ‘withURL’: False}  
2022-10-27 13:49:45,008 | sonar-tools | INFO | MainThread | Dumping report to stdout  
2022-10-27 13:49:45,008 | sonar-tools | INFO | findingSearch0 | Project ‘services’ issue search  
2022-10-27 13:49:45,011 | sonar-tools | INFO | MainThread | Starting finding writer thread ‘findingWriter’

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [October 27, 2022, 5:27pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/14 "2022-10-27T17:27:53Z")

</div>

Unfortunately, I haven’t had time to get serious about Python, so I haven’t used  
sonar-tools yet and therefore can’t be of help.

You may contact Olivier Korach via the project page

> **[GitHub - okorach/sonar-tools: Additional command line based tools to help in...](https://github.com/okorach/sonar-tools)**
>
> Additional command line based tools to help in SonarQube administration tasks - GitHub - okorach/sonar-tools: Additional command line based tools to help in SonarQube administration tasks

or via PM here in the forum !?

---

<div class="post-metadata">

**Author:** ![prasad-clouduser](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/prasad-clouduser/32/27501_2.png) [@prasad-clouduser](https://community.sonarsource.com/u/prasad-clouduser)\
**Post date:** [October 27, 2022, 6:14pm UTC](https://community.sonarsource.com/t/get-list-of-all-issues-for-a-specific-project/35143/15 "2022-10-27T18:14:27Z")

</div>

Hi Gilbert,

How to contact him ? Could you tell me where can I post so that he can see my posts

Thanks,  
Prasad.
