NAV Navbar
shell
  • Overview
  • Users
  • Organizations
  • Repositories
  • Repository Analysis
  • Test Coverage
  • Pull Requests
  • Overview

    Code Climate's API exposes user, organization and repository data displayed and used by our web application (and browser extension).

    The API complies with REST standards and the JSON API specification. In addition to our documentation here, you may find additional help by consulting the JSON API specification.

    As per the JSON API, clients should use the JSON API media type where appropriate (and the examples demonstrate this).

    If your organization uses codeclimate.com, the URL for the api is: https://api.codeclimate.com/.

    For on premise customers, use your normal Code Climate host name, but prefix endpoints with /api.

    All endpoints are prefixed by the API version. The current version is /v1.

    Following this, here are the base URLs (assuming current version):

    codeclimate.com: https://api.codeclimate.com/v1

    On premise: https://{YOUR-CC-HOST-NAME}/api/v1

    Authentication

    All authenticated calls must include a Authorization header including a valid token.

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/user
    

    Make sure to replace {TOKEN} with your API access token.

    Code Climate uses API access tokens to allow access to the API. You can generate a new Code Climate personal access token on codeclimate.com in the token settings area of your Code Climate user profile.

    Code Climate expects for the API token to be included in all API requests to the server in a header that looks like the following (replace {TOKEN} with your own):

    Authorization: Token token={TOKEN}

    Data Types

    Where possible, the Code Climate API uses consistent formats to represent common types. These are listed below.

    Type Format
    id stringified BSON object id
    timestamp ISO8601-formatted timestamp (e.g. 2015-12-17T18:58:07.301Z)

    Rate Limit

    The API enforces a limit of 5,000 requests per token per hour.

    Collection Pagination

    Request for 3rd page with 10 items per page

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "page[size]=10" \
      --data-urlencode "page[number]=3" \
      https://api.codeclimate.com/v1/orgs
    

    The Code Climate API supports pagination for resource collections.

    As per the JSON API, paginate through resources with a top level page[] query parameter. In the Code Climate API (JSON API is agnostic to how page[] is used), the page[] parameter supports nested page and size parameters.

    Query parameter Description Default Max
    page[size] The number of items to return per page 30 100
    page[number] The page number to request 1 n/a

    Collection Filtering

    Filtering by basic key / value

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "filter[branch]=master" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/ref_points
    

    Filtering with $in operator, passing multiple values. Note that the parameter is specified more than once:

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "filter[branch][\$in][]=master" \
      --data-urlencode "filter[branch][\$in][]=development" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/ref_points
    

    Filtering with the $regex operator. This can be used to find records with an attribute that matches a certain regular expression.

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "filter[path][\$regex]=.+\.yml" \
      https://api.codeclimate.com/v1/repos/59371236d8638a029a0000ef/snapshots/623c2866a758be0001036c9f/files
    

    In some cases, where specified, the Code Climate API supports filtering resource collections.

    As per the JSON API, filter resources with a top level filter[] query parameter.

    The JSON API is agnostic beyond the filter[] key. In the Code Climate API, filters can be of two basic formats (examples on the right):

    1. A basic key/value
    2. A more complex data structure with an operator. At this time only the $in and $regex operators are supported.

    See the Query Parameters section of each endpoint for details about what filters are supported.

    Fetching associated resources

    Code Climate's API supports loading associated resources in a single API call.

    To determine what associated resources can be loaded, inspect the relationships section of the API response. For example, the GET repo endpoint returns a JSON response with a relationships key, where one of the relationships is named latest_default_branch_snapshot.

    Fetch the associated resource(s) by using the include query string parameter. Multiple included resources should use an include[] parameter, with resources specified as a comma-delimited list.

    For example:

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "include[]=latest_default_branch_snapshot,account" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001
    

    Users

    Get authenticated user

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/user
    

    JSON response:

    {
      "data": {
        "id": "516342ca7e11a428b0025372",
        "type": "users",
        "attributes": {
          "email": "[email protected]",
          "enabled_features": [
            "builder_pull_engines",
            "disable_transactions",
            "encrypted_ssh_private_keys"
          ],
          "full_name": "Dale Cooper",
          "staff": false,
          "github_login": "dale_cooper"
        },
        "links": {
          "avatar": "https:\/\/avatars.githubusercontent.com\/u\/122672"
        }
      }
    }
    

    Returns information about the authenticated user.

    HTTP Request

    GET https://api.codeclimate.com/v1/user

    Query Parameters

    N/A

    Organizations

    Get organizations

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/orgs
    

    JSON response:

    {
      "data": [
        {
          "id": "3334f0eaf3ea115e91218182",
          "type": "orgs",
          "attributes": {
            "name": "Twin Peaks"
          },
          "meta": {
            "counts": {
              "repos": 6
            },
            "permissions": {
              "admin": true
            }
          }
        },
        {
          "id": "591d76793b8b820267111402",
          "type": "orgs",
          "attributes": {
            "name": "FBI"
          },
          "meta": {
            "counts": {
              "repos": 0
            },
            "permissions": {
              "admin": true
            }
          }
        }
      ],
      "links": {
      }
    }
    

    Returns collection of organizations for the current user.

    HTTP Request

    GET https://api.codeclimate.com/v1/orgs

    Query Parameters

    Paginated

    Not filterable.

    Get permissions

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/orgs/596b70adb79d8f147b000002/permissions
    

    JSON response:

    {
      "data": [
        {
          "id": "approve-pull-requests",
          "type": "team_permissions",
          "attributes": {
            "name": "approve-pull-requests",
            "granted_to": "members"
          },
          "meta": {
            "options": [
              "members",
              "owners"
            ]
          }
        },
        {
          "id": "manage-issues",
          "type": "team_permissions",
          "attributes": {
            "name": "manage-issues",
            "granted_to": "members"
          },
          "meta": {
            "options": [
              "members",
              "owners"
            ]
          }
        }
      ]
    }
    

    Retrieves permissions such as which members can manage issues and/or approve pull requests.

    HTTP Request

    POST https://api.codeclimate.com/v1/orgs/:org_id/permissions

    Query Parameters

    N/A

    Get members

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/orgs/596b70adb79d8f147b000002/members
    

    JSON response

    {
      "data":[
        {
          "id": "602c2cfee9c14500fc000001",
          "type": "users",
          "attributes": {
            "email": "[email protected]",
            "full_name": "Lewis Oliver",
            "staff": true,
            "github_login": "lewis_oliver"
          },
          "links": {
            "avatar": "https://avatars.githubusercontent.com/u/11605222"
          }
        },
        {
          "id": "602c2d13e9c14500fc000002",
          "type": "users",
          "attributes": {
            "email": "[email protected]",
            "full_name": "Bob Mendoza",
            "staff": false,
            "github_login": "bob_mendoza"
          },
          "links": {
            "avatar": "https://avatars.githubusercontent.com/u/62915929"
          }
        }
      ]
    }
    

    Returns listing of active members for the specified organization that the authenticated user (user associated with the passed token) has access to.

    HTTP Request

    GET https://api.codeclimate.com/v1/orgs/:org_id/members

    Query Parameters

    Parameter Default Description
    admin_only false If set to true, the result will only include administrator members.

    Paginated

    Remove member

    curl \
      -H "Accept: application/vnd.api+json"
      -H "Authorization: Token token={TOKEN}"
      -X DELETE \
      https://api.codeclimate.com/v1/orgs/596b70adb79d8f147b000002/members/516342ca7e11a428b0025372
    

    Removes the given user from the account members. Be aware that this endpoint is enabled on demand. You should contact our customer support team in order to be able to consume this endpoint, [email protected].

    HTTP Request

    PUT https://api.codeclimate.com/v1/orgs/:org_id/members/:user_id

    Query Parameters

    N/A.

    Create organization

    Given a JSON file "create-org.json" with the following contents ...

    {
      "data": {
        "type": "orgs",
        "attributes": {
          "name": "Twin Peaks",
          "vcs_owner_attributes": {
            "vcs_login": "your-github-org-name"
          }
        }
      }
    }
    

    ... issue the following after replacing {TOKEN} ...

    $ curl \
      -H "Accept: application/vnd.api+json" \
      -H "Content-Type: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      -d @create-org.json \
      https://api.codeclimate.com/v1/orgs
    

    ... which returns JSON like this:

    {
      "data": {
        "id": "596b70adb79d8f147b000002",
        "type": "orgs",
        "attributes": {
          "name": "Black Lodge"
        },
        "meta": {
          "counts": {
            "repos": 0
          },
          "permissions": {
            "admin": true
          }
        }
      }
    }
    

    Creates a new single-person organization with the specified attributes.

    If the organization was created successfully, this endpoint responds with the created organization and status 201.

    HTTP Request

    POST https://api.codeclimate.com/v1/orgs

    POST Parameters

    Request is a JSON API document which complies with the specification for resource creation requests. See example POST in gutter for format.

    For more details, consult Creating Resources.

    Parameter Description Required?
    name Name of the new organization Yes
    vcs_owner_attributes Hash containing attributes to connect the organization to a version control system's organization (e.g. your GitHub organization) for authentication No
    vcs_owner_attributes.vcs_login The name of your GitHub organization to connect to the Code Climate organization No

    Add private repository

    Given a JSON file "create-private-repository.json" with the following contents ...

    {
      "data": {
        "type": "repos",
        "attributes": {
          "url": "https://github.com/twinpeaks/ranchorosa"
        }
      }
    }
    

    .. issue the following after replacing {TOKEN} and the organization id ...

    $ curl \
      -H "Accept: application/vnd.api+json" \
      -H "Content-Type: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      -d @create-private-repository.json \
      https://api.codeclimate.com/v1/orgs/596b70adb79d8f147b000002/repos
    

    ... which returns JSON like this:

    {
      "data": {
        "id": "696a76232df2736347000001",
        "type": "repos",
        "attributes": {
          "analysis_version": 3385,
          "badge_token": "16096d266f46b7c68dd4",
          "branch": "master",
          "created_at": "2017-07-15T20:08:03.731Z",
          "github_slug": "twinpeaks\/ranchorosa",
          "human_name": "ranchorosa",
          "last_activity_at": "2017-07-15T20:08:03.731Z"
        },
        "relationships": {
          "latest_default_branch_snapshot": {
            "data": null
          },
          "latest_default_branch_test_report": {
            "data": null
          },
          "account": {
            "data": {
              "id": "596b70adb79d8f147b000002",
              "type": "orgs"
            }
          }
        },
        "links": {
          "self": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001",
          "services": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/services",
          "web_coverage": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001\/coverage",
          "web_issues": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001\/issues"
        },
        "meta": {
          "permissions": {
            "admin": true
          }
        }
      }
    }
    

    Adds the repository to the specified organization.

    If the repository was added successfully, this endpoint responds with the added repository and status 201.

    HTTP Request

    POST https://api.codeclimate.com/v1/orgs/:org_id/repos

    POST Parameters

    Request is a JSON API document which complies with the specification for resource creation requests. See example POST in gutter for format.

    For more details, consult Creating Resources.

    Parameter Description Required?
    url Code Climate uses the url parameter to determine where your repository is hosted and how to clone it. Currently, only repositories hosted on GitHub are supported, so we only accept https://github.com URLs. Once created, users will still find a Deploy Key added on GitHub and an SSH-based clone URL in their repo settings. Yes

    Get repositories

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/orgs/596b70adb79d8f147b000002/repos
    

    JSON response

    {
      "data": [
        {
          "id": "596a76232df1736777000001",
          "type": "repos",
          "attributes": {
            "analysis_version": 3436,
            "badge_token": "16096d266f46b7c68dc4",
            "branch": "master",
            "created_at": "2017-07-15T20:08:03.732Z",
            "github_slug": "twinpeaks\/ranchorosa",
            "human_name": "ranchorosa",
            "last_activity_at": "2017-07-26T00:42:23.337Z"
          },
          "relationships": {
            "latest_default_branch_snapshot": {
              "data": {
                "id": "5977e4cba2a8970001016f25",
                "type": "snapshots"
              }
            },
            "latest_default_branch_test_report": {
              "data": null
            },
            "account": {
              "data": {
                "id": "596b70adb79d8f147b000002",
                "type": "orgs"
              }
            }
          },
          "links": {
            "self": "https:\/\/codeclimate.com\/repos\/596a76232df1736777000001",
            "services": "https:\/\/api.codeclimate.com\/v1\/repos\/596a76232df1736777000001\/services",
            "web_coverage": "https:\/\/codeclimate.com\/repos\/596a76232df1736777000001\/coverage",
            "web_issues": "https:\/\/codeclimate.com\/repos\/596a76232df1736777000001\/issues"
          },
          "meta": {
            "permissions": {
              "admin": true
            }
          }
        }
      ]
    }
    

    Returns listing of repositories for the specified organization that the authenticated user (user associated with the passed token) has access to.

    HTTP Request

    GET https://api.codeclimate.com/v1/orgs/:org_id/repos

    Query Parameters

    N/A

    Repositories

    Get repository

    Retrieve a repo by github_slug:

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/repos?github_slug=twinpeaks/ranchorosa
    

    Alternatively, if you know the repo_id, you can issue the following:

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001
    

    JSON response:

    {
      "data": [
        {
          "id": "696a76232df2736347000001",
          "type": "repos",
          "attributes": {
            "analysis_version": 3385,
            "badge_token": "16096d266f46b7c68dd4",
            "branch": "master",
            "created_at": "2017-07-15T20:08:03.732Z",
            "github_slug": "twinpeaks\/ranchorosa",
            "human_name": "ranchorosa",
            "last_activity_at": "2017-07-15T20:09:41.846Z",
            "test_reporter_id": "d8ffac8b9a787b957e70ca74b8cac2dff09ed537b8c6023ac0424c8a43381402",
            "total_coverage_enforced": true,
            "vcs_database_id": "92872343",
            "vcs_host": "https://github.com"
          },
          "relationships": {
            "latest_default_branch_snapshot": {
              "data": {
                "id": "596a762c9373ca000100177e",
                "type": "snapshots"
              }
            },
            "latest_default_branch_test_report": {
              "data": null
            },
            "account": {
              "data": {
                "id": "596b70adb79d8f147b000002",
                "type": "orgs"
              }
            }
          },
          "links": {
            "self": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001",
            "services": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/services",
            "web_coverage": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001\/coverage",
            "web_issues": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001\/issues"
          },
          "meta": {
            "permissions": {
              "admin": true
            }
          }
        }
      ]
    }
    

    Retrieves information about the specified repository.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos?github_slug={github_slug}

    OR

    GET https://api.codeclimate.com/v1/repos/:repo_id

    Query Parameters

    Parameter Description Required?
    github_slug GitHub slug in username/reponame format Yes if no :repo_id

    Get ref points

    First page of ref points, for master branch only, which have completed Code Climate analysis.

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "filter[branch]=master" \
      --data-urlencode "filter[analyzed]=true" \
      --data-urlencode "page[size]=3" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/ref_points
    

    JSON response:

    {
      "data": [
        {
          "id": "596922da59abfc0001000170",
          "type": "ref_points",
          "attributes": {
            "analyzed": true,
            "branch": "master",
            "commit_sha": "db36165a645dccb5ac78d3c70dffffa4aef7d8a2",
            "created_at": "2017-07-14T20:00:26.765Z",
            "ref": "refs\/heads\/master"
          },
          "relationships": {
            "snapshot": {
              "data": {
                "id": "596922dbbf0ade0001004b86",
                "type": "snapshots"
              }
            }
          }
        },
        {
          "id": "59691c63f4c69a0002001026",
          "type": "ref_points",
          "attributes": {
            "analyzed": true,
            "branch": "master",
            "commit_sha": "e9a210203b43d1586ca1aa27884c86b914419bff",
            "created_at": "2017-07-14T19:32:51.664Z",
            "ref": "refs\/heads\/master"
          },
          "relationships": {
            "snapshot": {
              "data": {
                "id": "60691c63bf0ade00010042c7",
                "type": "snapshots"
              }
            }
          }
        },
        {
          "id": "6068ee85ce77bd0001000029",
          "type": "ref_points",
          "attributes": {
            "analyzed": true,
            "branch": "master",
            "commit_sha": "6b21824ec86477884482b51284267af8dcfec233",
            "created_at": "2017-07-14T16:17:09.936Z",
            "ref": "refs\/heads\/master"
          },
          "relationships": {
            "snapshot": {
              "data": {
                "id": "59744a9dbf0ade0001003fa3",
                "type": "snapshots"
              }
            }
          }
        }
      ],
      "links": {
        "self": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/ref_points?filter%5Banalyzed%5D=true&filter%5Bbranch%5D=master&page%5Bnumber%5D=1&page%5Bsize%5D=3",
        "next": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/ref_points?filter%5Banalyzed%5D=true&filter%5Bbranch%5D=master&page%5Bnumber%5D=2&page%5Bsize%5D=3",
        "last": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/ref_points?filter%5Banalyzed%5D=true&filter%5Bbranch%5D=master&page%5Bnumber%5D=1760&page%5Bsize%5D=3"
      }
    }
    

    Returns collection of ref points for the repository.

    A ref point is an observation of a commit on a branch at a moment in time. Whenever Code Climate is notified about a new commit (e.g. through webhook events), Code Climate create a ref point for it. It's sort of like our own git log of the actions that occurred on the repository and won't change if you force-push and change history.

    Ref points are sorted by creation date in reverse chronological order.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/ref_points

    Query Parameters

    Paginated, Filterable

    Filters include:

    Name Description Required?
    filter[analyzed] Only ref points which have been analyzed (or not analyzed) by Code Climate No
    filter[branch] Only ref points associated with the specified branch No
    filter[commit_sha] Only ref points associated with the given commit_sha No
    filter[local_ref] Only ref points associated with the given local_ref. Examples include refs/pulls/553/head and ref/heads/master No

    Get repository services

    curl
      -H "Accept: application/vnd.api+json"
      -H "Authorization: Token token={TOKEN}"
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/services
    

    JSON response:

    {
      "data": [
        {
          "id": "58f0ee6f2f1eba0290004322",
          "type": "services",
          "attributes": {
            "slug": "flowdock",
            "title": "Flowdock",
            "description": "Send messages to a Flowdock inbox"
          },
          "links": {
            "events": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/services\/58f0ee6f2f1eba0290004322\/events"
          }
        },
        {
          "id": "53c97739e30ba123fd00abd3",
          "type": "services",
          "attributes": {
            "slug": "githubpullrequests",
            "title": "GitHub Pull Requests",
            "description": "Update pull requests on GitHub"
          },
          "links": {
            "events": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/services\/53c97739e30ba123fd00abd3\/events"
          }
        },
        {
          "id": "8953edc0e30ba06dfd0017d3",
          "type": "services",
          "attributes": {
            "slug": "hipchat",
            "title": "HipChat",
            "description": "Send messages to a HipChat chat room"
          },
          "links": {
            "events": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/services\/8953edc0e30ba06dfd0017d3\/events"
          }
        },
        {
          "id": "22272d8e6afbed290a0000eb",
          "type": "services",
          "attributes": {
            "slug": "jira",
            "title": "JIRA",
            "description": "Create tickets in JIRA"
          },
          "links": {
            "events": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/services\/22272d8e6afbed290a0000eb\/events"
          }
        },
        {
          "id": "666958c7695680518a002624",
          "type": "services",
          "attributes": {
            "slug": "slack",
            "title": "Slack",
            "description": "Send messages to a Slack channel"
          },
          "links": {
            "events": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/services\/666958c7695680518a002624\/events"
          }
        }
      ]
    }
    

    Returns a collection of (external) service integrations for a particular repository.

    There are few types of integrations:

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/services

    Query Parameters

    Filterable

    Filters include:

    Name Description Required?
    filter[type] Only integrations of this type. Only supports issue_tracker value at the moment. No

    Trigger new service event

    Given a JSON file "trigger-event.json" with the following contents ...

    {
      "data": {
        "attributes": {
          "name": "issue",
          "issue": {
            "check_name": "Metrics/CyclomaticComplexity",
            "description": "Cyclomatic complexity for method is too high.",
            "details_url": "http://example.com/repos/1/issues#issue_12345",
            "id": "12345",
            "location": {
              "path": "foo.rb"
            }
          }
        }
      }
    }
    

    ... issue the following after replacing {TOKEN} ...

    $ curl \
      -H "Accept: application/vnd.api+json" \
      -H "Content-Type: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      -d @trigger-event.json \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/services/666958c7695680518a002624/events
    

    ... which returns JSON like this:

    {
      "data": {
        "attributes": {
          "ok": true,
          "message": "Success"
        },
        "id": "700a76232df2736347000201",
        "type": "service_events",
        "links": {
          "external": "https://github.com/example/repo/issues/100"
        }
      }
    }
    

    Trigger an event to be consumed by one of the repository's service integrations.

    HTTP Request

    POST https://api.codeclimate.com/v1/repos/:repo_id/services/:service_id/events

    POST Parameters

    Request is a JSON API document which complies with the specification for resource creation requests. See example POST in gutter for format.

    For more details, consult Creating Resources.

    Add public (OSS) repository

    Given a JSON file "create-public-repository.json" with the following contents ...

    {
      "data": {
        "type": "repos",
        "attributes": {
          "url": "https://github.com/twinpeaks/ranchorosa"
        }
      }
    }
    

    .. issue the following after replacing {TOKEN} and the organization id ...

    $ curl \
      -H "Accept: application/vnd.api+json" \
      -H "Content-Type: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      -d @create-public-repository.json \
      https://api.codeclimate.com/v1/github/repos
    

    ... which returns JSON like this:

    {
      "data": {
        "id": "5977b29ed9371b0266334433",
        "type": "repos",
        "attributes": {
          "analysis_version": 3436,
          "badge_token": "a5bf2eef77b257ea5bb8",
          "branch": "master",
          "created_at": "2017-07-25T21:05:34.827Z",
          "github_slug": "twinpeaks\/ranchorosa",
          "human_name": "brew",
          "last_activity_at": "2017-07-25T21:05:34.827Z",
          "vcs_database_id": "92872343",
          "vcs_host": "https://github.com"
        },
        "relationships": {
          "latest_default_branch_snapshot": {
            "data": null
          },
          "latest_default_branch_test_report": {
            "data": null
          },
          "account": {
            "data": null
          }
        },
        "links": {
          "self": "https:\/\/codeclimate.com\/github\/twinpeaks\/ranchorosa",
          "services": "https:\/\/api.codeclimate.com\/v1\/repos\/5977b29ed9371b0266334433\/services",
          "web_coverage": "https:\/\/codeclimate.com\/github\/twinpeaks\/ranchorosa\/coverage",
          "web_issues": "https:\/\/codeclimate.com\/github\/twinpeaks\/ranchorosa\/issues"
        },
        "meta": {
          "permissions": {
            "admin": true
          }
        }
      }
    }
    

    Add a GitHub open source repository to Code Climate

    If the repository was added successfully, this endpoint responds with the added repository and status 201.

    HTTP Request

    POST https://api.codeclimate.com/v1/github/repos

    POST Parameters

    Request is a JSON API document which complies with the specification for resource creation requests. See example POST in gutter for format.

    For more details, consult Creating Resources.

    Parameter Description Required?
    url Code Climate uses the url parameter to determine where your repository is hosted and how to clone it. Currently, only repositories hosted on GitHub are supported, so we only accept https://github.com URLs. Once created, users will still find a Deploy Key added on GitHub and an SSH-based clone URL in their repo settings. Yes

    Update private repository

    # note: to remove a delegated configuration repository,
    # pass the setting without a value
    # --data "data[attributes][delegated_config_repo_id]"
    
    curl \
      -H "Accept: application/vnd.api+json"
      -H "Authorization: Token token={TOKEN}"
      -X PUT \
      --data "data[attributes][delegated_config_repo_id]=5b3115402954870021000001"
      https://api.codeclimate.com/v1/orgs/5a81d1bbbb0c5d026b000001/repos/696a76232df2736347000001
    

    JSON response:

    {
      "data": {
        "id": "696a76232df2736347000001",
        "type": "repos",
        "attributes": {
          "analysis_version": 3385,
          "badge_token": "16096d266f46b7c68dd4",
          "branch": "master",
          "created_at": "2017-07-15T20:08:03.732Z",
          "delegated_config_repo_id": "5b3115402954870021000001",
          "github_slug": "twinpeaks\/ranchorosa",
          "human_name": "ranchorosa",
          "last_activity_at": "2017-07-15T20:09:41.846Z",
          "vcs_database_id": "92872343",
          "vcs_host": "https://github.com"
        },
        "relationships": {
          "latest_default_branch_snapshot": {
            "data": {
              "id": "596a762c9373ca000100177e",
              "type": "snapshots"
            }
          },
          "latest_default_branch_test_report": {
            "data": null
          },
          "account": {
            "data": {
              "id": "5a81d1bbbb0c5d026b000001",
              "type": "orgs"
            }
          }
        },
        "links": {
          "self": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001",
          "services": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/services",
          "web_coverage": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001\/coverage",
          "web_issues": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001\/issues"
        },
        "meta": {
          "permissions": {
            "admin": true
          }
        }
      }
    }
    

    Update a private repository on Code Climate

    Currently this endpoint can only be used to configure delegated analysis for private repositories.

    If the repository is updated successfully, this endpoint responds with the updated repository and status 200.

    HTTP Request

    PUT https://api.codeclimate.com/v1/orgs/:org_id/repos/:repo_id

    PUT Parameters

    Request is a JSON API document which complies with the specification for resource update requests. See example PUT in gutter for format.

    For more details, consult Updating Resources.

    Permitted update parameters:

    Parameter Description Required?
    delegated_config_repo_id The repo_id of another repository within the organization to be used as the configuration repository No

    Delete private repository

    curl \
      -H "Accept: application/vnd.api+json"
      -H "Authorization: Token token={TOKEN}"
      -X DELETE \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001
    

    Delete a private repository on Code Climate

    If the repository is deleted successfully, this endpoint responds with status 204.

    HTTP Request

    DELTE https://api.codeclimate.com/v1/repos/:repo_id

    Repository Analysis

    Get issues

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "page[size]=3" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/snapshots/596922dbbf0ade0001004b87/issues
    

    JSON response:

    {
      "data": [
        {
          "id": "59692f9909bf630001000046",
          "type": "issues",
          "attributes": {
            "categories": [
              "Complexity"
            ],
            "check_name": "method_count",
            "constant_name": "lib\/book.rb",
            "content": {
              "body": ""
            },
            "description": "Class `Check` has 22 methods (exceeds 20 allowed). Consider refactoring.",
            "engine_name": "structure",
            "fingerprint": "15447258442b0314aa1543ec0eced333",
            "location": {
              "path": "lib\/book.rb",
              "end_line": 205,
              "start_line": 7
            },
            "other_locations": [
    
            ],
            "remediation_points": 1400000,
            "severity": "minor"
          },
          "meta": {
            "permissions": {
              "manageable": true
            }
          }
        },
        {
          "id": "59692f9c09bf630001000060",
          "type": "issues",
          "attributes": {
            "categories": [
              "Style"
            ],
            "check_name": "Rubocop\/Style\/WordArray",
            "constant_name": "lib\/book.rb",
            "content": {
              "body": "This cop can check for array literals made up of word-like\nstrings, that are not using the %w() syntax.\n\nAlternatively, it can check for uses of the %w() syntax, in projects\nwhich do not want to include that syntax."
            },
            "description": "Use `%w` or `%W` for an array of words.",
            "engine_name": "rubocop",
            "fingerprint": "f506a038288d1d6b9dab5f7bcc3528dd",
            "location": {
              "path": "lib\/book.rb",
              "end_line": 31,
              "start_line": 31
            },
            "other_locations": [
    
            ],
            "remediation_points": 50000,
            "severity": "minor",
            "status": {
              "details": "",
              "name": "invalid",
              "updated_at": "2017-07-11T22:04:32.145Z",
              "updated_by_id": "57ae4e45a41eb700640014ec"
            }
          },
          "meta": {
            "permissions": {
              "manageable": true
            }
          }
        },
        {
          "id": "59692f9c09bf63000100005d",
          "type": "issues",
          "attributes": {
            "categories": [
              "Style"
            ],
            "check_name": "Rubocop\/Style\/MethodName",
            "constant_name": "lib\/book.rb",
            "content": {
              "body": "This cop makes sure that all methods use the configured style,\nsnake_case or camelCase, for their names. Some special arrangements\nhave to be made for operator methods."
            },
            "description": "Use snake_case for method names.",
            "engine_name": "rubocop",
            "fingerprint": "6a6479b6d3d525ad5a6543fc076b1711",
            "location": {
              "path": "lib\/book.rb",
              "end_line": 11,
              "start_line": 11
            },
            "other_locations": [
    
            ],
            "remediation_points": 50000,
            "severity": "minor",
            "status": {
              "details": "",
              "name": "invalid",
              "updated_at": "2017-07-11T22:03:30.320Z",
              "updated_by_id": "57ae4e45a41eb700640014ec"
            }
          },
          "meta": {
            "permissions": {
              "manageable": true
            }
          }
        }
      ],
      "links": {
        "self": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/snapshots\/596922dbbf0ade0001004b87\/issues?page%5Bnumber%5D=1&page%5Bsize%5D=3",
        "next": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/snapshots\/596922dbbf0ade0001004b87\/issues?page%5Bnumber%5D=2&page%5Bsize%5D=3",
        "last": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/snapshots\/596922dbbf0ade0001004b87\/issues?page%5Bnumber%5D=9&page%5Bsize%5D=3"
      },
      "meta": {
        "current_page": 1,
        "total_pages": 9,
        "total_count": 25
      }
    }
    

    Returns a paginated collection of analysis issues found by the snapshot. Each issue found includes its status ("invalid", "won't fix" etc), location, fingerprint, severity and other details.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/snapshots/:snapshot_id/issues

    Query Parameters

    Paginated, Filterable, Sortable

    Filters include:

    Name Description Required?
    filter[categories] Single path or $in clause containing list of categories No
    filter[severity] Single severity or $in clause containing list of severities No
    filter[status] Single status or $in clause containing list of statuses No
    filter[location.path] Single path or $in clause containing list of statuses No

    Get files

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "page[size]=3" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/snapshots/596922dbbf0ade0001004b87/files
    

    JSON response:

    {
      "data": [
        {
          "id": "59692f9709bf630001000004",
          "type": "constants",
          "attributes": {
            "blob_id": "c101538850228bcb9a91916ce1ce33fe34a75658",
            "path": "lib/book.rb",
            "rating": []
          }
        },
        {
          "id": "59692f9709bf630001000043",
          "type": "constants",
          "attributes": {
            "blob_id": "19e1f6c863dca39b1724b0007fbc8b3564411a14",
            "path": "lib/group.rb",
            "rating": [
              {
                "path": "lib/group.rb",
                "letter": "A",
                "measure": {
                    "value": 0,
                    "unit": "minute"
                },
                "pillar": "Maintainability"
              },
              {
                "letter": "A",
                "measure": {
                  "unit": "percent",
                  "value": 95.0,
                },
                "path": "lib/group.rb",
                "pillar": "Test Coverage",
              }
            ]
          }
        },
        {
          "id": "59692f9709bf630001000022",
          "type": "constants",
          "attributes": {
            "blob_id": "e1166417d88ba5dad15a47564146a68ac3c50222",
            "path": "lib/user.rb",
            "rating": [
              {
                "path": "lib/user.rb",
                "letter": "B",
                "measure": {
                    "value": 400,
                    "unit": "minute"
                },
                "pillar": "Maintainability"
              },
              {
                "letter": "B",
                "measure": {
                  "unit": "percent",
                  "value": 80.0,
                },
                "path": "lib/user.rb",
                "pillar": "Test Coverage",
              }
            ]
          }
        }
      ],
      "links": {
        "self": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/snapshots\/596922dbbf0ade0001004b87\/files?page%5Bnumber%5D=1&page%5Bsize%5D=3",
        "next": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/snapshots\/596922dbbf0ade0001004b87\/files?page%5Bnumber%5D=2&page%5Bsize%5D=3",
        "last": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/snapshots\/596922dbbf0ade0001004b87\/files?page%5Bnumber%5D=20&page%5Bsize%5D=3"
      }
    }
    

    Retrieve analysis of files associated with a given snapshot.

    Sorted by path in ascending order.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/snapshots/:snapshot_id/files

    Query Parameters

    Paginated, Filterable

    Filters include:

    Name Description Required?
    filter[path] Single path, $in clause containing list of categories or $regex clause containing regular expressions No

    Get builds

    Running builds:

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "filter[state]=running" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/builds
    

    JSON response:

    {
      "data": [
        {
          "id": "584ec7bb46607e0001004eda",
          "type": "builds",
          "attributes": {
            "commit_sha": "42d2908f95610fd1ae429bbb7f4b09e50dbd0672",
            "error_code": null,
            "finished_at": null,
            "local_ref": "refs\/pull\/3302\/head",
            "number": 6723,
            "state": "running"
          },
          "relationships": {
            "pull_request": {
              "data": {
                "id": "584ec7bad211e6000103444e",
                "type": "pull_requests"
              }
            },
            "snapshot": {
              "data": null
            }
          },
          "links": {
            "self": "https:\/\/codeclimate.com\/repos\/5017075af3ea000dc6000740\/builds\/6723"
          }
        },
        {
          "id": "56af8a388542010001002d11",
          "type": "builds",
          "attributes": {
            "commit_sha": "5c44e9a9e70c17133b9f7473dd57b08eb91b111d",
            "error_code": null,
            "finished_at": null,
            "local_ref": "refs\/pull\/2124\/head",
            "number": 1624,
            "state": "running"
          },
          "relationships": {
            "pull_request": {
              "data": {
                "id": "56abdbcf8fdd16000103b200",
                "type": "pull_requests"
              }
            },
            "snapshot": {
              "data": null
            }
          },
          "links": {
            "self": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001\/builds\/1624"
          }
        }
      ],
      "links": {
    
      }
    }
    

    Returns collection of builds for the repository, sorted in descending order by build number.

    Builds represent an attempt to run analysis on a particular commit of a repository. Builds may not have started or finished, or finished successfully.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/builds

    Query Parameters

    Paginated, Filterable

    Filters include:

    Name Description Required?
    filter[state] Only builds in a particular state. Supports the states new or running No
    filter[local_ref] Only builds associated with the given local_ref. Examples include refs/pulls/553/head and ref/heads/master No

    Get build

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/builds/10678
    

    JSON response:

    {
      "data": {
        "id": "596922dccf0ade0001004b98",
        "type": "builds",
        "attributes": {
          "commit_sha": "db36165a645accc5ac78d3c70dffffa4aef7d8a2",
          "error_code": null,
          "finished_at": "2017-07-14T20:03:14.050Z",
          "local_ref": "refs\/heads\/master",
          "number": 10678,
          "state": "complete"
        },
        "relationships": {
          "pull_request": {
            "data": null
          },
          "snapshot": {
            "data": {
              "id": "596922dbbf0ade0001004b87",
              "type": "snapshots"
            }
          }
        },
        "links": {
          "self": "https:\/\/codeclimate.com\/repos\/696a76232df2736347000001\/builds\/10678"
        }
      }
    }
    

    A build represent an attempt to run analysis on a particular commit of a repository. Builds may not have started or finished, or finished successfully.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/builds/:number

    Query Parameters

    N/A

    Get snapshot

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/snapshots/596922dbbf0ade0001004b87
    

    JSON response:

    {
      "data": {
        "id": "596922dbbf0ade0001004b87",
        "type": "snapshots",
        "attributes": {
          "commit_sha": "db36165a645accc5ac78d3c70dffffa4aef7d8a2",
          "committed_at": "2017-07-14T20:00:26.765Z",
          "created_at": "2017-07-14T20:03:14.042Z",
          "lines_of_code": 456,
          "ratings": [
            {
              "letter": "A",
              "path": "\/",
              "measure": {
                "value": 3.0210800735343,
                "unit": "percent"
              },
              "pillar": "Maintainability"
            }
          ],
          "gpa": null,
          "worker_version": 33840
        },
        "meta": {
          "issues_count": 6037,
          "measures": {
            "remediation": {
              "value": 20007.3,
              "unit": "minute"
            },
            "technical_debt_ratio": {
              "value": 3.0210800735343,
              "unit": "percent"
            }
          }
        }
      }
    }
    

    Retrieves information associated with a given snapshot.

    A snapshot represents a successful completed analysis of a specific commit.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/snapshots/:snapshot_id

    Query Parameters

    N/A

    Get time series

    Retrieves the diff coverage for each week between 2017-04-01 and 2017-05-01.

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get
      --data-urlencode "filter[from]=2017-04-01"
      --data-urlencode "filter[to]=2017-05-01"
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/metrics/diff_coverage
    

    JSON response. points is an array of data points each containing a timestamp and value.

    {
      "data": {
        "id": "58b05f886d9cd4bb01000123",
        "type": "metrics",
        "attributes": {
          "name": "diff_coverage",
          "points": [
            {
              "timestamp": 1490572800,
              "value": 100.0
            },
            {
              "timestamp": 1491177600,
              "value": 97.08
            },
            {
              "timestamp": 1491782400,
              "value": 99.0
            },
            {
              "timestamp": 1492387200,
              "value": 100.0
            },
            {
              "timestamp": 1492992000,
              "value": 100.0
            },
            {
              "timestamp": 1493596800,
              "value": 100.0
            }
          ]
        }
      }
    }
    

    Returns information about a particular repository metric as a time series. The time series returned is an array of data points, each containing a timestamp and a value for the metric at that timestamp. A range of time is required, provided by passing query parameters filter[to] and filter[from].

    Currently, data points are captured and returned in weekly increments only. The timestamp for a particular data point represents the start of that time period.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/metrics/:metric

    :metric can take one of the following values:

    Metric Description
    loc.[Language] Lines of code for Language. Ex.: loc.JavaScript
    diff_coverage Diff coverage for that data point
    remediation_minutes Calculated minutes to fix issues for that data point
    technical_debt_ratio Technical debt ratio for that data point
    test_coverage Test coverage percentage for that data point

    Query Parameters

    Paginated, Filterable

    Filters include:

    Name Description Required?
    filter[from] Start date of time series range, in YYYY-MM-DD format Yes
    filter[to] End date of time series range, in YYYY-MM-DD format Yes

    Test Coverage

    Get test coverage reports

    curl
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "page[size]=3" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/test_reports
    

    JSON response

    {
      "data": [
        {
          "id": "596ad7629c5b3756bc000003",
          "type": "test_reports",
          "attributes": {
            "branch": "master",
            "commit_sha": "cd3811626d5f723130417735d10a132f285795cc",
            "committed_at": "2017-07-16T02:55:52.000Z",
            "covered_percent": 84.946657957762,
            "lines_of_code": 456,
            "rating": {
              "path": "\/",
              "letter": "B",
              "measure": {
                "value": 84.946657957762,
                "unit": "percent"
              },
              "pillar": "Test Coverage"
            },
            "received_at": "2018-09-06T20:25:28.098Z",
            "state": "done"
          }
        },
        {
          "id": "596ad4e7e13a1a079100000f",
          "type": "test_reports",
          "attributes": {
            "branch": "master",
            "commit_sha": "a06a461bd0659d733073024434c952445fa4ba77",
            "committed_at": "2017-07-16T02:36:27.000Z",
            "covered_percent": 84.946657957762,
            "rating": {
              "path": "\/",
              "letter": "B",
              "measure": {
                "value": 84.946657957762,
                "unit": "percent"
              },
              "pillar": "Test Coverage"
            },
            "received_at": "2018-09-05T20:25:28.098Z",
            "state": "done"
          }
        },
        {
          "id": "5969249a7834e60266000001",
          "type": "test_reports",
          "attributes": {
            "branch": "master",
            "commit_sha": "db36165a645abbb5ac78d3c70dffffa4aef7d832",
            "committed_at": "2017-07-14T20:00:24.000Z",
            "covered_percent": 84.9460024386,
            "rating": {
              "path": "\/",
              "letter": "B",
              "measure": {
                "value": 84.9460024386,
                "unit": "percent"
              },
              "pillar": "Test Coverage"
            },
            "received_at": "2018-09-04T20:25:28.098Z",
            "state": "done"
          }
        }
      ],
      "links": {
        "self": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/test_reports?page%5Bnumber%5D=1&page%5Bsize%5D=3",
        "next": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/test_reports?page%5Bnumber%5D=2&page%5Bsize%5D=3",
        "last": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/test_reports?page%5Bnumber%5D=163&page%5Bsize%5D=3"
      }
    }
    

    Gets collection of test coverage reports, sorted by committed at descending.

    Each test coverage report contains the overall coverage percentage and test coverage rating for the repository at a specific commit. Does not contain line by line coverage: line by line coverage is available via the test file reports endpoint.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/test_reports

    Query Parameters

    Paginated, Filterable

    Filters include:

    Name Description Required?
    filter[branch] Test reports associated with the specified branch No

    Get test coverage file reports

    curl
      -H "Accept: application/vnd.api+json"
      -H "Authorization: Token token={TOKEN}"
      --get
      --data-urlencode "page[size]=3"
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/test_reports/596ad7629c5b3756bc000003/test_file_reports
    
    {
      "data": [
        {
          "id": "596ad7622df1731de500015e",
          "type": "test_file_reports",
          "attributes": {
            "coverage": [4, 4, 4, 4, null, 4, null, 4, 6, 2, null, 2, null, null, null, 1, null, null, 1, null, null, 4, 6, 3, null, 3, null, 3, 2, 2, null, 1, null, null, null, 4, null, 4, 6, null, null, 4, null, null, 3, null, null, 4, 2, 2, 2, null, 2, null, null, null, null, null, null, 4, 2, 1, null, 1, null, null, null, null],
            "covered_percent": 100,
            "covered_strength": 3.0606060606061,
            "path": "lib\/book.rb",
            "line_counts": {
              "missed": 0,
              "covered": 33,
              "total": 33
            }
          }
        },
        {
          "id": "596ad7622df1731de5000147",
          "type": "test_file_reports",
          "attributes": {
            "coverage": [4, 4, 4, null, 4, null, 4, 12, 5, null, 5, 1, null, null, 4, 1, null, null, 3, 1, null, null, 2, 2, null, null, 4, null, 4, 1, 1, null, null, 4, 1, null, null, null, null, null, 4, 1, null, null, null, null, null, 4, 2, null, 2, null, null, null, 4, 24, null, null, 4, 1, 1, null, null, null, null, 1, null, null, 4, 5, null, null, null],
            "covered_percent": 100,
            "covered_strength": 3.7647058823529,
            "path": "lib\/group.rb",
            "line_counts": {
              "missed": 0,
              "covered": 34,
              "total": 34
            }
          }
        },
        {
          "id": "596ad762e13a1a6a9d0000a8",
          "type": "test_file_reports",
          "attributes": {
            "coverage": [4, 4, 4, null, 4, null, 4, 4, 6, null, 2, null, null, null],
            "covered_percent": 100,
            "covered_strength": 4,
            "path": "lib\/user.rb",
            "line_counts": {
              "missed": 0,
              "covered": 8,
              "total": 8
            }
          }
        }
      ],
      "links": {
        "self": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/test_reports\/596ad7629c5b3756bc000003\/test_file_reports?page%5Bnumber%5D=1&page%5Bsize%5D=3",
        "next": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/test_reports\/596ad7629c5b3756bc000003\/test_file_reports?page%5Bnumber%5D=2&page%5Bsize%5D=3",
        "last": "https:\/\/api.codeclimate.com\/v1\/repos\/696a76232df2736347000001\/test_reports\/596ad7629c5b3756bc000003\/test_file_reports?page%5Bnumber%5D=307&page%5Bsize%5D=3"
      }
    }
    

    Gets collection of test coverage file reports, containing line by line coverage information.

    The coverage attribute contains an array of coverage information. null in the array means that line is "uncoverable" (e.g. blank line or comment), a number in the array represents how many times that line was covered by tests.

    Sorted by file paths in ascending order.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/test_reports/:test_report_id/test_file_reports

    Query Parameters

    Paginated

    Sending test coverage data

    While the API also supports receiving test coverage data from your build, we generally do not recommend issuing calls against these endpoints yourself and as such have not documented them.

    Instead, we recommend that you use our test reporter client which takes care of this plumbing for you.

    If the test reporter doesn't suit your specific needs, open an issue or pull request on that repository.

    Pull Requests

    Get rating changes

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --get \
      --data-urlencode "filter[path]=lib/book.rb" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/pulls/65/files
    

    JSON response:

    {
      "data": [
        {
          "id": "69926c2c28352600010003db-59726c2f1e3c870001000312",
          "type": "file_diffs",
          "attributes": {
            "to_rating": "unrated",
            "from_rating": "unrated",
            "path": "lib\/book.rb"
          }
        }
      ]
    }
    

    Returns rating changes for files in a pull request.

    HTTP Request

    GET https://api.codeclimate.com/v1/repos/:repo_id/pulls/:number/files

    Query Parameters

    Filterable

    Filters include:

    Name Description Required?
    filter[path] Complete file path for file to filter by Yes

    Approve PRs

    curl \
      -H "Accept: application/vnd.api+json" \
      -H "Authorization: Token token={TOKEN}" \
      --data-urlencode "data[attributes][reason]=merge" \
      https://api.codeclimate.com/v1/repos/696a76232df2736347000001/pulls/65/approvals
    

    JSON response:

    {
      "data": {
        "id": "5a60de1a4668b4650a000b5a",
        "type": "approvals",
        "attributes": {
          "reason": "merge",
          "created_at": "2018-01-18T17:49:14.458Z"
        },
        "relationships": {
          "author": {
            "data": {
              "id": "516341ca7e00a428b0015372",
              "type": "users"
            }
          },
          "pull_request": {
            "data": {
              "id": "5a60d683af0a490001000a71",
              "type": "pull_requests"
            }
          },
          "repo": {
            "data": {
              "id": "696a76232df2736347000001",
              "type": "repos"
            }
          }
        }
      }
    }
    

    Approves a given pull request.

    HTTP Request

    POST https://api.codeclimate.com/v1/repos/:repo_id/pulls/:number/approvals