Skip to content
This documentation applies to Codacy Self-hosted v4.1.0

For the latest updates and improvements, see the latest Cloud documentation instead.

Obtaining current issues in repositories#

To obtain information about the current issues in your repositories in a flexible way, use the Codacy API endpoint searchRepositoryIssues.

For example, you may want to generate a report that includes only issues that belong to specific categories (such as security issues), or that have a minimum severity level.

Example: Obtaining security issues with level Error and Warning#

This example exports the pattern ID, issue level, file path, and timestamp for all security issues that have the severity level Warning or Error in the GitHub repository codacy/website.

The example script:

  1. Defines an account API token.
  2. Calls the Codacy API endpoint to retrieve information about the issues, filtering the results by security issues with the relevant severity levels.
  3. Uses jq to select only the necessary data fields and convert the results to the CSV format.
export CODACY_API_TOKEN="<your account API token>"

curl -X POST "https://app.codacy.com/api/v3/analysis/organizations/gh/codacy/repositories/website/issues/search" \
     -H "api-token: $CODACY_API_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{ "levels": ["Error", "Warning"], "categories": ["Security"] }' \
| jq -r ".data[] | [.patternInfo.id, .patternInfo.level, .filePath, .commitInfo.timestamp] | @csv"

Output:

"BundlerAudit_Insecure Dependency","Error","Gemfile.lock","2021-06-16T11:46:24Z"
"Custom_Scala_PredictableRandom","Warning","src/test/database/SpecsHelper.scala","2021-05-21T16:20:15Z"
"Custom_Scala_PlayUntrustedHttpRequestParameter","Warning","app/RedirectController.scala","2021-04-26T15:06:33Z"
[...]

Important

For the sake of simplicity, the example doesn't consider paginated results obtained from the Codacy API. Learn how to use pagination to ensure that you obtain all the results returned by the API.

Share your feedback 📢

Did this page help you?

Thanks for the feedback! Is there anything else you'd like to tell us about this page?

We're sorry to hear that. Please let us know what we can improve:

Alternatively, you can create a more detailed issue on our GitHub repository.

Thanks for helping improve the Codacy documentation.

If you have a question or need help please contact support@codacy.com.

Last modified June 17, 2021