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

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

Using the Codacy API#

The Codacy API allows you to programmatically retrieve and analyze data from Codacy and perform a few configuration changes.

Codacy supports two API versions but we strongly recommend using the new API v3 when possible since it's the version being actively developed:

API v3 (recommended) API v2
Endpoint documentation https://api.codacy.com/api/api-docs https://api.codacy.com/swagger
Base URL https://api.codacy.com/api/v3 https://api.codacy.com/
Overview

Use the new endpoints to access and manipulate the following resources, among others:

  • Analysis details, issue and ignored issue details, repository quality settings
  • Account details and API token management
  • Organization details and join request management
  • People management
  • Repository management and file details
  • Tool and code pattern details

Use the legacy endpoints to access and manipulate the following resources:

  • Commit code quality details and deltas
  • Project details and configurations, file code quality and issue details

Important

If you're using Codacy Self-hosted you must update the base URL of the APIs to include your Codacy instance domain name. For example:

https://codacy.example.com/api/v3   

Authenticating requests to the Codacy API#

Most API endpoints require that you provide either a project or account API token. After obtaining the necessary tokens, include them in your request headers using the format api-token: <token key> or project-token: <token key>.

For example, to make a request to an API v3 endpoint that requires an account API token:

curl -X GET https://api.codacy.com/api/v3/user/organizations/gh \
     -H 'api-token: SjE9y7ekgKdpaCofsAhd'

Or to make a request to an API v2 endpoint that requires a project API token:

curl -X GET https://api.codacy.com/2.0/commit/da275c14ffab6e402dcc6009828067ffa44b7ee0 \
     -H 'project-token: c9f2feb28e780acc8dc40754978b8bd9'

Using parameters in requests#

Most API endpoints require that you specify parameters.

For GET requests, specify parameters directly as path segments of the endpoint URLs. Some endpoints also accept optional query string parameters.

For example, to call the endpoint getRepositoryWithAnalysis with the parameters:

  • provider: gh
  • remoteOrganizationName: codacy
  • repositoryName: docs
  • branch (query string): api-overview
curl -X GET https://app.codacy.com/api/v3/analysis/organizations/gh/codacy/repositories/docs?branch=api-overview \
     -H 'api-token: SjE9y7ekgKdpaCofsAhd'

For POST, PATCH, and DELETE requests, besides the parameters included in the URL you may also need to include a JSON body.

For example, to call the endpoint searchRepositoryIssues specifying the issue levels Error and Warning in the body:

curl -X POST https://app.codacy.com/api/v3/analysis/organizations/gh/codacy/repositories/docs/issues/search \
     -H 'api-token: SjE9y7ekgKdpaCofsAhd' \
     -H 'Content-Type: application/json' \
     -d '{"levels": ["Error", "Warning"]}'

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 May 17, 2021