For the latest updates and improvements in production, open docs.codacy.com 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:
- Defines the account API token used to authenticate on the Codacy API.
- Calls the endpoint searchRepositoryIssues to retrieve information about the issues, filtering the results by security issues with the relevant severity levels.
- Uses jq to select only the necessary data fields and convert the results to the CSV format.
CODACY_API_TOKEN="<your account API token>"
GIT_PROVIDER="<your Git provider>" # gh, ghe, gl, gle, bb, or bbe
ORGANIZATION="<your organization name>"
REPOSITORY="<your repository name>"
curl -X POST "https://app.codacy.com/api/v3/analysis/organizations/$GIT_PROVIDER/$ORGANIZATION/repositories/$REPOSITORY/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"
Example 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 process all results returned by the API.
See also#
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?
255 characters left
We're sorry to hear that. Please let us know what we can improve:
255 characters left
Alternatively, you can create a more detailed issue on our GitHub repository.
Thanks for helping improve the Codacy documentation.
Edit this page on GitHub if you notice something wrong or missing.
If you have a question or need help please contact support@codacy.com.