100% free for Open Source, forever. Get another set of eyes on your code.

Code Climate API (Deprecated)

Note: This API is unsupported and has been deprecated in favor of Code Climate's new API, in public beta as of November 2016. The new Code Climate API offers a richer set of resources and operates on a personal access token system.

Support for the endpoints below in the new API is forthcoming. For now, feel free to continue using what we have here.

Requirements

The API has two requirements:

  1. SSL (aka, https)
  2. Your API token (which is passed as the request parameter "api_token")

To access your API token:

  1. From your Dashboard, next to your organization's name, click Organization.
  2. Select the Integrations tab. Your API token will be listed on this page.

Note: Ensure you are not viewing a repository’s Integrations tab. Since your API token lives at the organization-level, it is accessed in your organization’s Integrations tab.

Note: API tokens are currently only available for Code Climate organizations on paid plans. They are not currently available for users that only have open source repositories (though this is something we plan to change in the future).

All responses are in JSON.

Endpoints

GET /api/repos

Retrieves a list of all repos (including their ID, URL and configured default branch)

Example Request

curl --get --data api_token=71188ef0569c36034f0b5a40c17e2c6f5bcfe594 https://codeclimate.com/api/repos

Example Response:

[
  {
    "id": "4906075af3ea000dc6000740",
    "url": "ssh://git@github.com/redsox/soxtalk.git",
    "branch": "master"
  },
  {
    "id": "1222075af3ea000dc6000799",
    "url": "ssh://git@github.com/redsox/baseball.git",
    "branch": "dev"
  }
]

GET /api/repos/:repo_id

GET /api/repos/:repo_id/branches/:branch_name

Retrieves information about a particular repo. The repo id can be found in the URL on any repo page.

The response includes information about the repo requested (e.g. name, branch), as well as meta-data from the last two snapshots performed (e.g. commit SHA, GPA, test coverage percentage). If you use the branch variety of the call, it instead returns the last two spapshots performed for that branch.

Example Request:

curl --get --data api_token=71188ef0569c36034f0b5a40c17e2c6f5bcfe594 https://codeclimate.com/api/repos/5017075af3ea000dc6000740

Example Response:

{
  "id": "4906075af3ea000dc6000740",
  "account_id": "3d415d14a1747d5991000001",
  "name": "Sox Talk",
  "url": "ssh://git@github.com/redsox/soxtalk.git",
  "branch": "master",
  "created_at": 1343686490,
  "last_snapshot": {
    "id": "407c8d1d13d637023100016c",
    "repo_id": "4907075af3ea000dc6000740",
    "commit_sha": "72f1c6ae07cc465df70aa372dc972e835f355972",
    "committed_at": 1368165656,
    "finished_at": 1368165666,
    "gpa": 3.05,
    "covered_percent": 46
  },
  "previous_snapshot": {
    "id": "4074d085c7f3a364f100667a",
    "repo_id": "4907075af3ea000dc6000740",
    "commit_sha": "02bcca40eafc7832160a08eef8f091e0896e2cec",
    "committed_at": 1367646334,
    "finished_at": 1367658637,
    "gpa": 3.04,
    "covered_percent": 23
  }
}

Example Request:

curl --get --data api_token=71188ef0569c36034f0b5a40c17e2c6f5bcfe594 https://codeclimate.com/api/repos/5017075af3ea000dc6000740/branches/integration

Example Response:

{
  "id": "4906075af3ea000dc6000740",
  "account_id": "3d415d14a1747d5991000001",
  "name": "Sox Talk",
  "url": "ssh://git@github.com/redsox/soxtalk.git",
  "branch": "integration",
  "created_at": 1343686490,
  "last_snapshot": {
    "id": "557c8d1d13d637023100016c",
    "repo_id": "4907075af3ea000dc6000740",
    "commit_sha": "8311c6ae07cc465df70aa372dc972e835f355972",
    "committed_at": 1368165656,
    "finished_at": 1368165666,
    "gpa": 2.99
  },
  "previous_snapshot": {
    "id": "3374d085c7f3a364f100667a",
    "repo_id": "4907075af3ea000dc6000740",
    "commit_sha": "56bcca40eafc7832160a08eef8f091e0896e2cec",
    "committed_at": 1367646334,
    "finished_at": 1367658637,
    "gpa": 2.55
  }
}

POST /api/repos/:repo_id/refresh

POST /api/repos/:repo_id/branches/:branch_name/refresh

Triggers an immediate scan of your repository. (Note that in most cases, especially if you are Github-linked, this is unnecessary)

Example Request:

curl --data api_token=71188ef0569c36034f0b5a40c17e2c6f5bcfe594 https://codeclimate.com/api/repos/5017075af3ea000dc6000740/refresh

Example Request:

curl --data api_token=71188ef0569c36034f0b5a40c17e2c6f5bcfe594 https://codeclimate.com/api/repos/5017075af3ea000dc6000740/branches/integration/refresh

Response is simple a 200 success.