-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* wip: Create new section dedicated to the Codacy API * wip: Move "Codacy API tokens" inside the new "Codacy API" section I didn't create redirects from the previous URL to the new one because the previous URL was live for only a very short while (see #554). * wip: Move example "Adding repositories" inside "Codacy API" * clean: Rename "Codacy API overview" to "Using the Codacy API" The new title is more "actionable" and hopefully will attract the attention from the users better. * feature: Add API reference links to sidebar navigation * feature: Add Codacy API overview for both API versions * edit: Open links API links on new browser window * style: Refactor API overview using a table to organize the information * clean: Improve warning about keeping API tokens safe * feature: Add instructions on how to authenticate in the Codacy API * clean: Move Codacy API to top level section * feature: Add card for the Codacy API on the documentation homepage * edit: Mention that the API v3 is preferred over the older version * feature: Mention that Codacy Sef-hosted requires a different base URL
- Loading branch information
Showing
12 changed files
with
198 additions
and
31 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
!!! warning | ||
**Never write API tokens on your configuration files** and keep your API tokens well protected, as they grant owner permissions to your projects. | ||
**Never write API tokens on your configuration files** and keep your API tokens well protected, as they grant owner permissions to your projects on Codacy. | ||
|
||
We recommend that you set API tokens as environment variables. Check the documentation of your CI/CD platform on how to do this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# 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 prefer the new API v3 when possible since it's the version being actively developed: | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<td></td> | ||
<th><strong>API v3 (preferred)</strong></th> | ||
<th><strong>API v2</strong></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<th>Endpoint documentation</th> | ||
<td><a target="_blank" href="https://api.codacy.com/api/api-docs">https://api.codacy.com/api/api-docs</a></td> | ||
<td><a target="_blank" href="https://api.codacy.com/swagger">https://api.codacy.com/swagger</a></td> | ||
</tr> | ||
<tr> | ||
<th>Base URL</th> | ||
<td><code>https://api.codacy.com/api/v3</code></td> | ||
<td><code>https://api.codacy.com/</code></td> | ||
</tr> | ||
<tr> | ||
<th>Overview</th> | ||
<td> | ||
<p>The new endpoints allow you to access and manipulate the following resources, among others:<p> | ||
<ul> | ||
<li><a target="_blank" href="https://api.codacy.com/api/api-docs#codacy-api-analysis">Analysis</a> details, issue and ignored issue details, repository quality settings</li> | ||
<li><a target="_blank" href="https://api.codacy.com/api/api-docs#codacy-api-account">Account</a> details and API token management</li> | ||
<li><a target="_blank" href="https://api.codacy.com/api/api-docs#codacy-api-organization">Organization</a> details and join request management</li> | ||
<li><a target="_blank" href="https://api.codacy.com/api/api-docs#codacy-api-people">People</a> management</li> | ||
<li><a target="_blank" href="https://api.codacy.com/api/api-docs#codacy-api-repository">Repository</a> management and file details</li> | ||
<li><a target="_blank" href="https://api.codacy.com/api/api-docs#codacy-api-tools">Tool</a> and code pattern details</li> | ||
</ul> | ||
</td> | ||
<td> | ||
<p>The legacy endpoints allow you to access and manipulate the following resources:</p> | ||
<ul> | ||
<li><a target="_blank" href="https://api.codacy.com/swagger#codacy-api-commit">Commit</a> code quality details and deltas</li> | ||
<li><a target="_blank" href="https://api.codacy.com/swagger#codacy-api-project">Project</a> details and configurations, file code quality and issue details</li> | ||
</ul> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
!!! 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](api-tokens.md). 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**: | ||
|
||
```bash | ||
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**: | ||
|
||
```bash | ||
curl -X GET https://api.codacy.com/2.0/commit/da275c14ffab6e402dcc6009828067ffa44b7ee0 \ | ||
-H "project-token: c9f2feb28e780acc8dc40754978b8bd9" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters