Skip to content

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 📢

Let us know if this page was helpful:

Thank you for the feedback!

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

If you have a question or need help, please ask our community or contact support@codacy.com.

Last modified June 17, 2021